Question: Bedtools bamtofastq error
0
gravatar for quachtina96
3.6 years ago by
quachtina9620
United States
quachtina9620 wrote:

Hi,

I am trying to convert my bam file into two fastq files in the command line, but I run into an error and I'm not sure what to change/do differently. Thoughts/advice?

my line:

bedtools bamtofastq ID18_Father_exome_L001_001_mtExtract.qsort.bam -fq test1.fq -fq2 test2.fq

the error:

 

*****ERROR: Unrecognized parameter: ID18_Father_exome_L001_001_mtExtract.qsort.bam *****

*****
*****ERROR: Need -bam.
*****

Tool:    bedtools bamtofastq (aka bamToFastq)
Version: v2.17.0
Summary: Convert BAM alignments to FASTQ files.

Usage:   bamToFastq [OPTIONS] -i <BAM> -fq <FQ>

Options:
        -fq2    FASTQ for second end.  Used if BAM contains paired-end data.
                BAM should be sorted by query name is creating paired FASTQ.

        -tags   Create FASTQ based on the mate info
                in the BAM R2 and Q2 tags.

Tips:
        If you want to create a single, interleaved FASTQ file
        for paired-end data, you can just write both to /dev/stdout:

        bedtools bamtofastq -i x.bam -fq /dev/stdout -fq2 /dev/stdout > x.ilv.fq

As I was writing the question, I realized that I didn't include the -i before the bam file name, however including it resulted in the following error:

error: unrecognized command: -i

Please help! 

 

bam fastq bamtofastq bedtools • 3.9k views
ADD COMMENTlink written 3.6 years ago by quachtina9620
0
gravatar for Devon Ryan
3.6 years ago by
Devon Ryan88k
Freiburg, Germany
Devon Ryan88k wrote:

Please post the full command, I suspect you're putting -i in the wrong place.

ADD COMMENTlink written 3.6 years ago by Devon Ryan88k

Hi Devon! You were right. I put in on the left of bamToFastq instead of the right! But I have one more question:With the following command, 

bamToFastq -i mtExtract.qsort.bam -fq firsttestfile.fq -fq2 secondtestfile.fq

I got the following in the output:

*****WARNING: Query D3NJ6HQ1:424:HA49WADXX:1:1103:21194:65285 is marked as paired, but it's mate does not occur next to it in your BAM file.  Skipping.
*****WARNING: Query D3NJ6HQ1:424:HA49WADXX:1:1107:12296:11434 is marked as paired, but it's mate does not occur next to it in your BAM file.  Skipping.
*****WARNING: Query D3NJ6HQ1:424:HA49WADXX:1:1113:14106:44374 is marked as paired, but it's mate does not occur next to it in your BAM file.  Skipping.
*****WARNING: Query D3NJ6HQ1:424:HA49WADXX:1:1101:5351:15533 is marked as paired, but it's mate does not occur next to it in your BAM file.  Skipping.

 

Do you know what I could do to fix this? Or what this may mean?

 

 

ADD REPLYlink written 3.6 years ago by quachtina9620
1

Make sure to query sort the file (samtools sort -n).

ADD REPLYlink written 3.6 years ago by Devon Ryan88k

See my reply in this A: Can't convert paired end BAM to bed using bedtools for a way to stop this error and why it occurs. If you have a paired-end dataset, then bedtools wants the pairs on subsequent lines. To do this you have to sort the BAM file by read name.

ADD REPLYlink written 3.6 years ago by James Ashmore2.6k

Yes, I did sort the BAM file by read name before running the command. I am not sure if my situation is different because the bam I am working with is only the mtDNAextract bam and thus is just the chrM. The rest of the header is there from when I extracted the bam with header (came from the bam from which I extracted the chrM). The bam file I am working with is only chrM. the first portion of the header is the following:

@HD     VN:1.4  SO:queryname
@SQ     SN:chrM LN:16571
@SQ     SN:chr1 LN:249250621
@SQ     SN:chr2 LN:243199373

and so on...

 

ADD REPLYlink written 3.6 years ago by quachtina9620
1

If you have any singletons then there's nothing you can do but exclude them. In other words, do a samtools view mtExtract.qsort.bam | grep "D3NJ6HQ1:424:HA49WADXX:1:1103:21194:65285" and see if you get both mates. If not, then you might need to prefilter things. You might also just check the fastq files. If bedtools just skips over these then you have nothing to worry about.

ADD REPLYlink written 3.6 years ago by Devon Ryan88k
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: 1657 users visited in the last hour