This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Filtering BAM file to extract PE reads that mapped as proper pairs, including PE reads that did not map, but their mate did

Hi!

I'm working on the assembly of a chloroplast genome. I have a bam file and I wanted to:

  1. Remove pairs that did not map to the reference genome
  2. Keep reads that are mapped as proper pairs
  3. Keep reads in a pair where one read mapped but the other did not (I want to include the unmapped read if its pair mapped properly)

I have been reading about the flags and my teacher and I did the following steps:

samtools fastq   -f 3   -1 paired_1.fastq   -2 paired_2.fastq   zm_cp.bam           
samtools fastq   -f 9   -1 unmapped_1.fastq   -2 unmapped_2.fastq   zm_cp.bam   
samtools fastq   -f 5   -1 unmapped_t1.fastq  -2 unmapped_t2.fastq  zm_cp.bam

cat   unmapped_1.fastq   unmapped_t1.fastq   >   tmp1.fastq         
cat   unmapped_t2.fastq   unmapped_2.fastq   >   tmp2.fastq          
cat   paired_1.fastq   tmp1.fastq   >   chloroplast_reads_1.fastq            
cat   paired_2.fastq   tmp2.fastq   >   chloroplast_reads_2.fastq

I wanted to be sure if this workflow is appropiate. I'll be very happy to read some advice :)

Thanks a lot in advance!

assembly alignment next-gen

0 answers

No answers yet.

Log in to answer this question.