Skip to content
@deckyard/bioinformatics

Cheatsheet

Every export, reached as bioseq.NAME. All errors are Error{kind: "bioinformatics"}.

jennifer
import "@deckyard/bioinformatics/" as bioseq;

Conventions (details): input in any case, residues out uppercase (FASTA/FASTQ parsing preserves case); offsets 0-based half-open, in forward-strand coordinates even for reverse-strand features; subrange is the one 1-based inclusive verb; filter* strip silently, everything else raises on a foreign character; physical quantities raise on ambiguity codes; a With suffix makes a default explicit.

Alphabets and validation

FunctionReturnsNotes
filterDna(s)stringkeep DNA_ALPHABET only, uppercased
filterRna(s)stringkeep RNA_ALPHABET only
filterProtein(s)stringkeep PROTEIN_ALPHABET only
isDna(s)boolnon-empty and wholly in the alphabet
isRna(s)bool
isProtein(s)bool
kindName(kind)string"DNA", "RNA" or "protein"
ConstantValueMeaning
DNA1molecule kind
RNA2molecule kind
PROTEIN3molecule kind
DNA_ALPHABET"ACGTRYSWKMBDHVN"bases plus IUPAC codes
RNA_ALPHABET"ACGURYSWKMBDHVN"
PROTEIN_ALPHABET"ACDEFGHIKLMNPQRSTVWYBZXJUO*"standard, ambiguous, rare, stop

Transforms

FunctionReturnsNotes
complement(s)stringpairs each base, same order
reverseComplement(s)stringthe other strand, 5' to 3'
reverse(s)stringany sequence
transcribe(dna)stringT to U
backTranscribe(rna)stringU to T
translate(nt)stringstandard code, stops as *
translateWith(nt, table)stringcodon map, e.g. VERTEBRATE_MITOCHONDRIAL
translateFrame(nt, frame)stringframe 1, 2, 3, -1, -2, -3
translateFrameWith(nt, frame, table)string
sixFrame(nt)list of Frameorder 1, 2, 3, -1, -2, -3
sixFrameWith(nt, table)list of Frame
splitCodons(nt)list of stringtrailing partial codon dropped
oneToThree(protein)stringMKV to MetLysVal
threeToOne(protein)stringrun together or space/hyphen separated

Frame

FieldMeaning
frame as int1, 2, 3, or -1, -2, -3 for the reverse complement
protein as stringthe translation, stops as *

Composition and properties

FunctionReturnsNotes
baseCount(s)map of string to intpresent residues only
baseFrequency(s)map of string to floatpercentages
residueCount(p)map of string to int
residueFrequency(p)map of string to floatpercentages
gcContent(s)floatpercentage; ambiguity codes count in length only
atContent(s)floatpercentage of A, T, U
gcWindows(s, size, step)list of floatfull windows only
molecularWeight(s, kind)floataverage Da; nucleic acid as 5'-OH single strand
meltingTemp(s)floatWallace rule, Celsius, DNA
meltingTempNn(s)floatnearest-neighbour, 250 nM primer, 50 mM Na+
meltingTempNnWith(s, primerNm, saltMm)floatnM, mM
netCharge(p, ph)floatEMBOSS iep pKa set
isoelectricPoint(p)floatbisection over pH 0 to 14
gravy(p)floatmean Kyte-Doolittle hydropathy
aromaticity(p)floatfraction of F, W, Y
dnaStats(s)DnaStats
proteinStats(p)ProteinStats
codonUsage(nt)list of CodonUsestandard code, first-seen order
codonUsageWith(nt, table)list of CodonUse

DnaStats

FieldMeaning
length as intbases
gc as floatGC percentage
at as floatAT percentage
counts as map of string to intresidue counts
molecularWeight as floatDa, 0.0 when ambiguous
meltingTemp as floatWallace Tm, 0.0 when ambiguous
ambiguous as boolany code other than A, C, G, T

ProteinStats

FieldMeaning
length as intresidues
molecularWeight as floatDa, 0.0 when ambiguous
isoelectricPoint as float0.0 when ambiguous
gravy as float0.0 when ambiguous
aromaticity as floatfraction of F, W, Y
counts as map of string to intresidue counts
ambiguous as boolcarries B, Z, X, J or *

CodonUse

