Sequencing data with Jennifer

Jennifer

Sequences, Sanger traces, fragment runs, NGS reads, mtDNA haplogroups and study tables with four @deckyard decks and one @skiffyard deck, and one pipeline that ties them together.

November 2026, by @mplx.
Based on Jennifer 0.27.0

Powered by Jennifer's Cantrip - Markdown into slide decks, https://github.com/jennifer-language/cantrip
1 / 21

Five decks, and where the data comes from

DeckReadsSample here
@deckyard/bioinformatics 0.4.0DNA, RNA, protein, FASTAcalls of 3730.ab1
@deckyard/abif 0.1.0.ab1, .fsa, .hidBiopython's test files
@deckyard/ngs 0.3.0FASTQ, SAM, VCF, BED, GFF2000 generated reads
@skiffyard/mitoleaf 0.5.0mitoLEAF tree XMLthe deck's test tree
@deckyard/statfiles 0.1.0Stata™, SPSS™, SAS™a generated .dta

jvc install brings forensicgenetics 0.5.0 along with mitoleaf.

2 / 21

One read, four molecules

def s as string init abif.calls(abif.open("data/3730.ab1")).bases;
def start as int init bioseq.find($s, "ATGGTGAGCAAG")[0].start;
def cds as string init $s[$start..$start + 60];
io.printf("RNA      %s\n", bioseq.transcribe($cds));
io.printf("revcomp  %s\n", bioseq.reverseComplement($cds));
io.printf("protein  %s\n", bioseq.translate($cds));
1165 bases, GC 62.5 %
DNA      ATGGTGAGCAAGGGCGAGGAGGATAACATGGCCATCATCAAGGAGTTCATGCGCTTCAAG
RNA      AUGGUGAGCAAGGGCGAGGAGGAUAACAUGGCCAUCAUCAAGGAGUUCAUGCGCUUCAAG
revcomp  CTTGAAGCGCATGAACTCCTTGATGATGGCCATGTTATCCTCCTCGCCCTTGCTCACCAT
protein  MVSKGEEDNMAIIKEFMRFK
3 / 21

Frames, motifs and sites

def protein as string init bioseq.translate($s[$start..len($s)]);
for (def m in bioseq.find($protein, "MVSKGEE")) { ... }
bioseq.findIupac($s[0..120], "RNNATGG")[0];
bioseq.restrictionSites($s, ["EcoRI", "NcoI", "BamHI"]);
372 residues, stop codons: 0
MVSKGEE at residue 1
MVSKGEE at residue 241
linker GGSG
start codon at 47
RNNATGG ACCATGG at 44, strand 1
NcoI CCATGG at 45
NcoI CCATGG at 480
4 / 21

FASTA, and refusing what is not a base

def recs as list of bioseq.Record init [
    bioseq.Record{id: "cds", description: "from 3730.ab1", sequence: $cds}];
def text as string init bioseq.writeFastaWrapped($recs, 40);
bioseq.parseFasta($text)[0].id;          # cds
bioseq.reverseComplement("ACGTX");       # throws
>cds from 3730.ab1
ATGGTGAGCAAGGGCGAGGAGGATAACATGGCCATCATCA
AGGAGTTCATGCGCTTCAAG
bioinformatics: not a nucleotide sequence: 'X' at position 4 (use
  filterDna / filterRna / filterProtein to strip it)
5 / 21

ABIF: a directory of tagged entries

def f as abif.File init abif.open($path);
def i as abif.Info init abif.info($f);
io.printf("%s, well %s, %s %s, %s\n", $i.sample, $i.well, $i.model,
    $i.polymer, $i.runStart);
io.printf("ABIF %d, %d tags, base order %s\n", $f.version,
    len(abif.tags($f)), abif.text($f, "FWO_", 1));
226032_C-ME-18_pCAGseqF, well B9, 3730 POP7, 2009-12-12 09:56:53
ABIF 101, 123 tags, base order GATC
6 / 21

Base calls, qualities, peaks

def c as abif.Calls init abif.calls($f);
for (def q in $c.qualities) {
    if ($q >= 20) {
        $high = $high + 1;
    }
}
1165 bases, 1089 at Q20 or better
first 12: GGGCGAGCKYYA [20, 3, 4, 4, 4, 6, 4, 4, 0, 0, 0, 6]
bases 101-120: CTTCAAGGTGCACATGGAGG
7 / 21

Plotting a trace

def ys as list of float init plot.floats(
    abif.analysedTrace($f, $d)[$from..$stop]);   # one per dye
...
plot.save(plot.chart($series, $opts), "out/trace.svg");

Analysed signal of 3730.ab1, bases 101 to 120

8 / 21

Fragment analysis: no bases, just sizes

FragmentAnalysis36_POP7_1 on a 3100, dye set F, 2004-11-22 11:58:35
dye 1 5-FAM  530 nm: 8531 scans, 47 peaks over 100
dye 4 ROX    607 nm: 8531 scans, 21 peaks over 100
abif: the file has no base calls (PBAS 2); is it a fragment run?

Raw signal of test.fsa, scans 3000 to 5500

9 / 21

FASTQ, one record at a time

def r as fastq.Reader init fastq.open("data/reads.fastq");
while (fastq.hasNext($r)) {
    def rec as fastq.Read init fastq.next($r);
    if (fastq.minQuality($rec, fastq.PHRED33) < 15) { ... }
}
fastq.close($r);
syn1: 100 bases, mean Q 30.1, last five [15, 17, 19, 18, 13]
2000 reads, 1347 with a base below Q15
10 / 21

Quality control in one pass

