# Paired-end 16S FASTQ quality audit

Synthetic teaching example, not biological data or a validated production pipeline. Four artificial 40-base pairs; reverse reads deliberately drop from Q35 to Q20 at cycle 31. The sequences are not real 16S amplicons.

## Run

Requires Python 3, standard library only. From this directory:

```bash
python3 fastq_qc.py --demo --out demo_results
```

For a separate Phred+33 four-line FASTQ pair (plain or gzip):

```bash
python3 fastq_qc.py --r1 path/to/R1.fastq.gz --r2 path/to/R2.fastq.gz --out qc_results
```

Use a fresh output directory for each run. Outputs: summary.csv and per_cycle.csv. Demo mode also writes toy FASTQ files. Capture a console log with shell redirection if desired.

## Scope and limitations

The script validates sequence/quality lengths, allowed bases, quality-character range and normalized paired identifiers in matching record order. It does not infer quality encoding, validate unique IDs or mate orientation, trim primers, screen contaminants, calculate expected errors, denoise, merge reads or infer taxonomy. Mean Phred is not the mean error probability. Q30 percentage is the fraction of bases with Phred >=30.

## From preflight to QIIME 2

For demultiplexed sequencing data, use the appropriate manifest format (e.g. PairedEndFastqManifestPhred33V2 with confirmed Phred+33 encoding), import, summarize quality with demux summarize, then select trimming/denoising settings using read quality, actual primer handling, amplicon length and sufficient overlap. Evaluate DADA2 retention, merging and chimera removal before taxonomic classification and downstream diversity analysis. Do not transfer trimming settings between sequencing runs without checking. The artificial demo is not suitable for DADA2.

Official documentation:
- https://amplicon-docs.qiime2.org/en/latest/how-to-guides/how-to-import/
- https://amplicon-docs.qiime2.org/en/2026.4/references/plugins/demux/
- https://amplicon-docs.qiime2.org/en/2026.10/references/plugins/dada2/

## Validation

Executed in Python: four built-in demo checks; rejection of mismatched IDs, truncated record, unequal sequence/quality lengths and missing pair; gzip input accepted. Expected summary: R1 4 reads, 160 bases, mean Q35, 100% Q30; R2 4 reads, 160 bases, mean Q31.25, 75% Q30. QIIME 2 itself was not run.