FieldMeaning
codon as stringDNA-spelled codon
aminoAcid as stringits residue under the table, X if not in it
count as intoccurrences
fraction as floatshare among synonymous codons, 0 to 1
perThousand as floatper thousand codons
FunctionReturnsNotes
find(s, pattern)list of Matchexact, overlapping
findIupac(s, pattern)list of MatchIUPAC codes in the pattern
findFuzzy(s, pattern, maxMismatches)list of Matchsubstitutions only
orfs(nt, minAa)list of Orfsix frames, standard code
orfsWith(nt, minAa, tableId)list of OrfNCBI table id
cpgIslands(s, window, minGc, minObsExp)list of Regionclassic: 200, 50.0, 0.6
restrictionSites(s, names)list of Siteordered by cut, then enzyme
enzymesCutting(s)list of stringenzymes with a site
nonCutters(s)list of stringenzymes without one
restrictionDigest(s, names, circular)list of Fragmentcuts at cutTop

Match

FieldMeaning
start as int0-based offset of the first base
end as intone past the last base
text as stringthe matched subsequence
strand as int+1, or -1 on the reverse complement
mismatches as int0 except for findFuzzy

Orf

FieldMeaning
frame as int1, 2, 3 forward; -1, -2, -3 reverse
strand as intsign of frame
start as intfirst base of the start codon, forward coordinates
end as intone past the last base, stop included
length as intend - start
nucleotides as stringthe frame as read, 5' to 3'
protein as stringtranslation without the stop
stopped as boolfalse when it ran off the end

Region

FieldMeaning
start as int0-based offset
end as intone past the last base
length as intbases
gc as floatGC percentage
obsExp as floatobserved over expected CpG

Site

FieldMeaning
enzyme as stringenzyme name
start as intfirst base of the recognition site
end as intone past the site
cut as inttop-strand cut offset
site as stringconcrete sequence found
strand as int+1, or -1 if found only on the reverse strand

Fragment

FieldMeaning
start as intfirst base in the original sequence
end as intone past the last; not greater than start for a fragment through a circular origin
length as intbases
sequence as stringthe fragment

Formats

FunctionReturnsNotes
parseFasta(text)list of Recordcase preserved
writeFasta(records)stringwrapped at FASTA_WIDTH
writeFastaWrapped(records, width)string
wrap(s, width)stringno trailing newline
toPlain(text)stringstrip headers, digits, whitespace
parseFastq(text)list of Readfour-line or wrapped
writeFastq(reads)stringfour-line form
fastqToFasta(reads)list of Record
qualityScores(r)list of intPhred+33
qualityScoresWith(r, offset)list of intPHRED33 or PHRED64
meanQuality(r)floatarithmetic mean, Phred+33
meanQualityWith(r, offset)float
errorProbability(score)float10^(-Q/10)
ConstantValueMeaning
FASTA_WIDTH60default line width
MAX_RECORDS1000000records per parse
PHRED3333Sanger, Illumina 1.8+
PHRED6464Illumina 1.3 to 1.7

Record

FieldMeaning
id as stringfirst token after >
description as stringrest of the header, or ""
sequence as stringjoined sequence lines

Read

FieldMeaning
id as stringfirst token after @
description as stringrest of the header, or ""
sequence as stringthe bases
quality as stringencoded quality, same length as sequence

Manipulation

FunctionReturnsNotes
randomDna(n)stringuniform over DNA_BASES
randomRna(n)stringuniform over RNA_BASES
randomProtein(n)stringuniform over STANDARD_RESIDUES
randomDnaWith(n, weights)stringrelative weights
randomRnaWith(n, weights)string
randomProteinWith(n, weights)string
shuffle(s)stringFisher-Yates, composition kept
mutate(s, rate, kind)stringsubstitutions, a mutated position always changes
subrange(s, from, through)string1-based inclusive
windows(s, size, step)list of stringfull windows only
ConstantValueMeaning
DNA_BASES"ACGT"generator alphabet
RNA_BASES"ACGU"
STANDARD_RESIDUES"ACDEFGHIKLMNPQRSTVWY"

Comparison

