一键导入
read-write-sequences
Read and write FASTA, FASTQ, GenBank, EMBL using Biopython SeqIO — including indexed random access, conversion, and 2026 best practices.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Read and write FASTA, FASTQ, GenBank, EMBL using Biopython SeqIO — including indexed random access, conversion, and 2026 best practices.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | read-write-sequences |
| description | Read and write FASTA, FASTQ, GenBank, EMBL using Biopython SeqIO — including indexed random access, conversion, and 2026 best practices. |
| license | MIT |
pysam (see ors-bioinformatics-sequence-pysam-genomics).pysam.AlignmentFile.pyfastx (faster than Biopython for FASTA).biopython>=1.83index() on .bgz.| Format | String | Notes |
|--------|--------|-------|"
| FASTA | "fasta" | Sequence only, single-line or wrapped |
| FASTQ (Sanger / Illumina 1.8+) | "fastq" | Phred+33 |
| FASTQ (Illumina 1.3-1.7) | "fastq-illumina" | Phred+64 |
| FASTQ (Solexa) | "fastq-solexa" | Solexa+64 |
| GenBank | "genbank" | Annotation + sequence |
| EMBL | "embl" | EBI submission format |
| SwissProt | "swiss" | UniProt curated |
| UniProt XML | "uniprot-xml" | EBI download |
| GFF3 | "gff3" | Genome features, not sequence records |
| GTF | "gtf" | Gene transfer format |
| ABI | "abi" | Sanger trace |
| Phylip | "phylip" | Alignment |
| Clustal | "clustal" | Alignment |
| Stockholm | "stockholm" | Pfam/Rfam |
| Tab-delimited | "tab" | ID, seq, optional qualifiers |
from Bio import SeqIO
for rec in SeqIO.parse("input.fasta", "fasta"):
# rec.id, rec.description, rec.seq
...
records = list(SeqIO.parse("small.fasta", "fasta"))
from Bio import SeqIO
db = SeqIO.index("large.fasta", "fasta")
seq = db["target_id"].seq
db.close()
For persistent index (no rebuild on next open):
db = SeqIO.index_db("large.idx", "large.fasta", "fasta")
db = SeqIO.index("indexable.fasta.bgz", "fasta")
from Bio import SeqIO
SeqIO.write(records, "out.fasta", "fasta")
The return value is the number of records written.
from Bio import SeqIO
from Bio.SeqRecord import SeqRecord
from Bio.Seq import Seq
with open("out.fasta", "w") as fh:
rec = SeqRecord(Seq("ACGT"), id="seq1", description="example")
SeqIO.write(rec, fh, "fasta")
from Bio import SeqIO
def stream_to_fasta(in_path, in_fmt, out_path):
with open(out_path, "w") as out:
for rec in SeqIO.parse(in_path, in_fmt):
# modify rec if needed
SeqIO.write(rec, out, "fasta")
from Bio import SeqIO
n = SeqIO.convert("in.gb", "genbank", "out.fasta", "fasta")
print(f"Converted {n} records")
Biopython auto-handles wrapped FASTA in parse(); record.seq is always the full sequence.
from Bio import SeqIO
for rec in SeqIO.parse("annotation.gb", "genbank"):
for feat in rec.features:
if feat.type == "CDS":
gene = feat.qualifiers.get("gene", ["?"])[0]
print(gene, feat.location)
from Bio import SeqIO
for qresult in SeqIO.parse("blast.tab", "blast-tab"):
for hsp in qresult:
...
blast-tab parses the tabular -outfmt 6.
def short_id(rec):
rec.id = rec.id.split()[0]
rec.description = ""
return rec
close()..fasta.gz (plain gzip) fails. Convert to BGZF first."fastq-illumina" and wrote with "fastq", Biopython re-encodes qualities. Usually fine, but worth being explicit.SeqIO.convert. Returns 0 silently if source format is wrong. assert n > 0.description. If you write a record with both id="seq1 chr1" and a description, downstream tools will see seq1 as the ID.n_records_in == n_records_out for round-trips.db["known_id"].seq == expected_seq.len(features_in) == len(features_out), modulo per-format feature filtering.| Need | Tool |
|---|---|
| Faster FASTA parsing | pyfastx |
| Format conversion at scale | seqkit convert, bioawk |
| Random access to huge FASTA | samtools faidx + bgzip |
| GFF/GTF parsing | gffutils, pyranges |
ors-bioinformatics-sequence-format-conversion, ors-bioinformatics-sequence-compressed-sequence-files.bio-read-sequences and bio-write-sequences (bioSkills-main/sequence-io/).Other skills in this category:
Pass work between ORS skills with a Material Passport — a structured JSON envelope that captures inputs, outputs, decisions, and provenance so a downstream skill can resume without re-deriving context. Use when one skill produces output that another skill must consume, especially across category boundaries (e.g. analysis → writing, sequencing → statistics).
Discover and maintain `## Cross-references` between ORS skills. Given a new or edited skill, suggest related skills (same category, shared tags, complementary workflows). Verify all xref slugs resolve to existing SKILL.md files. Use when adding a new skill, when sibling skills move, or when an audit reveals dangling xrefs.
7-mode AI failure-mode checklist applied before publishing any ORS artifact (skill, manuscript section, dataset card, agent output). Catches: fabricated citations, silent failures, scope creep, missing provenance, unsupervised writes, version drift, hallucinated APIs. Use as the final pass before any 'publish', 'release', 'merge', or 'finalize' action.
Version, changelog, and marketplace workflow for ORS skills. Semver discipline, breaking-change protocol, marketplace.json update, README refresh, and the v0.X.Y → v1.0.0 graduation criteria. Use when bumping a skill version, publishing a release, or upgrading the ORS package version.
Author a new ORS skill from scratch using the v0.4.0 schema. Produces a valid SKILL.md (frontmatter + metadata + sections) following spec/skill-format.md, guided by spec/author-guide.md, validated by scripts/validate-skills.py. Use when a user says 'add a new skill', 'create a skill for X', or 'I want to contribute a skill'.
Process many FASTA/FASTQ/GenBank files in batch — merge, split, convert, summarize, organize — using Biopython 1.83+.