Question: Extract the mapped contig sequences from SAM/BAM file
0
gravatar for sbdk82
2.6 years ago by
sbdk8250
United States
sbdk8250 wrote:

I have a sam/bam file that contains the mapping of long reads with assembled contigs from short reads. Because of low coverage of long reads, I have 80% of the contigs that are not mapped to s single read. I would like to extract the contigs (with nucleotide sequence) that have at least one mapped reads. How could I do it quickly using my SAM/BAM files? Also, I would like to extract the sequences of a particular contiguous and its mapped long read sequences. Any help would be appreciated.

bwa sam samtools bam • 2.3k views
ADD COMMENTlink modified 2.6 years ago by vmicrobio240 • written 2.6 years ago by sbdk8250
0
gravatar for vmicrobio
2.6 years ago by
vmicrobio240
vmicrobio240 wrote:

you may extract your mapped reads using samtools then bamtools to get a fastq and a sed to get your result in fasta format

samtools view -F4 -b in.bam > mapped-out.bam

bamtools convert -in mapped-out.bam -format fastq > mapped-out.fastq

sed -n '1~4s/^@/>/p;2~4p' mapped-out.fastq > mapped-out.fasta
ADD COMMENTlink written 2.6 years ago by vmicrobio240
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1948 users visited in the last hour