FunctionReturnsNotes
alignGlobal(a, b, opts)AlignmentNeedleman-Wunsch
alignLocal(a, b, opts)AlignmentSmith-Waterman
dnaOptions()AlignOptions+2 / -1, gap -2
proteinOptions()AlignOptionsBLOSUM62, gap -8
substitutionScore(matrix, a, b)inteither pair order
percentIdentity(al)floatover alignment length
percentSimilarity(al)float
percentGaps(al)float
formatAlignment(al, width)stringEMBOSS-style blocks
hammingDistance(a, b)intequal lengths only
editDistance(a, b)intLevenshtein
ConstantValueMeaning
DEFAULT_MAX_ALIGNMENT_CELLS1000000default maxCells, about 1 GB

AlignOptions

FieldMeaning
matchScore as intidentical residues, when matrix is empty
mismatchScore as intdiffering residues, when matrix is empty
gapScore as intper gap position
matrix as map of string to intsubstitution matrix, or empty
maxCells as intDP matrix limit; 0 for none

Alignment

FieldMeaning
a as stringfirst sequence, gapped
b as stringsecond sequence, gapped
markup as string| identical, : similar, space otherwise
score as inttotal score
length as intcolumns
identities as intidentical columns
similarities as intpositively scoring columns, identities included
gaps as intgap columns
startA as int0-based start in the first sequence
startB as int0-based start in the second

Reference data

FunctionReturnsNotes
codonTable(id)map of string to stringNCBI transl_table
codonTableName(id)string
codonTableIds()list of int1-6, 9-11
startCodons(id)list of string
expandIupac(code)stringR to AG
iupacClass(code)stringR to [AG]
matchesIupac(code, base)boolone-way
aminoAcid(code)AminoAcidone- or three-letter code
aminoAcids()list of AminoAcid22 records
hasAminoAcid(code)bool
enzyme(name)Enzymecase-insensitive
hasEnzyme(name)bool
enzymes()list of Enzymealphabetical
enzymeNames()list of stringalphabetical
isoschizomers(name)list of stringsame site string
isBlunt(e)boolcutTop == cutBottom
ConstantValueMeaning
PKA_N_TERMINUS8.6EMBOSS iep
PKA_C_TERMINUS3.6EMBOSS iep
WATER_MONO_MASS18.010565Da
WATER_AVG_MASS18.01528Da
PHOSPHATE_MASS79.98Da, HPO3
GAS_CONSTANT1.987cal/(mol K)

Map constants:

ConstantTypeValue
STANDARDmap of string to stringNCBI code 1
VERTEBRATE_MITOCHONDRIALmap of string to stringcode 2
YEAST_MITOCHONDRIALmap of string to stringcode 3
MOLD_MITOCHONDRIALmap of string to stringcode 4
INVERTEBRATE_MITOCHONDRIALmap of string to stringcode 5
CILIATE_NUCLEARmap of string to stringcode 6
ECHINODERM_MITOCHONDRIALmap of string to stringcode 9
EUPLOTID_NUCLEARmap of string to stringcode 10
BACTERIALmap of string to stringcode 11
IUPAC_DNAmap of string to stringcode to bases
IUPAC_RNAmap of string to stringcode to bases
COMPLEMENT_DNAmap of string to stringcode to complement
COMPLEMENT_RNAmap of string to stringcode to complement
THREE_LETTERmap of string to stringone-letter to three-letter
DNA_RESIDUE_MASSmap of string to floataverage residue mass, Da
RNA_RESIDUE_MASSmap of string to floataverage residue mass, Da
NN_ENTHALPYmap of string to floatdinucleotide dH, kcal/mol
NN_ENTROPYmap of string to floatdinucleotide dS, cal/(mol K)
BLOSUM62map of string to intpair to score, one order per pair

AminoAcid

FieldMeaning
one as stringone-letter code
three as stringthree-letter code
name as stringfull name
monoMass as floatmonoisotopic residue mass, Da
avgMass as floataverage residue mass, Da
pKa as floatside chain, 0.0 if it does not ionise
charge as int+1, -1 or 0
hydropathy as floatKyte-Doolittle

Enzyme

FieldMeaning
name as stringconventional spelling
site as stringrecognition sequence, IUPAC
cutTop as inttop-strand cut offset into the site
cutBottom as intbottom-strand cut, counted along the top strand
overhang as string"5'", "3'" or "blunt"
overhangLength as int0 when blunt