Bedtools bamtofastq error
1
0
Entering edit mode
8.8 years ago
quachtina96 ▴ 40

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!

fastq bam bamtofastq bedtools • 8.2k views
ADD COMMENT
0
Entering edit mode
8.8 years ago

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

ADD COMMENT
0
Entering edit mode

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

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

ADD REPLY
0
Entering edit mode

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

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

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 REPLY

Login before adding your answer.

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