> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/clara/parabricks/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/clara/parabricks/_mcp/server.

# bam2fq

Run bam2fq to convert BAM/CRAM to FASTQ.

This tool un-aligns a BAM file, reversing it from BAM to FASTQ format. This can
be useful if the BAM needs to be re-aligned to a newer or different reference
genome by applying bam2fq followed by [fq2bam (BWA-MEM + GATK)](/tool-reference/tools/fq-2-bam-bwa-mem-gatk) with the new reference
genome.

For paired reads, bam2fq will append "/1" to the 1st read name, and "/2" to the 2nd read name.

Refer to the [bam2fq Reference](#options) section for a detailed listing of all available options.

## Quick Start

```sh
# This command assumes all the inputs are in the current working directory and all the outputs go to the same place.
docker run --rm --gpus all --volume $(pwd):/workdir --volume $(pwd):/outputdir \
    --workdir /workdir \
    nvcr.io/nvidia/clara/clara-parabricks:4.7.1-1 \
    pbrun bam2fq \
    --ref /workdir/${REFERENCE_FILE} \
    --in-bam /workdir/${INPUT_BAM} \
    --out-prefix /workdir/${Prefix_for_output_fastq_files}
```

## Compatible CPU-based BWA-MEM, GATK4 Commands

The command below is the bwa-0.7.15 and GATK4 counterpart of the Parabricks command
above. The output from these commands will be identical to the output
from the above command.  Refer to the [Output Comparison](/about-parabricks/comparison-with-baseline-tools) page for
comparing the results.

```sh
$ gatk SamToFastq \
    -I <INPUT_DIR>/${INPUT_BAM} \
    -F <OUTPUT_DIR>/${OUTPUT_FASTQ_1} \
    -F2 <OUTPUT_DIR>/${OUTPUT_FASTQ_2}
```

## Options