bam2fastq.py - output fastq files from a bam-file

Tags

Genomics NGS Sequences BAM FASTQ Conversion

Purpose

This script takes a bam formatted file and converts to it to one or two fastq formatted files for single-end or paired-end data, respectively.

For paired-end data, the first fastq file contains the first read of a read pair and the other contains the second read of read pair.

Example

For example:

cat in.bam cgat bam2fastq out.1.fastq.gz out.2.fastq.gz

This command converts the bam formatted file in.bam into fastq files containing forward reads (out.1.fastq.gz) and reverse reads (out.2.fastq.gz). The output files can alternatively supplied via the option --output-pattern-filename. The statement below will create the same two output files:

cat in.bam cgat bam2fastq --output-filename-pattern=out.%s.fastq.gz

Type:

python bam2fastq.py --help

for command line help.

Command line options

usage: bam2fastq [-h] [--version] [--timeit TIMEIT_FILE]
                 [--timeit-name TIMEIT_NAME] [--timeit-header]
                 [--random-seed RANDOM_SEED] [-v LOGLEVEL]
                 [--log-config-filename LOG_CONFIG_FILENAME]
                 [--tracing {function}] [-? ?] [-P OUTPUT_FILENAME_PATTERN]
                 [-F] [-I STDIN] [-L STDLOG] [-E STDERR] [-S STDOUT]
bam2fastq: error: argument -?: expected one argument