---
name: "bam2fastx"
section: "1"
platform: "linux"
package: "tophat"
version: "2.1.1+dfsg1-2+b1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/bam2fastx"
---

# bam2fastx(1)

tophat component converting bam directly into fastx

## NAME

bam2fastx - tophat component converting bam directly into fastx

## DESCRIPTION

### bam2fastx v2.1.1 () usage:

-

  bam2fastx \[--fasta\|-a\] \[-C\|--color\] \[-P\|--paired\] \[-N\] \[-A\|--all\|-M\|--mapped-only\] \[-Q\] \[--sam\|-s\|-t\] \[-o \<outfname\>\] \<in.bam\>

By default, bam2fastx only converts the unmapped reads from the input file,

-

  discarding those unmapped reads flagged as QC failed. The input BAM/SAM file MUST be sorted by read name (**-n** option for samtools sort). If the input file name is "-", stdin will be used instead.

## OPTIONS

- **-A**,--all

  convert all reads (mapped and unmapped) (but discarding those flagged as QC failed, unless **-Q**)

- **-P**

  paired reads are expected and converted into two output files (see \<outfname\> comments below)

- **-Q**

  convert unmapped reads even when flagged as QC failed

- **-M**,--maped-only

  convert only mapped reads

- **-N**

  for **-P**, append  */1* and */2* suffixes to read names

- **-O**

  ignore the original quality values (OQ tag) and write the current quality values (default is to use OQ data if found)

- **-C**,--color

  reads are in ABI SOLiD color format

- **-s**,-t,--sam

  input is a SAM text file (default: BAM input expected)

- **-a**,--fasta

  output FASTA records, not FASTQ (discard quality values)

- **-o** \<outfname\>

  output file name or template (see below)

-

  \<outfname\> serves as a name template when **-P** option is provided, as suffixes .1 and .2 will be automatically inserted before the file extension in \<outfname\>, such that two file names will be created. If \<outfname\> ends in .gz or .bz2 then bam2fastx will write the output compressed by gzip or bzip2 respectively.

-

  Example of converting all paired reads from a BAM file to FASTQ format:

-

  bam2fastx **-PANQ** **-o** sample.fq.gz sample.sortedbyname.bam

-

  In this example the output will be written in two files:

-

  sample.1.fq.gz and sample.2.fq.gz
