This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Export reads from an alignment file

Hi! I have annotated some clustered genes in a very fragmented genome assembly based on Illumina reads. I want to study their synteny (impossible in the assembly I have) and I have a lot of nanopore reads as well. I had aligned the nanopore reads to the Illumina annotated-genes using BWA and I have now an alignment file. I now want to get the COMPLETE SEQUENCE of the reads aligning to my reference (so I can make a local assembly of those reads and hopefully get the synteny) and NOT ONLY THE PART OF THE READS THAT ALIGN TO THE REFERENCE. Is it possible to do that? How can I do it? Thanks a lot!

nanopore mapping bwa samtools sam

As per Pierre, you can just use samtools view -b -f 0x2 MyBAM.bam in order to extract just the reads that have aligned successfully to your genome (assuming paired-end). You can then use the cut command in combination in order to pull out information relating to read positions if you want to group them into specific loci prior to performing local assembly.

Another way to extract aligned reads over a defined genomic region is, for example:

samtools view -b -f 0x2 MyBAM.bam 5:135396277-135396306

0 answers

No answers yet.

Log in to answer this question.