Extract the mate pair information with htsjdk
1
0
Entering edit mode
5.7 years ago
mhasa006 ▴ 70

I have a BAM file sorted by position. I need to process a group of reads from the BAM file at a time. To process that, I need to access the mate pair of each of these read at the same time. Is there a way using htsjdk to access the mate pair information using the information of the other pair.

I can get the Mate Pair record name with getMateReferenceName() and alignment start position by getMateAlignmentStart(). But I need to access the read sequence and the base quality string and the flag of the mate pair. How can I do that? Thanks.

BAM samtools htsjdk • 1.4k views
ADD COMMENT
2
Entering edit mode
5.7 years ago

SAMReader$queryMate : https://samtools.github.io/htsjdk/javadoc/htsjdk/htsjdk/samtools/SamReader.html#queryMate-htsjdk.samtools.SAMRecord-

Fetch the mate for the given read. Only valid to call this if hasIndex() == true. This will work whether the mate has a coordinate or not, so long as the given read has correct mate information. This method iterates over the SAM file, so there may not be an unclosed iterator on the SAM file when this method is called.

Note that it is not possible to call queryMate when iterating over the SamReader, because queryMate requires its own iteration, and there cannot be two simultaneous iterations on the same SamReader. The work-around is to open a second SamReader on the same input file, and call queryMate on the second reader.

ADD COMMENT

Login before adding your answer.

Traffic: 2057 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6