def test_main_1(tmpdir, capsys): # test_dir = os.path.join(helpers.get_test_data_dir(), 'gfa-1') gfa_graph = mod.GFAGraph() gfa_graph.add_node('node1', 7, 'ACTGAAA', tags={}, labels={}) gfa_graph.add_node('node2', 10, 'AAACCCGGGT', tags={}, labels={}) gfa_graph.add_edge('edge1', 'node1', '+', 'node2', '+', 4, 7, 0, 3, '*', tags={}, labels={}) gfa_graph.add_path('000000F', ['node1', 'node2'], ['4M', '7M'], tags={}, labels={}) gfa_json_file = tmpdir.join('graph.gfa.json') gfa_json_file.write(mod.serialize_gfa(gfa_graph)) argv = ['prog', str(gfa_json_file), ] mod.main(argv) out, err = capsys.readouterr() expected = """H VN:Z:1.0 S node1 ACTGAAA LN:i:7 S node2 AAACCCGGGT LN:i:10 L node1 + node2 + 3M P 000000F node1,node2 4M,7M """ # Custom tags can be in an arbitrary order and hard to compare. # They might also change between versions, so just remove # them manually here and compare only the important fields. result = [] for line in out.splitlines(): line = line.strip() sl = line.split() if len(line) == 0: continue if line[0] == 'H': result.append('\t'.join(sl[0:2])) elif line[0] == 'S': result.append('\t'.join(sl[0:4])) elif line[0] == 'L': result.append('\t'.join(sl[0:6])) elif line[0] == 'P': result.append('\t'.join(sl[0:4])) result_str = '\n'.join(result) + '\n' assert(result_str == expected)
def test_main_6(capsys): test_dir = os.path.join(helpers.get_test_data_dir(), 'gfa-1') argv = [ 'prog', '--p-ctg-tiling-path', os.path.join(test_dir, 'p_ctg_tiling_path'), '--a-ctg-tiling-path', os.path.join(test_dir, 'a_ctg_tiling_path'), '--preads-fasta', os.path.join(test_dir, 'preads4falcon.fasta'), '--p-ctg-fasta', os.path.join(test_dir, 'p_ctg.fa'), '--a-ctg-fasta', os.path.join(test_dir, 'a_ctg.fa'), '--sg-edges-list', os.path.join(test_dir, 'sg_edges_list'), '--utg-data', os.path.join(test_dir, 'utg_data'), '--ctg-paths', os.path.join(test_dir, 'ctg_paths'), '--tiling', # '--write-reads', # '--write-contigs', '--min-p-len', '10000', '--min-a-len', '10000', ] mod.main(argv) out, err = capsys.readouterr() result = out.strip().splitlines() expected = [ line.strip() for line in open(os.path.join( test_dir, 'expected-6-tiling-no_r-no_c-minlen.gfa')).readlines() ] assert (result == expected)
def test_main_2(capsys): test_dir = os.path.join(helpers.get_test_data_dir(), 'gfa-1') argv = ['prog', '--p-ctg-tiling-path', os.path.join(test_dir, 'p_ctg_tiling_path'), '--a-ctg-tiling-path', os.path.join(test_dir, 'a_ctg_tiling_path'), '--preads-fasta', os.path.join(test_dir, 'preads4falcon.fasta'), '--p-ctg-fasta', os.path.join(test_dir, 'p_ctg.fa'), '--a-ctg-fasta', os.path.join(test_dir, 'a_ctg.fa'), '--sg-edges-list', os.path.join(test_dir, 'sg_edges_list'), '--utg-data', os.path.join(test_dir, 'utg_data'), '--ctg-paths', os.path.join(test_dir, 'ctg_paths'), # '--add-string-graph', '--write-reads', '--write-contigs', '--min-p-len', '0', '--min-a-len', '0', ] mod.main(argv) out, err = capsys.readouterr() expected_path = os.path.join(test_dir, 'expected-2-tiling-r-c.gfa') helpers.assert_filecmp(out, expected_path)
def test_help(): try: mod.main(['prog', '--help']) except SystemExit: pass
def test_help(): try: mod.main(['prog', '--help']) except SystemExit: pass