Extract Fastq file from BAM File by reference name using samtools.
1
0
Entering edit mode
9.0 years ago
clear.choi ▴ 30

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!

bam sam samtools • 4.2k views
ADD COMMENT
3
Entering edit mode
9.0 years ago

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 COMMENT
1
Entering edit mode

( 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 REPLY
0
Entering edit mode

Thank you :)

ADD REPLY

Login before adding your answer.

Traffic: 1303 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6