Trim PCR primers from aligned reads in amplicon-panel BAMs.
Amplicon panels (SARS-CoV-2 ARTIC, hereditary cancer panels, ctDNA hot-spot panels, fusion panels, 16S rRNA) use designed PCR primers for enrichment. The primer footprint at read 5' ends does not represent biological sequence; without trimming, downstream variant calls suppress true variants under primers and falsely confirm reference at primer locations.
This skill covers post-alignment primer clipping with samtools ampliconclip, the required tag-repair steps (fixmate, calmd), and the relationship to duplicate marking (do not run markdup on amplicon BAMs without UMIs).
--strand mode)conda install -c bioconda samtools
# Verify ampliconclip is available
samtools ampliconclip --help
Tell your AI agent what you want to do: - "Trim ARTIC SARS-CoV-2 primers from my amplicon BAM" - "Soft-clip primers using my primer BED" - "Why is markdup marking everything as duplicate on my amplicon panel?" - "Repair the MD/NM tags after primer clipping" - "Hard-clip primers for archival storage"
"I have a SARS-CoV-2 ARTIC BAM aligned with bwa-mem. Soft-clip primers using artic_v3 primer BED, then prepare for consensus calling."
"Compare samtools ampliconclip vs iVar trim for the ARTIC SARS-CoV-2 pipeline."
"ctDNA hot-spot panel with TruSeq UMIs. Trim primers, then run UMI consensus rather than markdup."
"Hereditary cancer panel from a Roche AVENIO design. Why is my variant caller missing variants at primer-overlapping positions?"
"My amplicon BAM ran through markdup and now flagstat shows 99% duplicates. What went wrong?"
"After ampliconclip, my downstream mpileup is reporting wrong reference bases. What tag did clipping invalidate?"
samtools view -H for @PG indicating an amplicon panel kit).samtools ampliconclip --strand --soft-clip -b primers.bed (or --both-ends instead of --strand for read-through amplicons).samtools view -h clipped.bam chr1:start-end) that primer footprint has soft-clip CIGAR ops.--strand on or off: on for primer-strand-specific trimming (default for amplicon panels with single-stranded primers); off only if both strands carry primer-derived sequence.--both-ends on or off: on when reads can read through the entire amplicon and primers can appear at either 5' or 3'. Standard for short-amplicon panels (<300 bp). Note: --both-ends overrides --strand (both ends are clipped regardless of strand), so use one or the other.bcftools mpileup, IGV mismatch visualization, or any tool that reads NM/MD.samtools markdup on amplicon BAMs without UMIs -- amplicon reads share start coordinates by design and markdup will erase the dataset. See duplicate-handling for the assay-aware decision matrix.fgbio GroupReadsByUmi -> CallMolecularConsensusReads instead of markdup.samtools consensus --config hiseq --ambig (Illumina preset) for IUPAC heterozygote handling.--strand was forgotten.samtools ampliconclip works but verify CIGAR semantics with the long-read team's recommended pipeline.