Body: <p>I have data in paired-end as well as single-end format for the same sample.I would like to split those two files into two per each, where one contains sequences that have 5' end and the other one has 3' ends.</p>
  <p>So the paired end data has R1 and R2, if R1 is first, it has 5' ends and if not, it has 3' ends? And I'd do the same thing for the single end data.</p>
  <p>I'm using samtools and pysam.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-12T12:50:27.723Z
Comments.Text: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Comments.UserDisplayName: Community
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-12T19:16:14.830Z
Comments.Text: It's unclear what you're asking. Sequences are almost always written out to files in the 5' to 3' direction.
Comments.UserDisplayName: gringer
Tags: <samtools><pysam>
Title: How do I filter reads from a bamfile based on 5' and 3' ends?
ThreadText: # How do I filter reads from a bamfile based on 5' and 3' ends?
  
  (Asked by: username_0 on 2023-02-12)
  
  I have data in paired-end as well as single-end format for the same sample.I would like to split those two files into two per each, where one contains sequences that have 5' end and the other one has 3' ends.
  
  So the paired end data has R1 and R2, if R1 is first, it has 5' ends and if not, it has 3' ends? And I'd do the same thing for the single end data.
  
  I'm using samtools and pysam.
  
  **Tags:** samtools, pysam
  
  > **Comments:**
  > **username_1**: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.  
  > **username_2**: It's unclear what you're asking. Sequences are almost always written out to files in the 5' to 3' direction.  
  
  ---
  
  ## 0 answers
  
  