inputData

Converts a string into the bioUtils JSON format

inputData(dataString: string, metaData: object): object
Parameters
dataString (string) input data using '\n' for line breaks; can be fasta, fna, nexus or newick
metaData (object) any metadata to be appended to the bioUtils JSON object
Returns
object: the bioUtils JSON object {'sequences': [{'name': string, 'sequence': string}] ,'tree': string,'metaData': {'fileType': string, (metaData param)}}
Example
inputData('>seq1\nact\n>seq2\natc\n(seq1,seq2);', {'fileType': 'fna', 'otherMetaData': 'this is an example'})
// returns {'sequences': [ {name:'seq1', sequence:'act'}, {name:'seq2', sequence:'atc'} ],
//          'tree': '(seq1,seq2);',
//          'metaData': {'fileType': 'fna', 'otherMetaData': 'this is an example'})
//          }

readFileSync

Converts file into the bioUtils JSON format. Just wraps the inputData function for easier use.
-- NODE ONLY --

readFileSync(filePath: string, metaData: object): object
Parameters
filePath (string) a relative or absolute file path
metaData (object) any metadata to be appended to the bioUtils JSON object
Returns
object: the bioUtils JSON object {'sequences': [{'name': string, 'sequence': string}] ,'tree': string,'metaData': {'fileType': string}}

outputData

Converts a bioUtils JSON object to a string in one of the supported file formats

outputData(dataObject: object, fileType: string): string
Parameters
dataObject (object) the bioUtils JSON object {'sequences': [{'name': string, 'sequence': string}] ,'tree': string,'metaData': {'fileType': string}}
fileType (string) the desired filetype for the output string, if none is given the function will default to the filetype in the dataObject metaData
Returns
string: the data string in a particular file type format using '\n' for line breaks; can be fasta, fna, nexus or newick

writeFileSync

Writes a bioUtils json object to a file in a standard format (fasta, fna, nexus or newick). Just wraps the outputData function for easier use.
-- NODE ONLY --

writeFileSync(dataObject: any, filePath: string, fileType: string, the: object): null
Parameters
dataObject (any)
filePath (string) a relative or absolute file path
fileType (string) the type of file to write: fasta, fna, nexus or newick; if none is give than the fileType from the dataObject metaData will be used
the (object) bioUtils JSON object {'sequences': [{'name': string, 'sequence': string}] ,'tree': string,'metaData': {'fileType': string}}
Returns
null: This function writes a file but does not return anything.

fastaParser

Converts a fasta string into a bioUtils object

fastaParser(fastaString: string, metaData: object): object
Parameters
fastaString (string) input fasta string using '\n' for line breaks
metaData (object) any metadata to be appended to the bioUtils JSON object
Returns
object: the bioUtils JSON object {'sequences': [{'name': string, 'sequence': string}] ,'tree': undefined,'metaData': {'fileType': string, (metaData param)}}

fnaParser

Converts a fna string into a bioUtils object

fnaParser(fnaString: string, metaData: object): object
Parameters
fnaString (string) input fna string using '\n' for line breaks
metaData (object) any metadata to be appended to the bioUtils JSON object
Returns
object: the bioUtils JSON object {'sequences': [{'name': string, 'sequence': string}] ,'tree': string,'metaData': {'fileType': string, (metaData param)}}
Example
inputData('>seq1\nact\n>seq2\natc\n(seq1,seq2);')
// returns {'sequences': [ {'seq1': 'act'}, {'seq2': 'atc'} ],
//          'tree': '(seq1,seq2);',
//          'metaData': {'fileType': 'fna'})
//          }

newickParser

Converts a newick string into a bioUtils object

newickParser(newickString: string, metaData: object): object
Parameters
newickString (string) input newick string using '\n' for line breaks
metaData (object) any metadata to be appended to the bioUtils JSON object
Returns
object: the bioUtils JSON object {'sequences': []],'tree': string,'metaData': {'fileType': string, (metaData param)}}

nexusParser

Converts a newick string into a bioUtils object TODO: This is currently only handling a small subset of nexus formats and data. TODO: This was written with simplicity and readability in mind; it can and should be speed up a bit though.

nexusParser(nexusString: string, metaData: object): object
Parameters
nexusString (string) input newick string using '\n' for line breaks
metaData (object) any metadata to be appended to the bioUtils JSON object
Returns
object: the bioUtils JSON object {'sequences': [],'tree': string,'metaData': {'fileType': string, (metaData param)}}

containsStopCodons

Determins if any of the sequences contain stop codons

containsStopCodons(dataObject: object, geneticCode: string): boolean
Parameters
dataObject (object) the bioUtils JSON object
geneticCode (string) the genetic code to use for looking for stop codons
Returns
boolean: whether or not the data contains stop codons

numberOfSites

numberOfSites(dataObject: object): int
Parameters
dataObject (object) the bioUtils JSON object
Returns
int: The number of sites of sites of the fist sequence counting gaps

numberOfSequences

numberOfSequences(dataObject: object): int
Parameters
dataObject (object) the bioUtils JSON object
Returns
int: The number of sequences

sites

Attempt to quantify the diversity of an alignment using Shannon entropy

sites
Parameters
msa (object) a bioUtils JSON object
Returns
list: a list of the diversity for each site

translateToAminoAcids

Translate a codon bioUtils json object into an amino acid bioUtils json object.

translateToAminoAcids(dataObject: object, geneticCode: string): object
Parameters
dataObject (object) the bioUtils JSON object
geneticCode (string) the genetic code to use for translating codons to amino acids
Returns
object: the translated dataObject the bioUtils JSON object

getSitesAsListOfStrings

return a list of strings where each string is a site (0 -> numbrer of sites) and each character in the string is the character at that site and corresponding sequence (sequences listed in the same, decending order of the MSA)

getSitesAsListOfStrings(dataObject: object): list
Parameters
dataObject (object) the bioUtils JSON object
Returns
list: the list of strings
Example
const simpleBioUtilsObject = bioUtils.inputData('>seq1\nACT\n>seq2\nATC')
getSitesAsListOfStrings(simpleBioUtilsObject)
// returns ['AA', 'CT', 'TC']