bio-alignment-filtering
Filter alignments by flags, mapping quality, and regions using samtools view and pysam. Use when extracting specific reads, removing low-quality alignments, or subsetting to target regions.
npx skills add BioTender-max/awesome-bio-agent-skills --skill alignment-filtering --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
## Version Compatibility Reference examples tested with: pysam 0.22+, samtools 1.19+ Before using code patterns, verify installed versions match. If versions differ: - Python: `pip show <package>` then `help(module.function)` to check signatures - CLI: `<tool> --version` then `<tool> --help` to confirm flags If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying. # Alignment Filtering **"Filter my BAM file to keep only high-quality reads"** → Select reads by FLAG bits, mapping quality, and genomic regions using samtools view or pysam. - CLI: `samtools view` with `-F`/`-f`/`-q`/`-L` flags (samtools) - Python: `pysam.AlignmentFile` iteration with attribute filters (pysam) Filter alignments by flags, quality, and regions using samtools and pysam. ## Filter Flags | Option | Description | |--------|-------------| | `-f FLAG` | Include reads with ALL bits set | | `-F FLAG` | Exclude reads with ANY bits set | | `-G FLAG` | Exclude reads with ALL bits set | | `-q MAPQ` | Minimum mapping quality | | `-L BED` | Include reads overlapping regions | ## Common FLAG Values | Flag | Hex | Meaning
- Version Compatibility
- Filter Flags
- Common FLAG Values
- Filter by FLAG
- Keep Only Mapped Reads
- Keep Only Unmapped Reads
- Keep Only Properly Paired
- Remove Duplicates
- Remove Secondary and Supplementary
- Keep Only Primary Alignments
- Keep Read1 Only
- Keep Read2 Only
- Forward Strand Only
- Reverse Strand Only
samtools view -F 4 -o mapped.bam input.bam samtools view -f 4 -o unmapped.bam input.bam samtools view -f 2 -o proper.bam input.bam samtools view -F 1024 -o nodup.bam input.bam samtools view -F 2304 -o primary.bam input.bam samtools view -F 256 -F 2048 -o primary.bam input.bam Or combined: -F 2304 samtools view -f 64 -o read1.bam input.bam samtools view -f 128 -o read2.bam input.bam samtools view -F 16 -o forward.bam input.bam
What does the bio-alignment-filtering skill do?
Filter alignments by flags, mapping quality, and regions using samtools view and pysam. Use when extracting specific reads, removing low-quality alignments, or subsetting to target regions.
How do I install it?
Run `npx skills add BioTender-max/awesome-bio-agent-skills --skill alignment-filtering --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From BioTender-max/awesome-bio-agent-skills, a repository with 135 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
