Retrieve query start and end positions on reverse strand with Pysam
0
0
Entering edit mode
11 days ago
María José ▴ 10

I'm using the pysam library to work with BAM files and extract the alignment positions of my target sequence. I've implemented a conditional logic to handle reverse strand alignments, but I'm not getting the expected results.

for read in bamfile.fetch():
    print("ref_name:", read.reference_name)
    print("ref_start:", read.reference_start)
    print("ref_end:", read.reference_end)
    if read.is_reverse:
        query_start = len(read.seq) - read.query_alignment_end
        query_end = len(read.seq) - read.query_alignment_start
    else:
        query_start = read.query_alignment_start
        query_end = read.query_alignment_end
    print("query_start:", query_start)
    print("query_end:", query_end)
Reference Name: ref
Reference Start: 0
Reference End: 70
Query Start: 0
Query End: 70
Reference Name: ref
Reference Start: 70
Reference End: 101
Query Start: 0 x -> 70
Query End: 31 x -> 101
python alignment Pysam • 428 views
ADD COMMENT
0
Entering edit mode

but I'm not getting the expected results.

What results are you expecting?

ADD REPLY

Login before adding your answer.

Traffic: 1346 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