def test_solve_inc(self): m_eval, c_eval, k1_eval, tree_eval = phyl.solve_incomplete_phylogeny(m1,s1,c1) k1 = phyl.get_k1_matrix(m_eval,c_eval) self.assertTrue(np.all(m_exp==m_eval)) self.assertTrue(np.all(k1_exp==k1_eval)) self.assertTrue(np.all(tree_exp==tree_eval)) self.assertTrue(phyl.perfect_phylogeny_exists(k1,c_eval))
def test_solve_inc(self): m_eval, c_eval, k1_eval, tree_eval = phyl.solve_incomplete_phylogeny( m1, s1, c1) k1 = phyl.get_k1_matrix(m_eval, c_eval) self.assertTrue(np.all(m_exp == m_eval)) self.assertTrue(np.all(k1_exp == k1_eval)) self.assertTrue(np.all(tree_exp == tree_eval)) self.assertTrue(phyl.perfect_phylogeny_exists(k1, c_eval))
''' import argparse import numpy as np from perfect_phylogeny import phylogeny as phyl parser = argparse.ArgumentParser(prefix_chars='--') parser.add_argument('m_file',help='Matrix file') parser.add_argument('outname',nargs='?',default='tree',help='Output name') parser.add_argument('--plot',dest='plot',action='store_true',help='Plot output (if valid phylogeny). Requires Graphviz.') args = parser.parse_args() m_file = args.m_file outname = args.outname plot = args.plot if __name__ == '__main__': m_txt = np.genfromtxt(m_file,delimiter='\t',dtype=None,invalid_raise=False) s = np.array(m_txt[1:,0],dtype='S100') # row names/samples c = np.array(m_txt[0,1:],dtype='S100') # column names/features m = np.array(m_txt[1:,1:],dtype=int) # matrix values m_new, c_prime, k1, tree = phyl.solve_incomplete_phylogeny(m,s,c) k1 = phyl.get_k1_matrix(m_new,c_prime) if phyl.perfect_phylogeny_exists(k1,c_prime) and plot: print('Plotting tree...') phyl.write_dot(k1,s,outname)
def test_no_phyl(self): m_eval, c_eval = phyl.get_m_prime(m2,c2) k1 = phyl.get_k1_matrix(m_eval,c_eval) self.assertTrue(np.all(k1_nophyl==k1)) self.assertFalse(phyl.perfect_phylogeny_exists(k1,c_eval))
parser.add_argument('m_file', help='Matrix file') parser.add_argument('outname', nargs='?', default='tree', help='Output name') parser.add_argument( '--plot', dest='plot', action='store_true', help='Plot output (if valid phylogeny). Requires Graphviz.') args = parser.parse_args() m_file = args.m_file outname = args.outname plot = args.plot if __name__ == '__main__': m_txt = np.genfromtxt(m_file, delimiter='\t', dtype=None, invalid_raise=False) s = np.array(m_txt[1:, 0], dtype='S100') # row names/samples c = np.array(m_txt[0, 1:], dtype='S100') # column names/features m = np.array(m_txt[1:, 1:], dtype=int) # matrix values m_new, c_prime, k1, tree = phyl.solve_incomplete_phylogeny(m, s, c) k1 = phyl.get_k1_matrix(m_new, c_prime) if phyl.perfect_phylogeny_exists(k1, c_prime) and plot: print('Plotting tree...') phyl.write_dot(k1, s, outname)
def test_no_phyl(self): m_eval, c_eval = phyl.get_m_prime(m2, c2) k1 = phyl.get_k1_matrix(m_eval, c_eval) self.assertTrue(np.all(k1_nophyl == k1)) self.assertFalse(phyl.perfect_phylogeny_exists(k1, c_eval))