def test_select_translatable(self): """correctly get translatable seqs""" data = { "a": "AATATAAATGCCAGCTCATTACAGCATGAGAACA" "GCAGTTTATTACTTCATAAAGTCATA", "rc": "TATGACTTTATGAAGTAATAAACTGCTGTTCTCA" "TGCTGTAATGAGCTGGCATTTATATT", } seqs = make_unaligned_seqs(data=data, moltype=DNA) trans = select_translatable(allow_rc=False) tr = trans(seqs) ex = data.copy() ex.pop("rc") self.assertEqual(tr.to_dict(), ex) trans = select_translatable(allow_rc=True) tr = trans(seqs) ex = data.copy() ex["rc"] = data["a"] self.assertEqual(tr.to_dict(), ex) # if seqs not translatable returns NotCompletedResult data = dict(a="TAATTGATTAA", b="GCAGTTTATTA") seqs = make_unaligned_seqs(data=data, moltype=DNA) got = select_translatable(allow_rc=False) self.assertTrue(type(got), NotCompleted)
def _get_all_composables(tmp_dir_name): test_model1 = evo.model("HKY85") test_model2 = evo.model("GN") test_hyp = evo.hypothesis(test_model1, test_model2) test_num_reps = 100 applications = [ align.align_to_ref(), align.progressive_align(model="GY94"), evo.ancestral_states(), evo.bootstrap(hyp=test_hyp, num_reps=test_num_reps), evo.hypothesis(test_model1, test_model2), evo.model("GN"), evo.tabulate_stats(), sample.fixed_length(100), sample.min_length(100), io.write_db(tmp_dir_name, create=True), io.write_json(tmp_dir_name, create=True), io.write_seqs(tmp_dir_name, create=True), sample.omit_bad_seqs(), sample.omit_degenerates(), sample.omit_duplicated(), sample.take_codon_positions(1), sample.take_named_seqs(), sample.trim_stop_codons(gc=1), translate.select_translatable(), tree.quick_tree(), tree.scale_branches(), tree.uniformize_tree(), ] return applications
def test_str(self): """str representation correctly represents parameterisations""" func = select_translatable() got = str(func) self.assertEqual( got, "select_translatable(type='sequences', " "moltype='dna', gc='Standard Nuclear', " "allow_rc=False, trim_terminal_stop=True)", ) func = select_translatable(allow_rc=True) got = str(func) self.assertEqual( got, "select_translatable(type='sequences', " "moltype='dna', gc='Standard Nuclear', " "allow_rc=True, trim_terminal_stop=True)", ) nodegen = omit_degenerates() got = str(nodegen) self.assertEqual( got, "omit_degenerates(type='aligned', moltype=None, " "gap_is_degen=True, motif_length=1)", ) ml = min_length(100) got = str(ml) self.assertEqual( got, "min_length(type='sequences', length=100, " "motif_length=1, subtract_degen=True, " "moltype=None)", ) qt = quick_tree() self.assertEqual(str(qt), "quick_tree(type='tree', drop_invalid=False)")
def test_composite_pickleable(self): """composable functions should be pickleable""" from pickle import dumps from cogent3.app import io, sample, evo, tree, translate, align read = io.load_aligned(moltype="dna") dumps(read) trans = translate.select_translatable() dumps(trans) aln = align.progressive_align("nucleotide") dumps(aln) just_nucs = sample.omit_degenerates(moltype="dna") dumps(just_nucs) limit = sample.fixed_length(1000, random=True) dumps(limit) mod = evo.model("HKY85") dumps(mod) qt = tree.quick_tree() dumps(qt) proc = read + trans + aln + just_nucs + limit + mod dumps(proc)