This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Accessing Mate Of Samrecord Using Gatk

I'm wondering how to access the mate of a sam record using GATK. Right now I'm doing this:

if(samRecord.getReadPairedFlag()){ 
    SAMFileReader samfileReader = samRecord.getFileSource().getReader(); 
    SAMRecord mate = samfileReader.queryMate(samRecord); 
    mates.add(mate); 
}

Whoever, this fails with the error message: java.lang.RuntimeException: java.lang.IllegalStateException: Iteration in progress

This lead me to have a closer look at the documentation of SamFileReader in SAM JDK, and it states that there cannot be any open iterators over the sam file while calling this method.

Does anyone know if the walker keeps a iterator open over this file? And if so, is there any way for me to close it? Or better still, is there a GATK method for accessing the mate of the record?

gatk java

1 answer

You could open another SAMFileReader and query the mate with this second instance.

Log in to answer this question.