def test_equivalent_different_deflines_ignore(tmpdir, capsys): """Verify the correct message when different sequence descriptions, but deflines are ignored.""" seq_strings = ['A' * 1] path1 = write_fasta(seq_strings, tmpdir, "file1", '1') seq_strings = ['A' * 1] path2 = write_fasta(seq_strings, tmpdir, "file2", '2') fastatools.equivalent(path1, path2, ignore_defline=True) captured = capsys.readouterr() assert (captured.out == "Equivalent\n")
def test_equivalent_different_contents(tmpdir, capsys): """Verify the correct message when different sequence contents.""" seq_strings = ['A' * 10] path1 = write_fasta(seq_strings, tmpdir, "file1") seq_strings = ['T' * 10] path2 = write_fasta(seq_strings, tmpdir, "file2") fastatools.equivalent(path1, path2, ignore_defline=False) captured = capsys.readouterr() assert (captured.out == 'Not equivalent -- sequence 1 has different contents.\n')
def test_equivalent_different_num_sequences(tmpdir, capsys): """Verify the correct message when different number of sequences.""" seq_strings = ['A' * 1, 'T' * 10, 'C' * 100] path1 = write_fasta(seq_strings, tmpdir, "A1.T10.C100") seq_strings = ['A' * 1, 'T' * 10, 'C' * 100, 'G' * 1000] path2 = write_fasta(seq_strings, tmpdir, "A2.T20.C200.G2000") fastatools.equivalent(path1, path2) captured = capsys.readouterr() assert ( captured.out == "Not equivalent -- the number of sequences is different (3 and 4).\n")
def test_equivalent_different_deflines(tmpdir, capsys): """Verify the correct message when different sequence descriptions.""" seq_strings = ['A' * 1] path1 = write_fasta(seq_strings, tmpdir, "file1", '1') seq_strings = ['A' * 1] path2 = write_fasta(seq_strings, tmpdir, "file2", '2') fastatools.equivalent(path1, path2, ignore_defline=False) captured = capsys.readouterr() assert ( captured.out == 'Not equivalent -- sequence 1 has different descriptions ("Id11 Description11" and "Id21 Description21").\n' )
def test_equivalent_ignore_order(tmpdir, capsys): """Verify the sequences can be in different order""" seq_strings = ['A' * 10, 'T' * 100] path1 = write_fasta(seq_strings, tmpdir, "file1") seq_strings = ['T' * 100, 'A' * 10] path2 = write_fasta(seq_strings, tmpdir, "file2") fastatools.equivalent(path1, path2, ignore_defline=True, enforce_order=False) captured = capsys.readouterr() assert (captured.out == "Equivalent\n")
def test_equivalent_enforce_order(tmpdir, capsys): """Verify the sequences must be in the same order""" seq_strings = ['A' * 10, 'T' * 100] path1 = write_fasta(seq_strings, tmpdir, "file1") seq_strings = ['T' * 100, 'A' * 10] path2 = write_fasta(seq_strings, tmpdir, "file2") fastatools.equivalent(path1, path2, ignore_defline=True, enforce_order=True) captured = capsys.readouterr() assert ( captured.out == 'Not equivalent -- sequence 1 has different lengths (10 and 100).\n' 'Not equivalent -- sequence 2 has different lengths (100 and 10).\n')
def equivalent_command(args): """Determine if two sequences are equivalent, ignoring the line lengths and uppercase / lowercase characters. Parameters ---------- args : Namespace Command line arguments stored as attributes of a Namespace, usually parsed from sys.argv """ return fastatools.equivalent(args.fasta_path1, args.fasta_path2, ignore_defline=args.ignore_defline, enforce_order=args.enforce_order)