Open bioinformatica opened 4 months ago
I want to count the number of reads for the mutation T>C, I used the following code:
query_seq = read.query_sequence ref_seq = reference.fetch(read.reference_name, read.reference_start, read.reference_end) alignments = read.get_aligned_pairs(matches_only=True, with_seq=True) for query_pos, ref_pos, ref_base in alignments: if ref_base.upper() == 'T' and query_seq[query_pos].upper() == 'C': tc_count += 1 print(query_seq) print(ref_seq) break
Output: CATTTCTTAGTCCTACACACTAAAAACAGTAATGTGCTGCTTTGAGTGTGTAGGACTAAGAAATGGGATTCAGAGTAGTAAAGAGAAAAGTGGAATTTCCAAGCACTATGAATTACTGTTCTTTAAAAAACAGCAAAAATC
ACTTTAAAAACAGTAATGTGCTGCTTTGAGTGTGTAGGACTAAGAAATGGGATTCAGAGTAGTAAAGAGAAAAGTGGAATTTCCAAGCACTATGAATTACTGTTCTTTAAAAAACAGCAAAAATC
I set matches_only=True. Normally, tccount is always equal to 0. Why are their lengths different? causing tccount to increase
If matches_only=True is set, will only the exact same base pairs be returned? How should I change the code to count the number of reads with t>C?
I want to count the number of reads for the mutation T>C, I used the following code:
Output: CATTTCTTAGTCCTACACACTAAAAACAGTAATGTGCTGCTTTGAGTGTGTAGGACTAAGAAATGGGATTCAGAGTAGTAAAGAGAAAAGTGGAATTTCCAAGCACTATGAATTACTGTTCTTTAAAAAACAGCAAAAATC
ACTTTAAAAACAGTAATGTGCTGCTTTGAGTGTGTAGGACTAAGAAATGGGATTCAGAGTAGTAAAGAGAAAAGTGGAATTTCCAAGCACTATGAATTACTGTTCTTTAAAAAACAGCAAAAATC
I set matches_only=True. Normally, tccount is always equal to 0. Why are their lengths different? causing tccount to increase