Table of Contents#
- math.Skewness
 - math.Variance
 - math.Std
 - math.GatherDescriptiveStats
 - math.GetIC
 - math.HolmBonferroniCorrection
 - math.BenjaminiHochbergFDR
 - math.minNormalizedRange
 - math.DoLRT
 - math.Sum
 - math
 - math.Median
 - math.Int
 - math.Mean
 - math.Kurtosis
 - matrix
 - matrix.Symmetrize
 - random
 - regexp.Split
 - regexp
 - regexp.Replace
 - regexp.Find
 - regexp.FindSubexpressions
 - regexp.PartitionByRegularExpressions
 - models.binary.generic.Time
 - models.binary.generic.DefineQMatrix
 - models.binary
 - models.codon.generate_stencil
 - models.codon.generic.DefineQMatrix
 - models.codon
 - models.codon.MapCode
 - models.DNA.generic.Time
 - models.DNA.generic.DefineQMatrix
 - models.DNA
 - frequencies.empirical.binary
 - frequencies.empirical.binary
 - frequencies.empirical.protein
 - frequencies.empirical.protein
 - frequencies.empirical.protein
 - frequencies.equal
 - frequencies.empirical.F3x4
 - frequencies.empirical.F1x4
 - frequencies.empirical.corrected.CF3x4
 - frequencies.mle
 - frequencies.empirical.nucleotide
 - frequencies.empirical.nucleotide
 - frequencies
 - model.ApplyToBranch
 - model.define_from_components
 - model.generic.AddLocal
 - model.generic.AddGlobal
 - model.generic.GetLocalParameter
 - model.generic.GetLocalParameter
 - model.generic.GetGlobalParameter
 - model.generic.get_a_parameter
 - model.generic.get_rate_variation
 - model.generic.DefineModel
 - model.generic.DefineMixtureModel
 - model.ApplyModelToTree
 - models.generic.ConstrainBranchLength
 - models.generic.SetBranchLength
 - models.generic.AttachFilter
 - model.Dimension
 - model.parameters.Local
 - model.parameters.Global
 - model.MatchAlphabets
 - model
 - model.GetParameters_RegExp
 - parameters.DeclareCategory
 - parameters.NormalizeRatio
 - parameters.SetValue
 - parameters.SetLocalValue
 - parameters.SetValues
 - parameters.ConstrainMeanOfSet
 - parameters.UnconstrainParameterSet
 - parameters.Mean
 - parameters.Quote
 - parameters.AppendMultiplicativeTerm
 - parameters.AddMultiplicativeTerm
 - parameters.StringMatrixToFormulas
 - parameters.GenerateAttributedNames
 - parameters
 - parameters.GenerateSequentialNames
 - parameters.GetRange
 - parameters.SetRange
 - parameters.DeclareGlobal
 - parameters.IsIndependent
 - parameters.SetConstraint
 - parameters.SetProprtionalConstraint
 - parameters.ConstrainSets
 - parameters.RemoveConstraint
 - parameters.helper.copy_definitions
 - pparameters.SetStickBreakingDistribution
 - pparameters.GetStickBreakingDistribution
 - parameters.helper.stick_breaking
 - parameters.helper.dump_matrix
 - parameters.helper.tree_lengths_to_initial_values
 - parameters.GetProfileCI
 - parameters.ExportParameterDefinition
 - parameters.SetLocalModelParameters
 - parameters.SetLocalModelParameters
 - parameters.ApplyNameSpace
 - parameters.ValidateID
 - parameters.DeclareGlobalWithRanges
 - models.protein.generic.Time
 - models.protein
 - models.protein.generic.DefineQMatrix
 - rate_variation
 - alignments.GetSequenceNames
 - alignments.GetSequenceNames
 - alignments.GetIthSequence
 - alignments.LoadGeneticCode
 - alignments.GetIthSequenceOriginalName
 - alignments.GetAllSequences
 - alignments.ReadNucleotideDataSet
 - alignments.FilterType
 - alignments.ReadProteinDataSet
 - alignments.AlphabetType
 - alignments.EnsureMapping
 - alignments.ReadNucleotideDataSetString
 - alignments.PromptForGeneticCodeAndAlignment
 - alignments.LoadGeneticCodeAndAlignment
 - alignments.LoadCodonDataFile
 - alignments.ReadCodonDataSetFromPath
 - alignments.ReadNucleotideAlignment
 - alignments.CompressDuplicateSequences
 - alignments.DefineFiltersForPartitions
 - alignments.serialize_site_filter
 - alignments.ReadCodonDataSet
 - alignments.ReadCodonDataSetFromPathGivenCode
 - alignments.Extract_site_patterns
 - ancestral.Sequences
 - ancestral.ComputeSubstitutionCounts
 - ancestral
 - ancestral.build
 - distances.nucleotide.tn93
 - distances.nucleotide.p_distance
 - estimators.FitCodonModel
 - estimators.FitMGREV
 - estimators.FitMGREV
 - estimators.ComputeLF
 - estimators.CreateInitialGrid
 - estimators.LHC
 - estimators.SetGlobals
 - estimators.SetCategory
 - estimators.ExtractBranchInformation.copy_local
 - estimators.ExtractBranchInformation
 - estimators.branch_lengths_in_string
 - estimators.ExtractMLEs
 - estimators.ExtractMLEsOptions
 - estimators.TraverseLocalParameters
 - estimators.GetGlobalMLE
 - estimators.FitExistingLF
 - estimators.FitLF
 - estimators.FitLF
 - estimators.GetBranchEstimates
 - estimators.TakeLFStateSnapshot
 - estimators.GetGlobalMLE_RegExp
 - estimators.FitSingleModel_Ext
 - estimators.FitGTR_Ext
 - estimators.FitGTR
 - genetic_code.DefineCodonToAAMapping
 - genetic_code.DefineCodonToAAMapping
 - genetic_code.IsStop
 - genetic_code.DefineCodonToAAGivenCode
 - genetic_code
 - trees.infer.NJ
 - trees.GetTreeString
 - trees._matrix2string
 - trees.PartitionTree
 - trees.LoadAnnotatedTopology
 - trees.LoadAnnotatedTopologyAndMap
 - trees.LoadAnnotatedTreeTopology.match_partitions
 - trees.branch_names
 - trees.RootTree
 - trees.ExtractTreeInfo
 - trees.HasBranchLengths
 - trees.BootstrapSupport
 - trees.GetBranchCount
 - trees.SortedBranchLengths
 - trees.BranchNames
 - trees.ParsimonyLabel
 - trees.ParsimonyLabel
 - trees.ConjunctionLabel
 - trees.GenerateSymmetricTree
 - trees.GenerateSymmetricTree
 - trees
 - trees.GenerateRandomTree
 
