bio-sam-bam-basics
View, convert, and understand SAM/BAM/CRAM alignment files using samtools and pysam. Use when inspecting alignments, converting between formats, or understanding alignment file structure.
npx skills add BioTender-max/awesome-bio-agent-skills --skill sam-bam-basics --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. # SAM/BAM/CRAM Basics **"Read a BAM file"** → Open a binary alignment file and iterate over aligned reads with their mapping coordinates, flags, and quality scores. - Python: `pysam.AlignmentFile()` (pysam) - CLI: `samtools view` (samtools) - R: `scanBam()` (Rsamtools) View and convert alignment files using samtools and pysam. ## Format Overview | Format | Description | Use Case | |--------|-------------|----------| | SAM | Text format, human-readable | Debugging, small files | | BAM | Binary compressed SAM | Standard storage format | | CRAM | Reference-based compression | Long-term archival, smaller than BAM | ## SAM Format Structure ``` @HD VN:1.6 SO:coordinate @SQ SN:chr1 LN:248956422 @RG ID:sample1 SM:sample1 @PG ID:b
- Version Compatibility
- Format Overview
- SAM Format Structure
- samtools view
- View BAM as SAM
- View with Header
- View Header Only
- View Specific Region
- Count Alignments
- Format Conversion
- BAM to SAM
- SAM to BAM
- BAM to CRAM
- CRAM to BAM
samtools view input.bam | head samtools view -h input.bam | head -100 samtools view -H input.bam samtools view input.bam chr1:1000-2000 samtools view -c input.bam samtools view -h -o output.sam input.bam samtools view -b -o output.bam input.sam samtools view -C -T reference.fa -o output.cram input.bam samtools view -b -T reference.fa -o output.bam input.cram samtools view -b input.sam > output.bam
What does the bio-sam-bam-basics skill do?
View, convert, and understand SAM/BAM/CRAM alignment files using samtools and pysam. Use when inspecting alignments, converting between formats, or understanding alignment file structure.
How do I install it?
Run `npx skills add BioTender-max/awesome-bio-agent-skills --skill sam-bam-basics --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.
