SKILL.md
Version Compatibility
Reference examples tested with: BioPython 1.83+, numpy 1.26+, scipy 1.12+
Before using code patterns, verify installed versions match. If versions differ:
- Python:
pip show <package>thenhelp(module.function)to check signatures
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Ribosome Stalling Detection
"Find ribosome pause sites in my data" → Detect codon-level ribosome stalling and pausing events from Ribo-seq footprint density, identifying positions with abnormally high ribosome occupancy.
- Python:
plastidfor codon-resolution density calculation,scipyfor statistical scoring
Concept
Ribosome stalling/pausing occurs when ribosomes slow or stop at specific codons:
- Rare codons (low tRNA availability)
- Specific amino acid motifs (polyproline)
- Regulatory pause sites (upstream of stress response genes)
- Nascent chain interactions
Calculate Codon-Level Occupancy
Goal: Quantify ribosome occupancy at each codon position across all transcripts.
Approach: Map reads to P-sites using a fixed offset, then bin counts into codons along each CDS.
from plastid import BAMGenomeArray, GTF2_TranscriptAssembler, FivePrimeMapFactory
import numpy as np
from collections import defaultdict
def get_codon_occupancy(bam_path, gtf_path, psite_offset=12):
'''Calculate ribosome occupancy per codon'''
# Load reads with P-site mapping
alignments = BAMGenomeArray(
bam_path,
mapping=FivePrimeMapFactory(offset=psite_offset)
)
transcripts = list(GTF2_TranscriptAssembler(gtf_path))
codon_counts = defaultdict(lambda: defaultdict(int))
for tx in transcripts:
if tx.cds_start is None:
continue
cds = tx.get_cds()
cds_seq = tx.get_sequence(cds)
# Get counts at each position
counts = alignments.count_in_region(cds)
# Assign to codons
for i in range(0, len(cds_seq) - 2, 3):
codon = cds_seq[i:i+3]
codon_pos = i // 3
codon_counts[tx.get_name()][codon_pos] = counts # Simplified
return codon_counts
