Pipe BBMap reformat output into SAMtools
1
0
Entering edit mode
6.8 years ago
bruce.moran ▴ 960

Hi all,

I am wondering if I can pipe output from reformat.sh in BBMap into SAMtools view. My goal is to take a set of fastq and return an unaligned BAM headed with sequence dictionary (this is for use in GATK4). Using some GATK test data this part works (of course!):

bbduk.sh in1=6484_snippet_1.fastq in2=6484_snippet_2.fastq trimq=30 out=stdout.fq | reformat.sh in=stdin.fq out=stdout.bam

I suppose the question then is: can I force reformat.sh to produce a BAM without specifying ".bam" ending? Or, what form does 'stdout.bam' take and how can SAMtools recognise it? Or, can reformat.sh do the reheader itself?

All help much appreciated,

Bruce.

bbmap samtools pipe • 2.9k views
ADD COMMENT
1
Entering edit mode
ADD REPLY
0
Entering edit mode

OK, I had read that, just tried a few things and it seems you have to stream through samtools view:

reformat.sh in=6484_snippet_1.fastq out=stdout.bam | samtools reheader 6484_snippet_header.sam - > 6484_snippet.rh.bam

returns [W::hts_close] EOF marker is absent. The input is probably truncated.

reformat.sh in=6484_snippet_1.fastq out=stdout.bam | samtools view -hb - | reheader 6484_snippet_header.sam - > 6484_snippet.rh.bam

returns a reheaded BAM! Thanks for the response and making me think a bit more.

ADD REPLY
3
Entering edit mode
6.8 years ago
bruce.moran ▴ 960

To answer my own Q:

bbduk.sh in1=6484_snippet_1.fastq \
          in2=6484_snippet_2.fastq \
          trimq=30 out=stdout.fq \
| reformat.sh in=stdin.fq \
               out=stdout.bam \
| samtools view -hb - | samtools reheader 6484_snippet_header.sam - > 6484_snippet.rh.bam
ADD COMMENT
1
Entering edit mode

Incidentally, you can skip the reformat step - bbduk.sh will allow "out=stdout.bam" also :)

ADD REPLY
0
Entering edit mode

Cool, I had to use addslash and underscore hence the reformat.sh, but good to know.

ADD REPLY
0
Entering edit mode

Ah, I see. Well, alternately, reformat.sh supports quality-trimming, so I guess it's bbduk that was unnecessary (unless you were doing a kmer-based operation).

ADD REPLY
0
Entering edit mode

Thought about that also, but yes, using kmers.

ADD REPLY
0
Entering edit mode

You have learned everything I have to teach,

ADD REPLY
1
Entering edit mode

My RTFM is strong (also helps that there is a good FM)

ADD REPLY

Login before adding your answer.

Traffic: 2385 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