scientific-skills/Data Analysis/biopython-sequence-io/SKILL.md
Use Biopython to read/write/convert biological sequence files (FASTA/GenBank/FASTQ, etc.) and perform basic sequence operations; use when you need reliable sequence I/O, lightweight sequence manipulation, or scalable processing of large sequence datasets.
npx skillsauth add aipoch/medical-research-skills biopython-sequence-ioInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
4 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Bio.Seq.Seq (slicing, reverse complement, transcription/translation).Bio.SeqIO for parsing and writing FASTA/GenBank/FASTQ and other supported formats.SeqIO.index) for large files.biopython>=1.80numpy>=1.21Create config/task_config.json:
{
"input_path": "data/input.fasta",
"input_format": "fasta",
"output_path": "data/output.gb",
"output_format": "genbank",
"min_length": 200,
"max_ambiguous": 0,
"index_db_path": "data/index.sqlite"
}
Run:
python scripts/sequence_io.py
scripts/sequence_io.py (runnable end-to-end):
import json
from pathlib import Path
import numpy as np
from Bio import SeqIO
def gc_fraction(seq: str) -> float:
s = seq.upper()
if not s:
return 0.0
return float((s.count("G") + s.count("C")) / len(s))
def ambiguous_count(seq: str) -> int:
# Treat anything outside A/C/G/T/U as ambiguous for simple filtering.
allowed = set("ACGTU")
return sum(1 for ch in seq.upper() if ch not in allowed)
def main() -> None:
config_path = Path("config/task_config.json")
with config_path.open("r", encoding="utf-8") as f:
cfg = json.load(f)
input_path = Path(cfg["input_path"])
input_format = cfg["input_format"]
output_path = Path(cfg["output_path"])
output_format = cfg["output_format"]
min_length = int(cfg.get("min_length", 0))
max_ambiguous = int(cfg.get("max_ambiguous", 10**9))
output_path.parent.mkdir(parents=True, exist_ok=True)
kept = 0
lengths = []
# Stream records to avoid loading the entire file into memory.
with output_path.open("w", encoding="utf-8") as out_handle:
for record in SeqIO.parse(str(input_path), input_format):
seq_str = str(record.seq)
if len(seq_str) < min_length:
continue
if ambiguous_count(seq_str) > max_ambiguous:
continue
# Example: attach simple stats as annotations (useful for GenBank output).
record.annotations["gc_fraction"] = gc_fraction(seq_str)
SeqIO.write(record, out_handle, output_format)
kept += 1
lengths.append(len(seq_str))
summary = {
"input_path": str(input_path),
"output_path": str(output_path),
"kept_records": kept,
"length_min": int(np.min(lengths)) if lengths else 0,
"length_max": int(np.max(lengths)) if lengths else 0,
"length_mean": float(np.mean(lengths)) if lengths else 0.0,
}
Path("config").mkdir(parents=True, exist_ok=True)
with Path("config/summary.json").open("w", encoding="utf-8") as f:
json.dump(summary, f, ensure_ascii=False, indent=2)
if __name__ == "__main__":
main()
Configuration convention
config/task_config.json as an intermediate artifact.python scripts/<task_name>.py.-- parameters; prefer config files for reproducibility.encoding="utf-8". JSON output must use ensure_ascii=False.Parsing and writing
SeqIO.parse(path, format) for streaming iteration over records.SeqIO.write(records_or_record, handle, format) to serialize records.Large-file strategies
SeqIO.index(input_path, format) (creates an on-disk index depending on backend); this avoids loading all sequences into memory.Filtering/statistics
min_length, maximum ambiguous characters, and quality-based criteria for FASTQ.(count(G)+count(C))/length on an uppercased sequence string; handle empty sequences safely.Reference
references/sequence_io.md for additional notes and format-specific behaviors.biopython_sequence_io_result.md unless the skill documentation defines a better convention.Run this minimal verification path before full execution when possible:
No local script validation step is required for this skill.
Expected output format:
Result file: biopython_sequence_io_result.md
Validation summary: PASS/FAIL with brief notes
Assumptions: explicit list if any
tools
Generates complete conventional oncology bulk-transcriptome biomarker and hub-gene research designs from a user-provided cancer type and study direction. Always use this skill whenever a user wants to design, plan, or build a tumor bioinformatics study centered on differential expression, prognostic filtering or risk modeling, PPI-based hub-gene prioritization, diagnostic/prognostic evaluation, clinical association, immune infiltration context, methylation context, and optional tissue or cell validation. Covers five study patterns (signature-first prognostic workflow, hub-gene-first biomarker workflow, hybrid signature-to-hub workflow, immune-context biomarker workflow, translational validation workflow) and always outputs four workload configs (Lite / Standard / Advanced / Publication+) with recommended primary plan, step-by-step workflow, figure plan, validation strategy, minimal executable version, publication upgrade path...
development
Generates complete conventional non-oncology bioinformatics research designs from a user-provided disease context, process-related gene family or biological theme, and validation direction. Use when a study centers on multi-dataset bulk transcriptome integration, DEG analysis, process-gene intersection, enrichment analysis, GSEA, PPI hub-gene prioritization, TF/miRNA regulatory networks, ROC-based biomarker evaluation, and immune infiltration analysis. Covers five study patterns (process-DEG discovery, enrichment/GSEA interpretation, hub-gene prioritization, regulatory-network and immune interpretation, multi-layer public validation) and always outputs Lite / Standard / Advanced / Publication+ with a recommended primary plan, stepwise workflow, figure plan, validation hierarchy, minimal executable version, publication upgrade path, and strictly verified literature retrieval.
tools
Plans confounder control, variable adjustment logic, and bias mitigation strategies at the protocol stage for clinical, epidemiologic, translational, observational, and biomarker studies. Always use this skill when a user needs to identify major confounders, decide which variables should or should not be adjusted for, compare matching/stratification/weighting approaches, anticipate selection or measurement bias, or pressure-test a study design before execution. Focus on bias sensing, causal structure awareness, variable-role classification, and critical design review rather than generic statistical advice.
testing
Generates complete comparative network-toxicology research designs from a user-provided exposure pair, shared toxic phenotype, and validation direction. Use when a study centers on two related exposures under one outcome and needs target collection, shared-vs-specific target decomposition, enrichment, PPI hub prioritization, docking, optional transcriptomic cross-checks, and conservative mechanistic synthesis. Covers five study patterns and always outputs Lite / Standard / Advanced / Publication+ with a recommended primary plan, stepwise workflow, figure plan, validation hierarchy, minimal executable version, publication upgrade path, and strictly verified literature retrieval.