smftools.informatics.fastq_export#
Write per-barcode FASTQ files of reads directly from the raw ragged store.
Reads sequence and quality straight from the ragged parquet shards (the literal
as-sequenced read in query coordinates, not a reference-padded reconstruction),
so this needs only the raw spine's obs (with its ragged_shard pointer
column) -- no BAM re-parsing or dense materialization.
Functions
|
Write a |
|
Write one FASTQ per barcode/group from the raw ragged store. |
- smftools.informatics.fastq_export.write_fastq_per_barcode(raw_obs, base_dir, outdir, *, read_ids=None, group_labels='Barcode', gzip_output=True)#
Write one FASTQ per barcode/group from the raw ragged store.
Reads are grouped by their
ragged_shardpointer so every shard is read at most once, regardless of how many barcode groups its reads belong to; decoded records then stream to one open file handle per barcode.- Parameters:
raw_obs (
DataFrame) -- The raw spine'sobs, indexed by read_id, with aragged_shardcolumn (seeinformatics.raw_store.write_raw_store).base_dir (
str|Path) -- Raw spine's parent directory, used to resolveragged_shardrelative paths.outdir (
str|Path) -- Directory to write<barcode>.fastq[.gz]into.read_ids (
set[str] |None(default:None)) -- Read IDs to include (e.g. a QC-passed set).Nonewrites every read inraw_obs.group_labels (
Series|str(default:'Barcode')) -- Either a column name inraw_obs, or an externally suppliedSeries(indexed by read_id) of per-read group/barcode labels -- e.g. sample-sheet-enriched names from a preprocessed AnnData.gzip_output (
bool(default:True)) -- Whether to gzip-compress the FASTQ output.
- Returns:
{barcode: {"path": Path, "n_reads": int}}for every barcode that had at least one read written.- Return type:
- Raises:
KeyError -- If
raw_obslacks aragged_shardcolumn, orgroup_labelsnames a missing column.