What does the -0 flag of samtools fastq mean?
1
0
Entering edit mode
3.1 years ago
O.rka ▴ 710

-0 Write reads where the READ1 and READ2 FLAG bits set are either both set or both unset to FILE instead of outputting them.

http://www.htslib.org/doc/samtools-fasta.html

I just don't understand what it's saying. It looks like my output is the same regardless.

I'm trying to pipe the mapped reads from bwa mem to samtools fastq getting only the mapped reads and then repairing the reads using bbmap's repair.sh

   input_filepaths = [reference_index, reads_1.fastq, reads_2.fastq]
   output_filepaths = [mapped_1.fastq, mapped_2.fastq]
    cmd = [
    "(",
    os.environ["bwa"],
    "mem",
    "-t {}".format(opts.n_jobs),
    opts.bwa_options, 
    input_filepaths[0],
    input_filepaths[1],
    input_filepaths[2],
    "|",
    # os.environ["reformat.sh"],
    # "in=stdin.sam",
    # "fastawrap=1000",
    # "mappedonly=t",
    # "overwrite=t",
    # # "ref={}".format(input_filepaths[0]),
    # "out1={}".format(output_filepaths[0]),
    # "out2={}".format(output_filepaths[1]),

    "|",
    os.environ["samtools"],
    "fastq",
    "-F 4",
    "--threads {}".format(opts.n_jobs),
    "-0 /dev/null",
    "-s /dev/null",
    "-N -",
    "|",
    os.environ["repair.sh"],
    "in=stdin.fastq",
    "out1={}".format(output_filepaths[0]),
    "out2={}".format(output_filepaths[1]),
    "fastawrap=1000",
    "interleaved=t",
    "overwrite=t",
    ")",
    ]
samtools • 997 views
ADD COMMENT
0
Entering edit mode
3.1 years ago
aw7 ▴ 270

It is filtering out any read that is not recognised as one of a pair.

From the SAM spec:

Bits 0x40 and 0x80 reflect the read ordering within each template inherent in the sequencing technology used. If 0x40 and 0x80 are both set, the read is part of a linear template, but it is neither the first nor the last read. If both 0x40 and 0x80 are unset, the index of the read in the template is unknown. This may happen for a non-linear template or when this information is lost during data processing.

Bit 0x40 is the READ1 flag and bit 0x80 is READ2.

If your alignment is well behaved it is quite possible that you have no reads that are not either READ1 or READ2.

ADD COMMENT

Login before adding your answer.

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