Python API
mgnifam is a command-line tool first. The generated API pages document every module so
that contributors can browse the docstrings, most of which explain an invariant, but
only three names are a stable interface:
- the
mgnifamconsole script and its subcommands, equivalentlypython -m mgnifam; mgnifam.__version__;mgnifam.generate_families.build_ssi_index, for building a shared index once upstream of many chunk tasks.
Everything else may change in any release without notice.
build_ssi_indexfunction#
def build_ssi_index(fasta: str | os.PathLike[str], ssi_path: str | os.PathLike[str]) -> NoneBuild an Easel SSI index for fasta, replacing ssi_path atomically.
fasta must be uncompressed: Easel cannot seek within a gzip stream. Its sequence
names must be unique, or DuplicateSequenceName is raised, and non-empty, or
ValueError is – a bare > line otherwise reached split()[0] as an IndexError,
which is the one malformed input that produced a traceback instead of a message.
The index is built inside a private directory on the destination filesystem and
moved into place only on success, so a concurrent reader never observes a partial
index and a crashed build leaves nothing behind. That directory is not merely
tidiness: SSIWriter.close() raises before Easel closes its own writer, so on a
duplicate key the native handle and any external-sort scratch files are still open
and cannot be cleaned up by unlinking a known path.
Safe against PID collisions and cooperating concurrent writers. Not a defence against an actor with write access to the destination directory.