def test_valid_no_headers(self): """Test the function with valid Sequences and no variable headers.""" seq1 = Sequence(name='seq1') seq1.set_cont_values([1.0, 2.0, 3.0]) seq2 = Sequence(name='seq2') seq2.set_cont_values([3.0, 3.2, 4.1]) test_sequence_list = [seq1, seq2] mtx = dr.get_character_matrix_from_sequences_list(test_sequence_list) assert isinstance(mtx, Matrix)
def test_valid_with_headers(self): """Test the function with valid Sequences and include headers.""" seq1 = Sequence(name='seq1') seq1.set_cont_values([1.0, 2.0, 3.0]) seq2 = Sequence(name='seq2') seq2.set_cont_values([3.0, 3.2, 4.1]) test_sequence_list = [seq1, seq2] col_headers = ['Val 1', 'Val 2', 'Val 3'] mtx = dr.get_character_matrix_from_sequences_list( test_sequence_list, var_headers=col_headers) assert isinstance(mtx, Matrix) assert mtx.get_column_headers() == col_headers
# try: # # Try looking for the string # label_column = headers.index(args.annotate_labels) # except: # try: # # Treat it as an integer # label_column = int(args.annotate_labels) # except: # raise Exception( # 'Could not find column to use for labels. ' # 'Check the name to make sure it matches or use column' # ' index.') # Convert data to PAM format # TODO: CJG - This should use our Matrix class to read a csv or matrix lmm pam = data_readers.get_character_matrix_from_sequences_list( sequences, headers) # Read the tree tree = TreeWrapper.get(path=args.in_tree_filename, schema=args.in_tree_schema) # Run analysis if args.family_name == 'jaccard': results = phylo_beta_diversity.calculate_phylo_beta_diversity_jaccard( pam, tree) res_names = [ 'beta_jtu', 'phylo_beta_jtu', 'beta_jne', 'phylo_beta_jne', 'beta_jac', 'phylo_beta_jac' ] elif args.family_name == 'sorensen': results = phylo_beta_diversity.calculate_phylo_beta_diversity_sorensen(
if args.annotate_labels is not None: try: # Try looking for the string label_column = headers.index(args.annotate_labels) except Exception: try: # Treat it as an integer label_column = int(args.annotate_labels) except Exception: raise Exception( 'Could not find column to use for labels. ' 'Check the name to make sure it matches or use column' ' index.') # Get character matrix char_mtx = data_readers.get_character_matrix_from_sequences_list( sequences, var_headers=headers) # Run analysis tree, results = anc_dp.calculate_ancestral_distributions(tree, char_mtx) # Should we annotate the tree labels? if label_column is not None: annotators.annotate_tree_with_label(tree, results, label_column=label_column) else: # Annotate tree annotators.add_all_annotations(tree, results, update=True) # Write the tree tree.write(path=args.out_tree_filename, schema=args.out_tree_schema)