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

Pysam ignoring some reads? #1300

Open
rLannes opened this issue Jul 29, 2024 · 0 comments
Open

Pysam ignoring some reads? #1300

rLannes opened this issue Jul 29, 2024 · 0 comments

Comments

@rLannes
Copy link

rLannes commented Jul 29, 2024

Hi,

First a bit of context:
I do want to modify TEtools to be able to use pysam so it can accept bam.

issue:
But my version returns less read than the TE tools version.

Can someone explain to me why my code returns fewer reads? From my understanding, they are equivalent, except for the use of pysam. Note my version returns the exact number of mapped reads (samtools flagstat), TEtools returns more. (does pysam filter secondary per default?)

TEtools version:

with open(self.sam_file) as sam_file_handle:
   for line in sam_file_handle:
      if line[0] != '@':
         line = line.split()
         if len(line) > 4 and line[2][0] != '*' and int(line[4]) <= self.max_mapq:
            self.rosette.count(str(line[2]), 1)

My version:


with ps.AlignmentFile(self.sam_file, open_mode)  as sam_file_handle:
   for aln in sam_file_handle.fetch(until_eof=True):
      if aln.is_mapped and aln.mapping_quality <= self.max_mapq:
         self.rosette.count(aln.reference_name, 1)

Any help warmly appreciated.

Romain,

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