Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about read.get_aligned_pairs(matches_only=True, with_seq=True) #1283

Open
bioinformatica opened this issue Apr 24, 2024 · 1 comment
Open

Comments

@bioinformatica
Copy link

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

@bioinformatica
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant