ワンクリックで
batch-processing
Process many FASTA/FASTQ/GenBank files in batch — merge, split, convert, summarize, organize — using Biopython 1.83+.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Process many FASTA/FASTQ/GenBank files in batch — merge, split, convert, summarize, organize — using Biopython 1.83+.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
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'.
Align short reads to a reference with Bowtie2 — the standard aligner for ChIP-seq, ATAC-seq, and other short-fragment applications where sensitivity for short indels matters less than speed.
| name | batch-processing |
| description | Process many FASTA/FASTQ/GenBank files in batch — merge, split, convert, summarize, organize — using Biopython 1.83+. |
| license | MIT |
nf-core/rnaseq, nf-core/sarek, or Snakemake with pysam-backed streaming.read-sequences/write-sequences skills.biopython>=1.83 (pip install biopython)polars>=1.0Path.glob() (recursive when needed) to enumerate inputs. Always sort the result — glob order is filesystem-dependent.SeqRecord objects; never build a list of millions of records in memory.SeqIO.write accepts an iterator, so the read pipeline can feed the write pipeline directly.from pathlib import Path
from Bio import SeqIO
def count_records(directory: Path, pattern: str, fmt: str):
for fp in sorted(directory.glob(pattern)):
n = sum(1 for _ in SeqIO.parse(fp, fmt))"
yield {"file": fp.name, "records": n, "format": fmt}
for row in count_records(Path("data/"), "*.fasta.gz", "fasta"):
print(row)
When the source file matters later (downstream filters, audits), tag each record:
from pathlib import Path
from Bio import SeqIO
def with_source(directory: Path, pattern: str, fmt: str):
for fp in sorted(directory.glob(pattern)):
for rec in SeqIO.parse(fp, fmt):
rec.description = f"{rec.description} [source={fp.name}]"
yield rec
n = SeqIO.write(with_source(Path("data/"), "*.fa", "fasta"),
"merged.fasta", "fasta")
print(f"Wrote {n} records")
from itertools import islice
from Bio import SeqIO
def split_by_count(in_path: str, fmt: str, n_per_file: int, prefix: str):
it = SeqIO.parse(in_path, fmt)
i = 0
while True:
batch = list(islice(it, n_per_file))
if not batch:
return
i += 1
out = f"{prefix}_{i:04d}.{fmt}"
SeqIO.write(batch, out, fmt)
print(f"{out}: {len(batch)} records")
split_by_count("huge.fasta", "fasta", 10_000, "chunk")
from collections import defaultdict
from Bio import SeqIO
groups = defaultdict(list)
for rec in SeqIO.parse("input.fasta", "fasta"):
groups[rec.id.split("|")[0]].append(rec)
for prefix, recs in groups.items():
SeqIO.write(recs, f"{prefix}.fasta", "fasta")
from pathlib import Path
for gb in sorted(Path("genbank").glob("*.gb")):
out = Path("fasta") / gb.with_suffix(".fasta").name
n = SeqIO.convert(str(gb), "genbank", str(out), "fasta")
print(f"{gb.name} -> {out.name}: {n}")
from pathlib import Path
import polars as pl
from Bio import SeqIO
from Bio.SeqUtils import gc_fraction
rows = []
for fa in sorted(Path("data/").glob("*.fasta")):
lengths = [len(r.seq) for r in SeqIO.parse(fa, "fasta")]
if not lengths:
continue
rows.append({
"file": fa.name,
"n_records": len(lengths),
"total_bp": sum(lengths),
"min_len": min(lengths),
"median_len": sorted(lengths)[len(lengths) // 2],
"max_len": max(lengths),
})
pl.DataFrame(rows).write_parquet("summary.parquet")
from pathlib import Path
from Bio import SeqIO
from Bio.SeqUtils import gc_fraction
high, low = Path("high_gc"), Path("low_gc")
high.mkdir(exist_ok=True)
low.mkdir(exist_ok=True)
for fa in Path("input").glob("*.fasta"):
recs = list(SeqIO.parse(fa, "fasta"))
avg_gc = sum(gc_fraction(r.seq) for r in recs) / len(recs)
dest = high if avg_gc >= 0.55 else low
SeqIO.write(recs, dest / fa.name, "fasta")
concurrent.futuresThreadPoolExecutor is usually fine for I/O-bound sequence parsing; switch to ProcessPoolExecutor if you do CPU-heavy work per record (translation, alignment, etc.).
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
from Bio import SeqIO
def count(fp: Path) -> tuple[str, int]:
return fp.name, sum(1 for _ in SeqIO.parse(fp, "fastq"))
with ThreadPoolExecutor(max_workers=8) as ex:
for name, n in ex.map(count, sorted(Path(".").glob("*.fastq.gz"))):
print(f"{name}\t{n}")
list(SeqIO.parse(...)). If the file is >1 GB, materialize only the records you need; otherwise stream.Path.glob() results are not guaranteed sorted. Always sorted().'.fasta.gz' formats. SeqIO reads .gz natively, but you must pass "fasta" (not "fasta-gz") and accept the slower text path.summary.csv writes. Don't write a header if summaries is empty — handle the zero-record case.SeqIO.convert(src, src_fmt, dst, dst_fmt) for format-boundary code; it returns record count for free.head -n 4 merged.fasta | grep '^>' should show the [source=...] provenance tags.nf-core modules for production: nf-core/modules has a samtools_faidx and seqkit_stats you can call directly.seqkit stats *.fasta) is faster than Python for stats-only tasks and is installed in most BioContainers images.seqkit stats -j 8 *.fasta | tee summary.tsv.SeqIO tutorial: https://biopython.org/wiki/SeqIOors-bioinformatics-sequence-compressed-sequence-files for .gz/.bgz handling.bio-batch-processing (bioSkills-main/sequence-io/batch-processing).Other skills in this category: