Design
Scope
Reading the analysis files of the Applied Biosystems™ fragment-analysis software family (Genotyper™ documents; GeneScan™ projects, sample sheets and injection lists; GeneMapper™ projects and the tables GeneMapper and Peak Scanner™ export) and the reports of NCBI's OSIRIS into plain values. One deck for the family, one module per format, so a program that reads one format uses one namespace. The sample files themselves are ABIF, a published format with its own deck (@deckyard/abif). No writing.
Decisions
- One deck, modules shape. The formats share helpers (Mac aliases, Mac OS Roman text) and change for the same reason: a new file shows something new. Separate modules keep their APIs apart.
- Read everything at once.
genotyper.readreturns the whole document as plain structs. Walking it needs no calls into the module, so the document is not passed back across the module boundary. - Records found, then interpreted. The record tree is walked once (finding records by tag, class number, length and class name, and stepping over lane fields and peak tables, which can look like records); object numbers are kept for back-references. The classes the deck reads are then decoded by their layout.
- Damage is local. A lane whose fields do not fit, or a label naming a missing peak, goes to
Document.issues; the rest is read. A file that is not a Genotyper document fails. - Calls group labels by peak row, not by scan (offset in lanes of GeneScan results files), and get the categories of the lane's dye.
- Text is Mac OS Roman, decoded with the
encodinglibrary's"macintosh"codec (Jennifer 0.28.0); the deck carries no table. Exported tables are UTF-8, or Windows-1252 when not valid UTF-8 (what GeneMapper on Windows writes); OSIRIS reports are UTF-8. - Exported tables by column name. Columns depend on the table settings and the version, so
gmtablefinds every column by its header name; numbered columns become one peak per number, unknown columns stay text infields. Off-ladder (OL) and no-bin (?) alleles are kept and flagged, not dropped; empty numbers are -1. - OSIRIS through the core
xmllibrary. The report is the schemaOsirisAnalysisReport-2.0.xsd; notices are message numbers, checked against the report's messages. - Profiles without the dependency.
typingsreturnsgenotf.Typing, plain locus -> alleles maps in@deckyard/forensicgenetics' mixture shape; the conversion is documented, so the deck does not depend on it. - Aliases by Apple's layout, with a fallback for records the layout does not fit (Windows ports): the full path found by its extra.
Errors
Error{kind: "genotf"} for bytes that are not the format asked for and for alias records that are not there, and for a record whose data runs past its end or holds a NaN or infinite number. Problems inside a Genotyper document that leave the records intact are data (Document.issues), not errors. A table or report that breaks its layout (a ragged row, a number that is none, a missing required element, a notice without its message) fails whole with the same kind; xml's "limit" passes through.
Security and limits
The reader only reads: lengths are checked against the record and file they sit in before use, and walking stops at a record's end. Records nest a few levels deep; the walk recurses per level, not per record.
Testing and validation
GeneScan documents are built as ABIF bytes in the tests, with the real documents' irregularities. The GeneMapper test project is written by the JDK from Externalizable stand-in classes named as GeneMapper's (testdata/gen/GmFixture.java, invented values, embedded by testdata/gen/embed.j).
The Genotyper overlays build documents from bytes: categories in two dyes, lanes with new and back-referenced sources, labels before a later back-reference (they take no object number), a peak row that looks like a record header, Mac OS Roman names, a name led by a line feed, little-endian class numbers, a damaged lane, a results table. No vendor or user files are in the repository. With GENOTF_SAMPLES naming a folder of the Genotyper 3.7 tutorial documents, a further test checks them.
The gmtable overlay builds tables with the column layouts of real exports (GeneMapper ID-X with trailing tabs, columns in another order, a reduced table, sizing tables of GeneMapper and Peak Scanner with size-standard marks) and reads three GeneMapper 4 Genotypes tables of anemonefish microsatellites in testdata/gmtable (MIT, see its README). The osiris overlay reads reports laid out as OSIRIS 2.16's writer code lays them out, with invented values; no OSIRIS report is published with its sources.
Checked outside the suite: the 7 Genotyper tutorial documents and the GeneMapper ID-X example project, and real documents of each kind, whose results agree with what other readers and the documents' own tables show.
Known limitations and open questions
Macro step parameters, the statistics record and the trailer are not decoded; several fixed fields are unknown.
genescanneeds@deckyard/abif0.3.0 (lenient parsing) andgenemapperneeds@skiffyard/javaser; until both are released,vendor/is filled from the sibling checkouts by hand and CI cannot fetch them.GeneScan projects: only the sample files are read; panels, analysis parameters and the size standard are user-defined structures not decoded.
GeneMapper: only the fields listed in the module are read; positions in custom data are those of GeneMapper ID-X projects with the headers
GeneMapper1.200and4.000, and could move in other versions.gmtable: Peak Scanner Cloud's column names (Dye, Sample Peak,Area (Data Point)) are taken from a third-party importer, not from files. Quality flag values are not interpreted.osiris: checked against OSIRIS's schema and source, not against report files; lab settings, QC values, reviews and acceptances are not read.
Dependencies on decks
@deckyard/abif ^0.3.0 (the lenient parse) for genescan; @skiffyard/javaser ^0.1.0 for genemapper. genemapper reads the javaser.Stream tables directly instead of calling accessors per node: each call into a module rebuilds a Stream argument (about 9 ms for a 38,000-node project).
Dependencies on the interpreter
>=0.28.0, for encoding's "macintosh" codec (M29). Pure computation; no capabilities.