def opts as qc.Options init qc.options();
$opts.perBase = true;
def rep as qc.Report init qc.analyze("data/reads.fastq", $opts);
io.printf("%s", qc.summary($rep));
reads seen      2000
GC content      50.07 %
mean quality    30.14
bases >= Q30     59.95 %
adapter AGATCGGAAGAGC 250
mean Q at base 1: 36.9, at base 100: 16.0
11 / 21

Trimming adapters and tails

def s as trim.Stats init trim.run("data/reads.fastq", "out/trimmed.fastq",
    trim.options());
io.printf("in %d reads, %d bases; out %d reads, %d bases\n", $s.readsIn,
    $s.basesIn, $s.readsOut, $s.basesOut);
in 2000 reads, 200000 bases; out 2000 reads, 167465 bases
adapter-clipped 253, quality-trimmed 1749, too short 0
12 / 21

SAM, VCF and BED, line by line

def a as sam.Record init sam.parse(
    "r1\t16\tchrM\t16201\t60\t40M2I58M\t*\t0\t0\t*\t*\tNM:i:3");
def v as vcf.Variant init vcf.parse("chrM\t16278\t.\tC\tT\t50\tPASS\tDP=31");
def target as intervals.Interval init bed.parse("chrM\t16023\t16365\tHVS1");
intervals.contains($target, vcf.toInterval($v));
r1 - pos 16201, covers 98 reference bases, NM 3
as an interval: chrM	16200	16298
chrM:16278 C>["T"] snv=true passed=true DP=31
variant in target: true; read overlaps target by 98 bases
ngs.sam: CIGAR ends with a length and no operation: 40M2
13 / 21

mitoLEAF: a tree of motifs

def t as mitoleaf.Tree init mitoleaf.parse(fs.readString("data/tree.xml"));
for (def hg in mitoleaf.path($t, "L0a")) {
    ... mitoleaf.motif($t, $hg) ... mitoleaf.haplotype($t, $hg) ...
}
root mt-MRCA, 7 haplogroups
mt-MRCA adds 73G 146C 263G 315.1c 16519Y -> 73G 146C 263G 315.1C 16519Y
L0      adds A263 1048T             -> 73G 146C 315.1C 1048T 16519Y
L0a     adds T146 5231A 16278T      -> 73G 315.1C 1048T 5231A 16278T 16519Y
14 / 21

Nearest is not a classification

def obs as lineage.MtHaplotype init lineage.mtHaplotype("obs",
    ["16024-16362", "1-417"], "16278T 73G 315.1C");
def m as mitoleaf.Match init mitoleaf.assign($t, $obs);
nearest L0a, distance 3, ranges agree: false
  mt-MRCA 4, L0 4, L0a 3, L0a1 5, L1 6
lineage: haplotype 'bad': '73G' and '73A' name the same position
15 / 21

A pipeline: trace to haplogroup

func trimmed(r as fastq.Read) {
    def t as fastq.Read init trim.clipFixed($r, goodStart($r), 0);
    return trim.clipQuality($t, MIN_Q, WINDOW, fastq.PHRED33);
}
func differences(id as string, ref as string, refStart as int,
        s as string) {
    def al as bioseq.Alignment init bioseq.alignLocal($ref, $s,
        bioseq.dnaOptions());
    def r as string init strings.replace($al.a, "-", "");
    def x as string init strings.replace($al.b, "-", "");
    return lineage.mtHaplotypeFrom($id, $r, $x, $refStart + $al.startA);
}
16 / 21

The pipeline's run

SYN-HVS1: 390 bases, 345 kept, mean Q 41.9
  ["16024-16362"] ["16278T"]
SYN-HVS2: 469 bases, 424 kept, mean Q 42.8
  ["1-417"] ["73G", "315.1C"]
nearest L0a at distance 3, path ["mt-MRCA", "L0", "L0a"]
its haplotype ["73G", "315.1C", "1048T", "5231A", "16278T", "16519Y"]
17 / 21

Study results from Stata, SPSS and SAS

def data as bytes init fs.readBytes($path);
def ds as statfiles.Dataset init statfiles.read($data);
statfiles.labelOf($ds, "region", $row);    # "north", from a value label
statfiles.present($ds, "meanq");           # the non-missing values
statfiles.column($ds, "meanq");            # throws: row 5 is missing
Synthetic mtDNA study: dta 114, 8 rows, windows-1252
north: L0a L0a L0a1 L1
south: L0b L1a L0 L0a
mean quality over 7 of 8 rows: 45.2
statfiles: statfiles: meanq is missing (.) in row 5
18 / 21

Malformed input, by kind

Inputkind
fake.ab1 (26 bytes of text), an .ab1 cut shortabif
a FASTA header with no identifier, a base Xbioinformatics
FASTQ with a quality shorter than its sequencengs.fastq
a FASTA file handed to statfiles.readstatfiles
two designations for one position, an unknown haplogrouplineage, mitoleaf
fake.ab1: abif
  abif: not an ABIF file: 26 bytes, the header alone is 128
FASTQ: ngs.fastq
  sequence and quality differ in length in read: @r1
19 / 21

Huge input: caps throw limit

CapDefaultHere
bioseq.MAX_RECORDS1000000records per parse
AlignOptions.maxCells100000010000: 200 x 200 throws
lineage.MAX_ALIGN_LENGTH5000bases: 20 kb throws
abif.MAX_ENTRIES65536directory entries
statfiles maxCells2000000020: 8 x 5 throws
maxCells 20: limit
  statfiles: 8 rows of 5 variables is over 20 cells
align 20 kb: limit
  sequence longer than 5000 bases: alignment is O(nm), so a who...
20 / 21

Read more

Based on Jennifer 0.27.0, November 2026.

21 / 21