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_write_seqs(self): """correctly writes sequences out""" fasta_paths = list(io_app.findall(self.basedir, suffix=".fasta", limit=2)) fasta_loader = io_app.load_aligned(format="fasta") alns = list(map(fasta_loader, fasta_paths)) with TemporaryDirectory(dir=".") as dirname: writer = io_app.write_seqs(dirname, if_exists="ignore") wrote = list(map(writer, alns)) written = list(io_app.findall(dirname, suffix="fasta")) for i, wrote in enumerate(written): self.assertEqual(alns[i].info.stored, join(dirname, wrote))
def _get_all_composable_apps(): applications = [ align.align_to_ref(), align.progressive_align(model="GY94"), sample.fixed_length(100), sample.min_length(100), io.write_seqs(os.getcwd()), sample.omit_bad_seqs(), sample.omit_degenerates(), sample.take_codon_positions(1), sample.take_named_seqs(), sample.trim_stop_codons(gc=1), ] return applications
def test_checkpointable(self): """chained funcs should be be able to apply a checkpoint""" path = "data" + os.sep + "brca1.fasta" reader = io_app.load_aligned(moltype="dna") omit_degens = sample_app.omit_degenerates(moltype="dna") with TemporaryDirectory(dir=".") as dirname: writer = io_app.write_seqs(dirname) aln = reader(path) outpath = writer(aln) read_write = reader + writer got = read_write(path) # should skip reading and return path self.assertEqual(got, outpath) read_write.disconnect() # allows us to reuse bits read_write_degen = reader + writer + omit_degens # should return an alignment instance got = read_write_degen(path) self.assertIsInstance(got, ArrayAlignment) self.assertTrue(len(got) > 1000)