Metadata-Version: 2.4
Name: fastqp
Version: 0.3.6
Summary: Simple NGS read quality assessment using Python
Home-page: https://github.com/mdshw5/fastqp
Author: Matthew Shirley
Author-email: mdshw5@gmail.com
License: MIT
Project-URL: Source, https://github.com/mdshw5/fastqp
Project-URL: Tracker, https://github.com/mdshw5/fastqp/issues
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Environment :: Console
Classifier: Intended Audience :: Science/Research
Classifier: Natural Language :: English
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: six
Requires-Dist: matplotlib>=3.5.3
Requires-Dist: numpy>=1.23.5
Requires-Dist: simplesam>=0.1.4.2
Requires-Dist: scipy>=1.9.3
Requires-Dist: cycler
Provides-Extra: duplicates
Requires-Dist: pybloom-live>=4; extra == "duplicates"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

fastqp
======
[![CI](https://github.com/mdshw5/fastqp/actions/workflows/ci.yml/badge.svg)](https://github.com/mdshw5/fastqp/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/fastqp.svg?)](https://pypi.python.org/pypi/fastqp)

Simple FASTQ, SAM and BAM read quality assessment and plotting using Python.

Features
--------

- Requires only Python with Numpy, Scipy, and Matplotlib libraries
- Works with (gzipped) FASTQ, SAM, and BAM formatted reads
- Tabular, tidy, output statistics so you can create your own graphs
- A useful set of default graphics rivaling comparable QC packages
- Counts *all* IUPAC ambiguous nucleotide codes (NMWSKRYVHDB) if present in sequences
- Downsamples input files to around 2,000,000 reads (user adjustable)
- Allows a 5′ and 3′ (left and right) cycle limit for statistics and graphics
- Tracks kmers for the entire input file and reports over-represented kmers
- Optional sequence duplication rate over the entire input file (Bloom filters)
- Plots base call reference mismatches for aligned reads
- Optionally ignores reads flagged as vendor QC-fail in SAM/BAM input

Requirements
------------

- Python 3.10 or newer
- numpy 1.23.5+, scipy 1.9.3+, matplotlib 3.5.3+, cycler, six,
  simplesam 0.1.4.2+
- BAM file support requires [samtools](https://github.com/samtools/samtools)

Installation
------------

    pip install [--user] fastqp

The optional sequence duplication calculation (`-d/--count-duplicates`) needs
the `pybloom-live` package:

    pip install [--user] 'fastqp[duplicates]'

Usage
-----

```
usage: fastqp [-h] [-q] [-a NAME] [-p BASE_PROBS] [-k {2,3,4,5,6,7}]
              [-o OUTPUT] [-e TEXT] [-t {fastq,gz,sam,bam}] [-ll LEFTLIMIT]
              [-rl RIGHTLIMIT] [-mq MEDIAN_QUAL] [-s BINSIZE | -n NREADS | -d]
              [--aligned-only | --unaligned-only] [--ignore-qcfail]
              input

simple NGS read quality assessment using Python

positional arguments:
  input                 input file (one of .sam, .bam, .fq, or .fastq(.gz) or
                        stdin (-))

options:
  -h, --help            show this help message and exit
  -q, --quiet           do not print any messages (default: False)
  -a NAME, --name NAME  sample name identifier for text and graphics output
                        (default: input file name)
  -p BASE_PROBS, --base-probs BASE_PROBS
                        probabilities for observing A,T,C,G,N in reads
                        (default: 0.25,0.25,0.25,0.25,0.1)
  -k {2,3,4,5,6,7}, --kmer {2,3,4,5,6,7}
                        length of kmer for over-represented kmer counts
                        (default: 5)
  -o OUTPUT, --output OUTPUT
                        base name for the output ZIP of figures (default:
                        fastqp_figures)
  -e TEXT, --text TEXT  file name for tidy text output, or - for stdout
                        (default: -)
  -t {fastq,gz,sam,bam}, --type {fastq,gz,sam,bam}
                        file type (default: auto)
  -ll LEFTLIMIT, --leftlimit LEFTLIMIT
                        leftmost cycle limit (default: 1)
  -rl RIGHTLIMIT, --rightlimit RIGHTLIMIT
                        rightmost cycle limit (-1 for none) (default: -1)
  -mq MEDIAN_QUAL, --median-qual MEDIAN_QUAL
                        median quality threshold for failing QC (default: 30)
  -s BINSIZE, --binsize BINSIZE
                        number of reads to bin for sampling (default: auto)
  -n NREADS, --nreads NREADS
                        number of reads sample from input (default: 2000000)
  -d, --count-duplicates
                        calculate sequence duplication rate; disables sampling
                        and scans the whole file (default: False)
  --aligned-only        only aligned reads (default: False)
  --unaligned-only      only unaligned reads (default: False)
  --ignore-qcfail       skip reads flagged as vendor QC fail (SAM/BAM FLAG
                        0x200; no effect on FASTQ) (default: False)
```

Output
------

`fastqp` writes two kinds of output:

* **Figures**: a ZIP archive named `<--output>.zip` (default
  `fastqp_figures.zip`) containing PNG files such as
  `quality_score_quantiles.png`, `quality_score_distribution.png`,
  `quality_score_heatmap.png`, `read_length_distribution.png`,
  `cycle_specific_gc.png`, `gc_distribution.png`,
  `cycle_specific_base_composition.png`, `cycle_specific_kmers.png` and
  `cycle_specific_potiential_adapter_kmers.png`. SAM/BAM input also produces
  `cycle_specific_base_mismatches.png`.
* **Tidy statistics**: a headerless, tab-separated, four-column table written
  to `--text` (default: standard output; use `-e FILE` for a file):

  | sample | observation | cycle | value |
  |--------|-------------|-------|-------|
  | sample name | `reads`, `read_len`, `q05`–`q95`, `A`/`C`/`G`/`T`/..., `pos_gc`, `read_gc`, kmer, `duplicate` | cycle number or `None` | numeric value |

  Rows from multiple runs can be concatenated (the sample name is the first
  column), which makes it easy to load them into R, Spotfire or similar tools:

  ```r
  stats <- read.delim("fastqp_stats.tsv", header = FALSE,
                      col.names = c("sample", "observation", "cycle", "value"))
  ```

`-d/--count-duplicates` scans the entire input file (sampling is disabled) and
requires the `duplicates` extra described above. Note that the
`--aligned-only`, `--unaligned-only` and `--ignore-qcfail` filters only apply
to SAM/BAM input, which carries alignment and QC flags; they are ignored for
FASTQ. For SAM/BAM input, per-cycle base, quality and kmer statistics are
reported in the original read orientation (reverse-strand reads are
reverse-complemented), while the mismatch plot compares reads against the
reference orientation.

Changes
-------

See [releases page](https://github.com/mdshw5/fastqp/releases) for details.

Examples
--------

![quality heatmap](https://raw.github.com/mdshw5/fastqp/master/examples/example_qualmap.png)

![gc plot](https://raw.github.com/mdshw5/fastqp/master/examples/example_gc.png)

![gc distribution](https://raw.github.com/mdshw5/fastqp/master/examples/example_gcdist.png)

![nucleotide plot](https://raw.github.com/mdshw5/fastqp/master/examples/example_nucs.png)

![nucleotide mismatch plot](https://raw.github.com/mdshw5/fastqp/master/examples/example_mismatch.png)

![kmer distribution](https://raw.github.com/mdshw5/fastqp/master/examples/example_kmers.png)

![depth plot](https://raw.github.com/mdshw5/fastqp/master/examples/example_depth.png)

![quality percentiles](https://raw.github.com/mdshw5/fastqp/master/examples/example_quals.png)

![quality distribution](https://raw.github.com/mdshw5/fastqp/master/examples/example_qualdist.png)

![adapter kmer distribution](https://raw.github.com/mdshw5/fastqp/master/examples/example_adapters.png)


Acknowledgements
----------------
This project is freely licensed by the author, [Matthew Shirley](http://mattshirley.com), and
was completed under the mentorship financial support of Drs. [Sarah Wheelan](http://sjwheelan.som.jhmi.edu)
and [Vasan Yegnasubramanian](http://yegnalab.onc.jhmi.edu) at the Sidney Kimmel Comprehensive
Cancer Center in the Department of Oncology.