math.Skewness#
Returns skewness of 1xN vector
Parameters
_data_vectorMatrix 1xN vector
math.Variance#
Returns variance of 1xN vector
Parameters
_data_vectorMatrix 1xN vector
math.Std#
Returns standard deviation of 1xN vector
Parameters
_data_vectorMatrix 1xN vector
math.GatherDescriptiveStats#
Returns suite of statistical information for a 1xN vector
Parameters
_data_vectorMatrix 1xN vector
math.GetIC#
Computes small-sample AIC
Parameters
loglparamssamples
math.HolmBonferroniCorrection#
Returns Holm-Bonferroni corrected p-values
Parameters
psDict a key -> p-value (or null, for not done)
math.BenjaminiHochbergFDR#
Returns Benjamini-Hochberg corrected q-values (FDR)
Parameters
psDict a key -> p-value (or null, for not done)
math.minNormalizedRange#
Returns the range normalized to the lowest value
Returns number
math.DoLRT#
Computes the LRT and p-value
Parameters
lognulllogaltdf
math.Sum#
Computes sum of 1xN vector
Parameters
_data_vectorMatrix 1xN vector
math#
math.Median#
Returns median average of 1xN vector
Parameters
_data_vectorMatrix 1xN vector
math.Int#
Converts a float to integer by rounding
Parameters
float
math.Mean#
Returns mean average of 1xN vector
Parameters
_data_vectorMatrix 1xN vector
math.Kurtosis#
Returns kurtosis of 1xN vector
Parameters
_data_vectorMatrix 1xN vector
matrix#
matrix.Symmetrize#
upper triangle gets copied to lower triangle for non-square matrices, the largest square minor is symmetrized
Parameters
mxMatrix matrix to perform transform on
Returns any nothing
random#
#
Parameters
stringsDict/Matrix set of strings to partition (if Dict, will use the set of VALUES)rexDict/Matrix string matrix of regular expressions (if Dict, will use the set of VALUES)
Returns Dict "reg-exp" : "set of matched strings" (as dict) PLUS a special key ("") which did not match any regular expression
regexp.Split#
Parameters
Returns Dictionary a dictionary containing split strings
regexp#
regexp.Replace#
Parameters
stringStringreString search for this expressionreplString replace each occurence of re with repl
Returns Dictionary a dictionary containing split strings
regexp.Find#
Parameters
Returns String the portion of the string that is matching
regexp.FindSubexpressions#
Parameters
Returns AssociativeList all matched RE subsexpressions
regexp.PartitionByRegularExpressions#
Parameters
stringsDict/Matrix set of strings to partition (if Dict, will use the set of VALUES)rexDict/Matrix string matrix of regular expressions ((if Dict, will use the set of VALUES)
Returns Dict "reg-exp" : "set of matched strings" (as dict) PLUS a special key ("") which did not match any regular expression
models.binary.generic.Time#
Parameters
optiondoes nothing
Returns any default time
models.binary.generic.DefineQMatrix#
Parameters
modelSpecDictionarynamespaceString
models.binary#
models.codon.generate_stencil#
Generates a branch length extraction stencil for synonymous and non-synonymous rates
Parameters
typeString terms.genetic_code.synonymous or terms.genetic_code.nonsynonymous or callbackmodelDictionary the model object
Returns Matrix the appropriate NxN matrix stencil
models.codon.generic.DefineQMatrix#
Parameters
modelSpectnamespace
#
return complete differences between two codons *
models.codon#
models.codon.MapCode#
Parameters
genetic_codeString
Returns Dictionary the sense, stop, and translation-table for the genetic code
models.DNA.generic.Time#
Parameters
optiondoes nothing
Returns any default time
models.DNA.generic.DefineQMatrix#
Parameters
modelSpecDictionarynamespaceString
models.DNA#
frequencies.empirical.binary#
Sets model's equilibrium frequency estimator to ML for binary data
Parameters
modelDictionarynamespaceStringdatafilterDataSetFilter
Returns Dictionary updated model
frequencies.empirical.binary#
Sets model's equilibrium frequency estimator to Binary chatacter 2x1 estimator
Parameters
modelDictionarynamespaceString does nothingdatafilterDataSetFilter does nothing
Returns Dictionary updated model
frequencies.empirical.protein#
Sets model's equilibrium frequency estimator to protein 20x1 estimator
Parameters
modelDictionarynamespaceStringdatafilterDataSetFilter
Returns Dictionary updated model
frequencies.empirical.protein#
Sets model's equilibrium frequency estimator to ML for protein data
Parameters
modelDictionarynamespaceStringdatafilterDataSetFilter
Returns Dictionary updated model
frequencies.empirical.protein#
Multiplies nucleotide frequencies into the empirical codon estimate
Parameters
modelDictionary__estimatesMatrix 4x3 matrix of frequency estimates
Returns Dictionary updated model
frequencies.equal#
Sets model's equilibrium frequency estimator to equal frequencies
Parameters
modelDictionarynamespaceString does nothingdatafilterDataSetFilter does nothing
Returns Dictionary updated model
frequencies.empirical.F3x4#
Parameters
modelDictionarynamespaceStringdatafilterDataSetFilter
Returns Dictionary updated model
frequencies.empirical.F1x4#
Parameters
modelDictionarynamespaceStringdatafilterDataSetFilter
Returns Dictionary updated model
frequencies.empirical.corrected.CF3x4#
Parameters
modelDictionarynamespaceStringdatafilterDataSetFilter
Returns Dictionary updated model
frequencies.mle#
To be implemented
Parameters
modelnamespacedatafilter
frequencies.empirical.nucleotide#
Sets model's equilibrium frequency estimator to Nucleotide 4x1 estimator
Parameters
modelDictionarynamespaceStringdatafilterDataSetFilter
Returns Dictionary updated model
frequencies.empirical.nucleotide#
Compute equilibrium frequencies at run-time using Q inversion
Parameters
modelDictionarynamespaceStringdatafilterDataSetFilter
Returns Dictionary updated model
frequencies#
#
This is an function that computes stationary frequencies of Markov process based on its
rate matrix
Parameters
QMatrix matrix
model.ApplyToBranch#
Parameters
model_idtreebranch
model.define_from_components#
Parameters
id{String} Name of of Modelq{Matrix} instantaneous transition matrixevf{Matrix} the equilibrium frequenciescanonicalNumber matrix exponential
Examples
q = {{*,t,kappa*t,t}
 {t,*,t,t*kappa}
 {t*kappa,t,*,t}
 {t,t*kappa,t,*}};
evf =  {{0.4}{0.3}{0.2}{0.1}};
model.define_from_components(q,evf,1);
Returns any nothing, sets a global {Model}
model.generic.AddLocal#
Parameters
model_specidtag
model.generic.AddGlobal#
Parameters
model_specidtag
model.generic.GetLocalParameter#
Parameters
model_spectag
model.generic.GetLocalParameter#
Parameters
modelModel
Returns String
model.generic.GetGlobalParameter#
Parameters
model_spectag
model.generic.get_a_parameter#
Parameters
model_spectagtype
model.generic.get_rate_variation#
Parameters
model_spectagtype
model.generic.DefineModel#
Parameters
model_specidargumentsdata_filterestimator_type
model.generic.DefineMixtureModel#
Parameters
model_specidargumentsdata_filterestimator_type
model.ApplyModelToTree#
Parameters
id{String}treemodel_listrules
models.generic.ConstrainBranchLength#
Parameters
modelModelorAssociativeList {Number} valueparameterString
Returns any the number of constraints generated (0 or 1)
models.generic.SetBranchLength#
Parameters
modelModelorAssociativeList {Number} valueparameterString
Returns any the number of constraints generated (0 or 1)
models.generic.AttachFilter#
Parameters
modelModelfilterDataSetFilter
Returns any 0
model.Dimension#
Parameters
modelModel
Returns Matrix dimensions of model
model.parameters.Local#
Parameters
modelModel
Returns Matrix local parameters
model.parameters.Global#
Parameters
modelModel
Returns Matrix global parameters
model.MatchAlphabets#
Parameters
a1Matrix first alphabet to comparea2Matrix second alphabet to compare
Returns Number 1 if they are equal, 0 if they are not
#
Parameters
modelsDict list of model objectsfilterRegEx only apply to parameters matching this expression
Returns Dict the set of constraints applied
#
Parameters
modelDict first alphabet to compare
Returns String the branch length expression string
model#
model.GetParameters_RegExp#
Parameters
model{String} - model IDre{String} - regular expression
Returns any a dictionary of global model parameters that match a regexp
parameters.DeclareCategory#
Parameters
defDict category definition components
parameters.NormalizeRatio#
Parameters
Returns any n/d
parameters.SetValue#
Sets value of passed parameter id
Parameters
Returns any nothing
parameters.SetLocalValue#
Sets value of passed parameter tree.branch.id
Parameters
treeString id of treebranchString id of branchidString id of parameter to set value tovalueNumber value to set
Returns any nothing
parameters.SetValues#
Sets value of passed parameter id
Parameters
descdict -> {id : id, mle : value}
Returns any nothing
parameters.ConstrainMeanOfSet#
Ensures that the mean of parameters in a set is maintained
Parameters
setDict/Matrix list of variable idsweightsDict/Matrix weights to applymeanNumber desired meannamespaceString desired mean
Returns any nothing
parameters.UnconstrainParameterSet#
Parameters
lfLikelihoodFunction the likelihood function to operate onsetMatrix set of parameters to unconstrain
Returns any nothing
parameters.Mean#
Returns mean of values
Parameters
valuesMatrix values to return mean ofweightsMatrix weights to multiply values bydNumber does nothing
Returns Number mean
parameters.Quote#
Quotes the argument
Parameters
argString string to be quoted
Returns String string in quotes
parameters.AppendMultiplicativeTerm#
Parameters
Returns String (expression) * (term)
parameters.AddMultiplicativeTerm#
Parameters
matrixMatrix matrix to scaletermNumber scalar to multiply matrix bydo_emptiesNumber if element matrix is empty, fill with term
Returns Matrix New matrix
parameters.StringMatrixToFormulas#
Parameters
idString matrix to scalematrixMatrix if element matrix is empty, fill with term
Returns any nothing
parameters.GenerateAttributedNames#
Parameters
parameters#
parameters.GenerateSequentialNames#
Parameters
Returns Matrix 1 x 
parameters.GetRange#
Parameters
id
Returns any variable range
parameters.SetRange#
Parameters
idranges
Returns any nothing
parameters.DeclareGlobal#
Parameters
idStringcacheMatrix
Returns any nothing
parameters.IsIndependent#
Check if parameter is independent
Parameters
parameterid of parameter to check
Returns Bool TRUE if independent, FALSE otherwise
parameters.SetConstraint#
sets constraint on parameter
Parameters
orString {AssociativeList} id - id(s) of parameter(s) to set constraint onvalueNumber the constraint to set on the parameterglobal_tagString the global namespace of the parameter
Returns any nothing
parameters.SetProprtionalConstraint#
constrain x to be x := C * (current value of x)
Parameters
idString of parameter(s) to set constraint onscalerString variable - the ID of the 'C' scaler variable above; could also be an expression
Returns any nothing
parameters.ConstrainSets#
constraint set of parameters
Parameters
set1AssociativeList -set2AssociativeList -
Returns any nothing
parameters.RemoveConstraint#
Removes a constraint from a parameter
Parameters
idString id of parameter to remove constraint from
Returns any nothing
parameters.helper.copy_definitions#
Copies definitions from target to source
Parameters
targetDictionary the target dictionarysourceDictionary the source element to copy to target
Returns any nothing
pparameters.SetStickBreakingDistribution#
Parameters
parametersAssociativeListvaluesMatrix
Returns any nothing
pparameters.GetStickBreakingDistribution#
Parameters
parametersAssociativeList
Returns Matrix computed distribution (Nx2)
parameters.helper.stick_breaking#
Parameters
parametersAssociativeListinitial_valuesMatrix
Returns any weights
parameters.helper.dump_matrix#
Prints matrix to screen
Parameters
matrixMatrix
Returns any nothing
parameters.helper.tree_lengths_to_initial_values#
Sets tree lengths to initial values
Parameters
dicta [0 to N-1] dictrionary of tree objectstypecodon or nucleotide
Returns Dictionary dictionary of initial branch lengths
parameters.GetProfileCI#
Profiles likelihood function based on covariance precision level
Parameters
idString covariance parameter idlfLikelihoodFunction likelihood function to profilenull-nullNumber Covariance precision level
Returns Dictionary a dictionary containing profiling information
parameters.ExportParameterDefinition#
Geneate an HBL string needed to define a parameter
Parameters
idString the name of the parameter to export;
Returns String the string for an HBL definition of the parameter e.g. "global x := 2.3; x :> 1; x :< 3"; note that the definition will be NOT recursive, so if x depends on y and z, then y and z need to be exported separately
parameters.SetLocalModelParameters#
Copy local parameters from a node to 'template' variables
Parameters
modelDict model descriptiontreeString idnodeString ide.g. set alpha = Tree.Node.alpha set beta = Tree.Node.beta
parameters.SetLocalModelParameters#
Set category variables to their mean values for branch length calculations
Parameters
modelDict model description
parameters.ApplyNameSpace#
Applies a namespace to parameter ids
Parameters
parameters.ValidateID#
Given a set of strings, convert them to valid IDs that don't clash following renames
Parameters
idsArray/Dict the ids to validate (should be unique), if dict, should be i -> ID
Returns Dictionary a dictionary containing old -> new id map
parameters.DeclareGlobalWithRanges#
Parameters
idString variable idinitNumber initial value (could be None)lbNumber lower bound (could be None)ubNumber upper bound (could be None)
Returns any nothing
models.protein.generic.Time#
Parameters
optiondoes nothing
Returns any default time
models.protein#
models.protein.generic.DefineQMatrix#
Parameters
modelSpecDictionarynamespaceString
rate_variation#
alignments.GetSequenceNames#
Get sequence names from existing dataset
Parameters
dataset_nameString name of dataset to get sequence names from
Returns Matrix list of sequence names
alignments.GetSequenceNames#
Get sequence from existing dataset by name
Parameters
dataset_nameString name of dataset to get sequence names fromsequence_name(String | None) the name of the sequence to extract or None to set up the initial mapping
Returns String the corresponding sequence string
alignments.GetIthSequence#
Get i-th sequence name/value from an alignment
Parameters
dataset_nameString name of dataset to get sequence names fromindexString the name of the sequence to extract or None to set up the initial mapping
Returns Dict {"id" : sequence name, "sequence" : sequence data}
alignments.LoadGeneticCode#
Reads dataset from a file path
Parameters
codeString name - name of the genetic code to load, or None to prompt
Returns Dictionary metadata pertaining to the genetic code
alignments.GetIthSequenceOriginalName#
Get i-th sequence name/value from an alignment; retrieve the original sequence name if available
Parameters
dataset_nameString name of dataset to get sequence names fromindexString the name of the sequence to extract or None to set up the initial mapping
Returns Dict {"id" : sequence name, "sequence" : sequence data}
alignments.GetAllSequences#
Get all sequences as "id" : "sequence" dictionary
Parameters
dataset_nameString name of dataset to get sequence names from
Returns Dict { id -> sequence}
alignments.ReadNucleotideDataSet#
Read Nucleotide dataset from file_name
Parameters
dataset_namethe name of the dataset you wish to usefile_namepath to file
Returns Dictionary r - metadata pertaining to the dataset
alignments.FilterType#
Determine what type of data are in the filter
Parameters
filter_nameString the name of the dataset filter object
Returns String one of the standard datatypes, or the alphabet string if it's non-standard
alignments.ReadProteinDataSet#
Read a protein dataset from file_name
Parameters
dataset_namethe name of the dataset you wish to usefile_namepath to file
Returns Dictionary r - metadata pertaining to the dataset
alignments.AlphabetType#
Categorize an alphabet for an alignment
Parameters
alphabetthe alphabet vector, e.g. fetched by GetDataInfo (alphabet, ..., "CHARACTERS");
Returns String one of standard alphabet types or None if unknown
alignments.EnsureMapping#
Ensure that name mapping is not None by creating a f(x)=x map if needed
Parameters
dataset_namethe name of the dataset you wish to userDictionary metadata pertaining to the datasetfile_namepath to file
Returns Dictionary r - metadata pertaining to the dataset
alignments.ReadNucleotideDataSetString#
Read dataset from data
Parameters
Returns Dictionary r - metadata pertaining to the dataset
alignments.PromptForGeneticCodeAndAlignment#
Prompts user for genetic code and alignment
Parameters
dataset_nameString the name of the dataset you wish to usedatafilter_nameString the name of the dataset filter you wish to use
Returns Dictionary r - metadata pertaining to the dataset
alignments.LoadGeneticCodeAndAlignment#
Loads genetic code and alignment from file path
Parameters
dataset_nameString the name of the dataset you wish to usedatafilter_nameString the name of the dataset filter you wish to usepathString path to file
Returns Dictionary r - metadata pertaining to the dataset
alignments.LoadCodonDataFile#
Creates codon dataset filter from data set
Parameters
datafilter_nameString the name of the dataset filter you wish to usedataset_nameString the name of the existing datasetdata_infoDictionary DataSet metadata information
Returns Dictionary updated data_info that includes the number of sites, dataset, and datafilter name
alignments.ReadCodonDataSetFromPath#
Reads dataset from a file path
Parameters
dataset_nameString name of variable you would like to set the dataset topathString path to alignment file
Returns Dictionary r - metadata pertaining to the dataset
alignments.ReadNucleotideAlignment#
Creates nucleotide dataset filter from file
Parameters
file_nameString The location of the alignment filedatafilter_nameString the name of the dataset filter you wish to usedataset_nameString the name of the dataset you wish to use
Returns Dictionary updated data_info that includes the number of sites, dataset, and datafilter name
alignments.CompressDuplicateSequences#
Take an input filter, replace all identical sequences with a single copy Optionally, rename the sequences to indicate copy # by adding ':copies'
Parameters
filter_inString The name of an existing filterfilter_outString the name (to be created) of the filter where the compressed sequences will go)renameBool if true, rename the sequences
Returns any the number of unique sequences
alignments.DefineFiltersForPartitions#
Defines filters for multiple partitions
Parameters
partitionsMatrix a row vector of dictionaries with partition information containing "name" and "filter-string" attributessource_dataDataSet the existing dataset to partition
Returns Matrix filters - a list of newly created dataset filters
alignments.serialize_site_filter#
Parameters
data_filterDataFiltersite_indexNumber
Returns String a string representation of data_filter
alignments.ReadCodonDataSet#
Get metadata from existing dataset
Parameters
dataset_nameid of dataset
Returns Dictionary r - metadata pertaining to the dataset
alignments.ReadCodonDataSetFromPathGivenCode#
Reads a codon dataset from a file path given a genetic code
Parameters
dataset_nameString name of variable you would like to set the dataset topathString path to alignment filecodeMatrix genetic codestop_codonsString the list of stopcodons
Returns Dictionary r - metadata pertaining to the dataset
#
Parameters
sequenceString the string to translateoffsetNumber start at this position (should be in {0,1,2})codeDictionary genetic code description (e.g. returned by alignments.LoadGeneticCode)
Returns String the amino-acid translation ('?' is used to represent ambiguities; 'X' - stop codons)
#
Parameters
sequenceString the string to translateoffsetNumber start at this position (should be in {0,1,2})codeDictionary genetic code description (e.g. returned by alignments.LoadGeneticCode)codelookup resolution lookup dictionary
Returns Dict list of possible amino-acids (as dicts) at this position
#
Parameters
sequenceString the string to translatecodeDictionary genetic code description (e.g. returned by alignments.LoadGeneticCode)codelookup resolution lookup dictionary
Returns Dict for each reading frame F in {0, 1, 2} returnsF -> { terms.data.sequence: translated sequence (always choose X if available, otherwise first sense resolution) terms.sense_codons : N, // number of sense A/A terms.stop_codons : N, // number of stop codons terms.terminal_stop : T/F // true if there is a terminal stop codon }
#
Parameters
sequenceString the string to translate
Returns String the amino-acid translation ('?' is used to represent ambiguities; 'X' - stop codons)
alignments.Extract_site_patterns#
Parameters
data_filterDataFilter
Returns any for a data filter, returns a dictionary like this "pattern id": "sites" : sites (0-based) mapping to this pattern "is_constant" : T/F (is the site constant w/matching ambigs) "0":{ "sites":{ "0":0 }, "is_constant":0 },
    "1":{
      "sites":{
        "0":1
       },
      "is_constant":1
     },...
    "34":{
      "sites":{
        "0":34,
        "1":113
       },
      "is_constant":1
     },
   ...
#
Parameters
sequenceString the input sequence
Returns String the sequence with all gaps removed
#
Parameters
sequenceString the input sequence
Returns String the sequence with all gaps removed
#
Parameters
codon_sequenceString the codon sequence to mapaa_sequenceString the matching aligned a.a. sequencenoNumber more than this many mismatches - the codon sequence to mapmappingDict code ["terms.code.mapping"]
Examples
GCAAAATCATTAGGGACTATGGAAAACAGA
-AKSLGTMEN-R
maps to
---GCAAAATCATTAGGGACTATGGAAAAC---AGA
Returns String the mapped sequence
#
Parameters
filterString filter namebreakPointsMatrix locations of breakpoints (Nx1)treesMatrix tree strings for partitions (Nx1)fileString write the result hereisCodonBool is the filter a codon filter?
Examples
GCAAAATCATTAGGGACTATGGAAAACAGA
-AKSLGTMEN-R
maps to
---GCAAAATCATTAGGGACTATGGAAAAC---AGA
Returns String the mapped sequence
#
ancestral.Sequences#
Parameters
ancestral_dataDictionary the dictionary returned by ancestral.build
Returns any { "Node Name" : {String} inferred ancestral sequence, }
ancestral.ComputeSubstitutionCounts#
Parameters
ancestral_dataDictionary the dictionary returned by ancestral.buildbranch_filterDictionary/Function/None now to determine the subset of branches to count on None -- all branches Dictionary -- all branches that appear as keys in this dict Function -- all branches on which the function (called with branch name) returns 1substitution_filterFunction/None how to decide if the substitution should count None -- different characters (except anything vs a gap) yields a 1 Function -- callback (state1, state2, ancestral_data) will return the valuesite_filterFunction/None how to decide which sites will be kept None -- at least one substitution Function -- callback (substitution vector) will T/F
Returns any { "Branches" : {Matrix Nx1} names of selected branches, "Sites" : {Matrix Sx1} indices of sites passing filter, "Counts" : {Matrix NxS} of substitution counts, }N = number of selected branches S = number of sites passing filter
ancestral#
ancestral.build#
Builds ancestral states
Parameters
Returns any an integer index to reference the opaque structure for subsequent operations
distances.nucleotide.tn93#
Compute all pairwise distances between sequences in a data set
Parameters
filter{String} - id of datasetfreqs{Matrix/null} - if not null, use these nucleotide frequenciesoptions{Dict/null} - options for ambiguity treatment
Returns Matrix r - pairwise TN93 distances
distances.nucleotide.p_distance#
Compute all pairwise percent distances between sequences in a data set
Parameters
filter{String} - id of datasetoptions{Dict/null} - options for ambiguity treatment
Returns Matrix r - pairwise TN93 distances
estimators.FitCodonModel#
Parameters
codon_dataDataFiltertreeTreegenetic_codeStringoptionDictionaryinitial_valuesDictionary
Returns any MGREV results
estimators.FitMGREV#
Parameters
codon_dataDataFiltertreeTreegenetic_codeStringoptionDictionaryinitial_valuesDictionary
Returns any MGREV results
estimators.FitMGREV#
compute the asymptotic (chi^2) p-value for the LRT
Parameters
alternativeNumber log likelihood for the alternative (more general model)NullNumber log likelihood for the nulldfNumber degrees of freedom
Returns any p-value
estimators.ComputeLF#
compute the current value of the log likelihood function
Parameters
lfidString name of the function
Returns any log likelihood
estimators.CreateInitialGrid#
prepare a Dict object suitable for seeding initial LF values
Parameters
valuesDict : "parameter_id" -> {{initial values}} [row matrix], e.g. ... "busted.test.bsrel_mixture_aux_0": { {0.1, 0.25, 0.4, 0.55, 0.7, 0.85, 0.9} }, "busted.test.bsrel_mixture_aux_1": { {0.1, 0.25, 0.4, 0.55, 0.7, 0.85, 0.9} } ...Nint how many points to sampleinitDict/null if not null, taken to be the initial template for variables i.e. random draws will be one index change from this vector
Returns Dict like in{ "0":{ "busted.test.bsrel_mixture_aux_0":{ "ID":"busted.test.bsrel_mixture_aux_0", "MLE":0.4 }, "busted.test.bsrel_mixture_aux_1":{ "ID":"busted.test.bsrel_mixture_aux_1", "MLE":0.7 }, "busted.test.omega1":{ "ID":"busted.test.omega1", "MLE":0.01 }, "busted.test.omega2":{ "ID":"busted.test.omega2", "MLE":0.1 }, "busted.test.omega3":{ "ID":"busted.test.omega3", "MLE":1.5 } } ....
estimators.LHC#
prepare a Dict object suitable for seeding initial LF values based on Latin Hypercube Sampling
Parameters
rangesDict : "parameter_id" -> range, i.e. { lower_bound: 0, upper_bound: 1 }.samplesNumber : the # of samples to draw
estimators.SetGlobals#
Parameters
Returns any nothing
estimators.SetCategory#
Parameters
Returns any nothing
estimators.ExtractBranchInformation.copy_local#
Parameters
estimators.ExtractBranchInformation#
Parameters
Returns Dictionary branch information
estimators.branch_lengths_in_string#
Parameters
Returns String branch lenghts in tree string
estimators.ExtractMLEs#
Parameters
Returns any results
estimators.ExtractMLEsOptions#
Parameters
Returns any results
estimators.TraverseLocalParameters#
Parameters
likelihood_function_idStringmodel_descriptionsDictionarycallbackString (tree, node, parameter_list)
#
Parameters
tree_nameStringmodel_descriptionsDictionaryinitial_valuesMatrixbranch_length_conditions
Returns any number of constrained parameters;
#
Parameters
likelihood_function_idStringmodel_descriptionsDictionaryinitial_valuesMatrixbranch_length_conditions
Returns any estimators.ApplyExistingEstimates.df_correction - Abs(estimators.ApplyExistingEstimates.keep_track_of_proportional_scalers);
estimators.GetGlobalMLE#
Parameters
resultsDictionarytagString
Returns any None
estimators.FitExistingLF#
Fits a LikelihoodFunction
Parameters
model_map
Returns any LF results
estimators.FitLF#
Makes a likelihood function object with the desired parameters
Parameters
data_filters_listMatrix a vector of {DataFilter}stree_listMatrix a vector of {Tree}smodel_mapinitial_values
Returns any LF results
estimators.FitLF#
Fits a LikelihoodFunction
Parameters
data_filters_listMatrix a vector of {DataFilter}stree_listMatrix a vector of {Tree}smodel_mapinitial_values
Returns any LF results
estimators.GetBranchEstimates#
Parameters
Returns any None
estimators.TakeLFStateSnapshot#
Parameters
lf_idString
Returns Dict parameter -> {"MLE" : value, "constraint" : string (if present)}
estimators.GetGlobalMLE_RegExp#
Extract global scope parameter estimates that match a regular expression
Parameters
resultsDictionaryregularString expression to match
Returns Dict parameter description : value (could be empty)
estimators.FitSingleModel_Ext#
Parameters
data_filterDataFiltertreeTreemodelDictinitial_valuesMatrixrun_optionsDict
Returns any results
estimators.FitGTR_Ext#
Parameters
data_filterDataFiltertreeTreeinitial_valuesMatrixrun_optionsDict
Returns any results
estimators.FitGTR#
Parameters
data_filterDataFiltertreeTreeinitial_valuesMatrix
Returns any results
genetic_code.DefineCodonToAAMapping#
genetic_code.DefineCodonToAAMapping
Parameters
codeAssociativeList the nucleotide to codon mapping
Returns any returns ordered codon to amino acid map
genetic_code.DefineCodonToAAMapping#
genetic_code.DefineIntegerToAAMapping
Parameters
codeAssociativeList the nucleotide to codon mappingonly_senseBoolean if true, do not include stop codons in mapping
Returns any returns an integer to AA map { "0" : "K" .. "60" : "F" }
genetic_code.IsStop#
genetic_code.IsStop
Parameters
Returns any whether or not the codon is a stop codon
#
genetic_code.DefineCodonToAAGivenCode#
genetic_code.DefineCodonToAAGivenCode
Parameters
codeAssociativeList the nucleotide to codon mapping
Returns any the amino acid map
genetic_code#
#
trees.infer.NJ#
Infer a neighbor joining tree from a data filter using a specific distance
Parameters
datafilterString the ID of an existing datafilternullnull/String/Matrix , null : use the default distance calculation appropriate for the datatype String : a callback which takes (filter_id, seq1, seq2) arguments and returns d(seq1,seq2) Matrix : a precomputed distance matrix (same order of rows/column as datafilter names)
Returns String inferred tree string
trees.GetTreeString#
Looks for a newick tree in an alignment file
Parameters
look_for_newick_tree(String | Bool) If a string, sanitizes and returns the string. If TRUE, search the alignment file for a newick tree. If FALSE, the user will be prompted for a nwk tree file.
Returns String a newick tree string
trees._matrix2string#
Convert a matrix representation of a tree into Newick
Parameters
matrix_formMatrix : Kx3 matrix; each row represents ?NNumber : number of leavesnamesMatrix/Dict : leaf index -> namedo_lengthsBool : include branch lengths in the output
Returns String newick tree string
trees.PartitionTree#
Partitions a tree by assigning nodes to either being internal or leaf
Parameters
avlDictionary an AVL representation of the tree to be partitioned
Returns any nothing
trees.LoadAnnotatedTopology#
Loads an annatotaed tree topology from a newick tree
Parameters
look_for_newick_tree(String | Bool) If a string, sanitizes and returns the string. If TRUE, search the alignment file for a newick tree. If FALSE, the user will be prompted for a nwk tree file.
Returns Dictionary an annotated tree
trees.LoadAnnotatedTopologyAndMap#
Parameters
dataset_name
Returns Dictionary an annotated tree
trees.LoadAnnotatedTreeTopology.match_partitions#
Loads a tree topology with node name label mappings and annotations from a list of partitions
Parameters
partitionsMatrix a 1xN vector of partition names, typically retrieved from thepartitionskey in the dictionary returned from an alignments parser function.mappingDictionary a mapping of node names to labels
Examples
hky85_nucdata_info = alignments.ReadNucleotideAlignment(file_name, "hky85.nuc_data", "hky85.nuc_filter");
 name_mapping = {
  "HUMAN":"HUMAN",
  "CHIMP":"CHIMP",
  "BABOON":"BABOON",
  "RHMONKEY":"RHMONKEY",
  "COW":"COW",
  "PIG":"PIG",
  "HORSE":"HORSE",
  "CAT":"CAT",
  "MOUSE":"MOUSE",
  "RAT":"RAT"
 };
 trees.LoadAnnotatedTreeTopology.match_partitions(hky85_nucdata_info[terms.json.partitions], name_mapping);
 =>
 {
  "0":{
    "name":"default",
    "filter-string":"",
    "tree": *    }
 }
Returns Dictionary of matched partitions
trees.branch_names#
Parameters
treerespect_case
Returns any result
trees.RootTree#
Parameters
tree_infoDictrootString on this node (or prompt if empty)
Returns any a {Dictionary} (same as ExtractTreeInfo) for the rerooted tree
trees.ExtractTreeInfo#
Parameters
tree_stringString
Returns any a {Dictionary} of the following tree information :- newick string - newick string with branch lengths - annotated string - model map - internal leaves - list of models
trees.HasBranchLengths#
Parameters
treeDictionary information object (e.g. as returned by LoadAnnotatedTopology)
Returns any a {Boolean} to indicate whether the tree has a valid branch length array
trees.BootstrapSupport#
Parameters
treeDictionary information object (e.g. as returned by LoadAnnotatedTopology)
Returns any a {Dictionary} (could be empty or partially filled) with "node name" -> bootstrap support
trees.GetBranchCount#
Gets total branch count of supplied tree
Parameters
tree_stringString
Returns Number total branch count
trees.SortedBranchLengths#
Sorts branch lengths in a descending order
Parameters
tree_stringString
Returns Number total branch count
trees.BranchNames#
Return branch names
Parameters
tree_stringString
Returns Matrix 1xN sorted branch names
trees.ParsimonyLabel#
Compute branch labeling using parsimony
Parameters
treeString IDleafDict -> label labels may be missing for some of the leaves to induce partial labeling of the tree
Returns Dict {"score" : value, "labels" : Internal Branch -> label}
trees.ParsimonyLabel#
Annotate a tree string with using user-specified labels
Parameters
treeString IDnode_nameDict/String -> label OR (if string) (node_name) => name + annotationaString pair of characters to enclose the label innode_nameDict/String -> length OR (if string) (node_name) => length annotation
Returns String annotated string
trees.ConjunctionLabel#
Compute branch labeling using conjunction, i.e. node N is labeled 'X' iff all of the nodes that are in the subtree rooted at 'N' are also labeled 'N'
Parameters
treeString IDleafDict -> label labels may be missing for some of the leaves to induce partial labeling of the tree
Returns Dict {"labeled" : # of labeled internal nodes, "labels" : Internal Branch -> label}
trees.GenerateSymmetricTree#
Generate a symmetric binary tree on N leaves (only perfectly symmetric if N is a power of 2)
Parameters
NNumber : number of leaversrootedBool : whether the tree is rootedbranch_nameNone/String : if a string, then it is assumed to be a function with an integer argument (node index) that generates branch names default is to use numeric namesbranch_lengthNone/String : if a string, then it is assumed to be a function with no arguments that generates branch lengths
Returns String Newick tree string
trees.GenerateSymmetricTree#
Generate a ladder tree on N leaves
Parameters
NNumber : number of leaversrootedBool : whether the tree is rootedbranch_nameNone/String : if a string, then it is assumed to be a function with an integer argument (node index) that generates branch names default is to use numeric namesbranch_lengthNone/String : if a string, then it is assumed to be a function with no arguments that generates branch lengths
Returns String Newick tree string
trees#
trees.GenerateRandomTree#
Generate a RANDOM tree on N leaves
Parameters
NNumber : number of leaversrootedBool : whether the tree is rootedbranch_nameNone/String : if a string, then it is assumed to be a function with an integer argument (node index) that generates branch names default is to use numeric namesbranch_lengthNone/String : if a string, then it is assumed to be a function with no arguments that generates branch lengths
Returns String Newick tree string