Repository navigation
Home
A bioinformatics package in Go.
Routines here were initially inspired by lessons from online bioinformatics courses and exercises. The current purpose of the code is still simply for the author to explore bioinformatics in Go. Yet, the collection of implemented algorithms is growing and so the purpose of this document is to provide organizing documentation beyond the godoc comments in the source.
Outside this library, the author has other repositories useful for bioinformatics.
- Graph algorithms, including Eulerian cycles and paths.
- Clustering, including UPGMA and neighbor joining.
- Multiset, methods on a map-based data representation.
- Permutations, a few permutation generators.
- Subsequences, longest increasing, longest common.
It's a mess, and very incomplete. Many functions retain quirks of their originating programming assignments. Some functions have duplicate implementations, generally originating from assignments in different courses that cover the same topic. It is a goal though, to move code away from the specific requirements of course assignments and toward more consistent, more general functionality using more standard terminology. So, someday it should have some direction towards some new goals. It's not really time yet.
Some parts of the library are about efficiency and comparing the efficiency of different algorithms. To continue in that direction, more routines should have time or space complexity documented, more should be benchmarked to support the documented claims.
One big package! Perhaps it can be split along some logical lines in the future but for now everything is in package bio. Well except for the package bio/logo, mentioned later.
The general theme is to use very simple types with the goal of performance.
Type Seq []byte is the most general sequence type and a number of functions will operate on this type. Also some functions simply treat []byte or string as sequences. These functions will generally implement some string algorithm that is not specific to DNA or peptides. These functions treat each byte as a separate symbol and generally perform case sensitive symbol comparisons.
A number of types are defined as named types for byte slices and are intended to hold data restricted to some symbol set. These are named with some indication of the expected symbol set and are documented with a list or description of the symbols. Methods on the type will assume the symbol set. For example the type DNA8 holds the eight symbols [ACTGactg], the type AA20 holds the twenty IUPAC proteinogenic amino acid symbols.
This library usually works with bases in the order ACTG and ACUG. In this order, bits 1 and 2 of the ASCII representations are 00, 01, 10, and 11, allowing indexes 0, 1, 2, 3 to be directly obtained from the ASCII. Yes, T and U are the same, 10. In some cases this bit pattern is exploited for efficiency, in other cases this base order is maintained just for consistency within the library.
Go doc's alphabetical presentation is a little messy for this package. Here are some topic groupings. Only the tersest descriptions are given here; see the go doc for full documentation.
Sequence types defined simply as []byte are Seq, DNA, DNA8, RNA, RNA8, AA, AA20. These types have no constructor functions; simply use a type conversion from []byte or string. They all have stringers which are simple string type conversions. Also a number of functions work directly on string values.
As a term, a kmer is a sequence of a certain number (k) symbols. There is no separate type defined for a single kmer value but the list type Kmers []DNA8 carries the assumption that all list elements are the same length. In contrast elements of DNA8List []DNA8 may or may not be all the same length, depending on context.
It's kinda panicky currently. For performance, you might want to say in a lot of cases that arguments have to be as expected or else it's a programmer error and it's fair to panic. It's not very nice though and probably lots of places where panics can currently happen should have a little added code to return errors if arguments are invalid.
ReadFASTA-
ReadFASTAFile, FASTAReader.ReadSeq-
FASTASeq.ID,FASTASeq.Desc
- ASCII case conversion:
Seq.ToLower,Seq.ToUpper, - Delete sub-sequences:
Splice(string) - DNA to RNA:
DNA.Transcribe,DNA8.Transcribe - Reverse, Complement:
Seq.Reverse,DNA8Complement,DNA8.ReverseComplement - With IUPAC ambiguity:
DNAComplement,DNA.ReverseComplement - Constants and variables:
CodonTable,DNAStart,RNAStart,AAStop,GapSymbol - Translation:
CodonIndex,TranslateCodon,IsStartCodon,DNA8.Translate,DNA8.TranslateORF
- Data validation:
Kmers.Uniform,DistanceMatrix.Validate,DistanceMatrix.Additive - Hamming distance:
Seq.Hamming,DNA8.Hamming - Symbol counts:
Seq.Freq,Seq.FreqMap,DNA.BaseFreq,DNA8.BaseFreq,RNA8.BaseFreq,DNA.GCContent,DNA8.GCContent -
GCSkew,TiTvRatio(DNA),TiTvRatio(DNA8) - Determine leader board cut index:
Cut(sort.Interface) - Float64s:
NearestFloat64,ParseFloats,Quantize
In a separate packge bio/logo for namespace reasons, generates motif logos in the SVG format.
- Motif generates the SVG
- A raft of configuration functions control Motif.
- Enumerate all kmers in a sequence:
KmerComposition(string) - Enumerate all variants of a single kmer,
DNA8.HammingVariants - Enumerate all possible kmers for a given k:
DNA8.Inc - Compute all possible for a given k:
NumSubPepLinear,NumSubPepCyclic
- Linear search:
Seq.AllIndex,Seq.AllCount,Seq.HammingAllIndex - Count only:
Seq.AllCount - Knuth Morris Pratt:
KMP.Index,KMP.AllIndex - Burrows-Wheeler:
BWT.AllIndex - Search reading frames:
DNA8.AAFindAllIndex,DNA8.AAFindAllIndex3RC - Find most frequent:
ModalKmers(string),DNA8.ModalHammingKmers,DNA8.ModalHammingKmersRC - Find clustered repeats:
KmerClumps(string) - Find best match:
Seq.KmersNearestMotif,DNA8.KmersNearestMotif - Distance of best match
DNA8.MotifHamming,DNA8List.MotifHamming - Replication origin:
MinGCSkew - Find complement-palindromes:
DNA8.PalFindAllIndex - Find motifs common to each sequence in a list:
DNA8List.HammingMotifs,DNA8List.MedianMotifs,DNA8List.GreedyMotifSearch,DNA8List.RandomMotifSearch,DNA8List.GibbsMotifSearch
A CountProfile object holds integer counts, a FracProfile normalizes these to float64 values <= 1.0.
-
DNAConsensus([]DNA)computes consensus and "match" score directly from sequences without constructing profile -
Kmers.Consensusas above, but for DNA8 -
Kmers.ConsensusHammingcomputes cumulative hamming distance ("mismatch") directly from kmers without constructing profile -
Kmers.Entropycomputes Entropy -- "mismatch" sense like hamming but better -
Kmers.EntropyContributionsindividual entropy terms -
Kmers.CountProfile,CountProfile.Addconstruct a profile -
CountProfile.Consensusreturns DNA consensus and "match" score -
Kmers.FracProfile,Kmers.LaplaceProfileconstruct -
FracProfile.Entropy,FracProfile.CrossEntropy,FracProfile.RelativeEntropy -
FracProfile.KmerProbabilitycompute probability of a given kmer -
FracProfile.MostProbKmer, FracProfile.MostProbKmers` construct the most probable kmers
- Pairwise:
AlignGlobal,AlignLocal,AlignPair,AlignGlobalAffine,AlignGlobalLS(), - Substitution Matrixes:
PAM250,Blosum62 - Scores:
LinearGap,ConstantGap
- DeBruijn stuff:
Adjacency,Overlap,DeBruijn,DeBruijnK -
AlignLong([]string),
- Restriction sites:
SolvePartialDigest
Associated types are AAMass, MassSpec
Mass lookup: AA20MonoisotopicMass, AA20MonoisotopicMassTable
Compute mass: AA20.Weight
Other constants, values: AA20Alphabet, AA20Lightest, AA20Heaviest, ProtonMass, WaterMassAverage, WaterMassMonoisotopic
Convert to float64 sequence: AA20.MonoisotopicMass
- Synthesize spectrum for sequence:
AAMass.LinearSpec,AAMass.CyclicSpec,AA20.PrefixSpectrum - Compare spectra:
MassSpec.Overlap - Sequence cyclic peptides from spectrum:
MassSpec.SeqCyclic20
Reflecting the introductory course material, algorithms are first developed with the simplification of integer masses. Associated types are AAInt, AA18Int, IntSpec, MassCounts, AAInt
- Mass lookup:
AA20IntegerMass,AA20IntegerMassTable - Identify amino acid:
AA20NearestMass - Convert to an integer sequence:
AA20.Int - Histogram:
IntSpec.Counts - Compare spectra:
IntSpec.Equal - Compare to spectrum:
AAInt.CyclicCommonCounts,AAInt.LinearCommonCounts - Synthesize spectrum for sequence:
AAInt.LinearSpec,AAInt.CyclicSpec - Sequence cyclic peptides from spectrum:
IntSpec.SeqCyclicTheo,IntSpec.SeqCyclicExp,IntSpec.SeqCyclic18Exp - Convolution:
IntSpec.Convolve,ConvolveSpectra
- Distance matrix:
DNA8List.DistanceMatrix,StrList.DistanceMatrix,DNA8List.KCompositionDistMat,StrList.KCompositionDistMat - Distance metrics:
DNA8.PDistance,Seq.PDistance,Str.PDistance,Str.KCompositionDist - Max parsimony:
DNA8MaxParsimonyRooted,DNA8MaxParsimonyUnooted - Trees:
ParseNewick,PhyloList.RootedTree,PhyloList.PathLen,PhyloList.Distance,PhyloRootedTree.Newick - CharacterTables:
PhyloRootedTree.CharacterTable,StrKmers.CharacterTable