Question: Extract Fastq file from BAM File by reference name using samtools.
0
gravatar for clear.choi
3.5 years ago by
clear.choi30
United States
clear.choi30 wrote:

Hello,

 

I am trying to understand how to use samtools, and there is a little bit confusion.

I have one .BAM file which is 96 index is existed.

I can extract that specific index like below

samtool view -r B3 -b -o out.bam in.bam

[ Ref : Extract Bamfile using samtools ]

But I wonder if I want to use also Reference Name (fg, Reference name : A_01_01) 

And Flag which is contain 0 or 16 . ( 0 mean Forward sequence and 16 mean Reverse sequence )

If I want to extract reference "A_01_01" and Flag 0 . 

What is exactly command line I can use?

After that I can extract to fastq file using below command.

samtools bam2fq output.bam > output.fastq

Thank you!

 

 

sam samtools bam • 1.6k views
ADD COMMENTlink modified 3.5 years ago by Matt Shirley9.0k • written 3.5 years ago by clear.choi30
3
gravatar for Matt Shirley
3.5 years ago by
Matt Shirley9.0k
Cambridge, MA
Matt Shirley9.0k wrote:

It might help if you clarify your question, but I think you want:

samtools view -f 0 -r B3 -b -o out.bam in.bam A_01_01
ADD COMMENTlink written 3.5 years ago by Matt Shirley9.0k
1

"( 0 mean Forward sequence and 16 mean Reverse sequence )"

I really like samtools, but the flag notation is just so confusing to most people. "-f 0" will not work at all!! You want "-F 16"

ADD REPLYlink modified 3.5 years ago • written 3.5 years ago by John12k

Thank you :)

ADD REPLYlink written 3.5 years ago by clear.choi30
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: 1582 users visited in the last hour