Question: Extract the mapped contig sequences from SAM/BAM file
0
gravatar for sbdk
3.4 years ago by
sbdk60
United States
sbdk60 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 • 3.0k views
ADD COMMENTlink modified 3.4 years ago by vmicrobio250 • written 3.4 years ago by sbdk60
0
gravatar for vmicrobio
3.4 years ago by
vmicrobio250
vmicrobio250 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 3.4 years ago by vmicrobio250
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: 1343 users visited in the last hour