def test_getParamList(self): """testing getting the parameter list""" model = substitution_model.Nucleotide() self.assertEqual(model.getParamList(), []) model = substitution_model.Nucleotide(predicates=['beta:transition']) self.assertEqual(model.getParamList(), ['beta'])
def test_isIndel(self): """testing indel comparison nucleotide model""" model = substitution_model.Nucleotide(do_scaling=True, model_gaps=True) isIndel = model.getPredefinedPredicate('indel') assert isIndel('A', '-') assert isIndel('-', 'G') #assert not self.submodel.isIndel('-', '-') assert not isIndel('a', 't')
def GTR(**kw): """General Time Reversible nucleotide substitution model.""" return substitution_model.Nucleotide( motif_probs = None, do_scaling = True, model_gaps = False, recode_gaps = True, name = 'GTR', predicates = _gtr_preds, **kw)
# specify the 4 taxon tree, and a 'dummy' alignment t = tree.LoadTree(treestring='(a:0.4,b:0.3,(c:0.15,d:0.2)edge.0:0.1)root;') #al = alignments.LoadSeqs(data={'a':'a','b':'a','c':'a','d':'a'}) # how long the simulated alignments should be # at 1000000 the estimates get nice and close length_of_align = 10000 ######################### # # For a Jukes Cantor model # ######################### sm = substitution_model.Nucleotide() lf = sm.makeLikelihoodFunction(t) lf.setConstantLengths() lf.setName('True JC model') print lf simulated = lf.simulateAlignment(sequence_length=length_of_align) print simulated new_lf = sm.makeLikelihoodFunction(t) new_lf = new_lf.setAlignment(simulated) new_lf.optimise(tolerance=1.0) new_lf.optimise(local=True) new_lf.setName('True JC model') print new_lf #########################
def _makeModel(self, do_scaling, predicates, scale_rules=[]): return substitution_model.Nucleotide(do_scaling=do_scaling, equal_motif_probs=True, model_gaps=False, predicates=predicates, scales=scale_rules)
def getsubmod(self, choice='F81'): if choice == 'F81': return substitution_model.Nucleotide(model_gaps=True) else: return substitution_model.Nucleotide( model_gaps=True, predicates={'kappa': 'transition'})
def setUp(self): self.submodel = substitution_model.Nucleotide(do_scaling=True, model_gaps=False)
def test_getMotifs(self): """testing return of motifs""" model_motifs = substitution_model.Nucleotide().getMotifs()
def test_includinggaps(self): """testing excluding gaps from model""" model = substitution_model.Nucleotide(model_gaps=True) assert len(model.getAlphabet()) == 5
def setUp(self): self.submodel = substitution_model.Nucleotide(motif_length=3, mprob_model='tuple')