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?
Thanks. I got basically the same answer from the the GATK group, for future reference here's a link to their answer. http://getsatisfaction.com/gsa/topics/how_to_access_the_mate_of_a_record