def test_consensus(): """ Consensus sequences have a different name format. They also need to have the parentheses replaced by brackets so they don't get dropped from the tree file. """ raw_hcv = StringIO("""\ >Ref.CON_1a(142) ACTAGGA GAGATTT >Ref.2b.Bar TAGACT """) filtered_hcv = StringIO() expected_filtered_hcv = """\ >Ref.CON_1a[142]-1a ACTAGGA GAGATTT >Ref.2b.Bar-2b TAGACT """ filter_hcv_fasta(raw_hcv, filtered_hcv) assert expected_filtered_hcv == filtered_hcv.getvalue()
def test_consensus(): """ Consensus sequences have a different name format. They also need to have the parentheses replaced by brackets so they don't get dropped from the tree file. """ raw_hcv = StringIO("""\ >Ref.CON_1a(142) ACTAGGA GAGATTT >Ref.2b.Bar TAGACT """) filtered_hcv = StringIO() expected_filtered_hcv = """\ >Ref.CON_1a[142]-1a ACTAGGA GAGATTT >Ref.2b.Bar-2b TAGACT """ filter_hcv_fasta(raw_hcv, filtered_hcv) assert expected_filtered_hcv == filtered_hcv.getvalue()
def test_filter_duplicates(): raw_hcv = StringIO("""\ >Ref.1a.Foo ACTAGGA GAGATTT >Ref.2b.Bar TAGACT >Ref.1a.Foo AAA """) filtered_hcv = StringIO() expected_filtered_hcv = """\ >Ref.1a.Foo-1a ACTAGGA GAGATTT >Ref.2b.Bar-2b TAGACT """ expected_invalid_headers = ['>Ref.1a.Foo (duplicate)'] invalid_headers = filter_hcv_fasta(raw_hcv, filtered_hcv) assert expected_filtered_hcv == filtered_hcv.getvalue() assert expected_invalid_headers == invalid_headers
def test_filter_duplicates(): raw_hcv = StringIO("""\ >Ref.1a.Foo ACTAGGA GAGATTT >Ref.2b.Bar TAGACT >Ref.1a.Foo AAA """) filtered_hcv = StringIO() expected_filtered_hcv = """\ >Ref.1a.Foo-1a ACTAGGA GAGATTT >Ref.2b.Bar-2b TAGACT """ expected_invalid_headers = ['>Ref.1a.Foo (duplicate)'] invalid_headers = filter_hcv_fasta(raw_hcv, filtered_hcv) assert expected_filtered_hcv == filtered_hcv.getvalue() assert expected_invalid_headers == invalid_headers
def test_add_subtype(): raw_hcv = StringIO("""\ >Ref.1a.Foo ACTAGGA GAGATTT >Ref.2b.Bar TAGACT """) filtered_hcv = StringIO() expected_filtered_hcv = """\ >Ref.1a.Foo-1a ACTAGGA GAGATTT >Ref.2b.Bar-2b TAGACT """ filter_hcv_fasta(raw_hcv, filtered_hcv) assert expected_filtered_hcv == filtered_hcv.getvalue()
def test_add_subtype(): raw_hcv = StringIO("""\ >Ref.1a.Foo ACTAGGA GAGATTT >Ref.2b.Bar TAGACT """) filtered_hcv = StringIO() expected_filtered_hcv = """\ >Ref.1a.Foo-1a ACTAGGA GAGATTT >Ref.2b.Bar-2b TAGACT """ filter_hcv_fasta(raw_hcv, filtered_hcv) assert expected_filtered_hcv == filtered_hcv.getvalue()
def test_filter_missing_subtype(): raw_hcv = StringIO("""\ >Ref.1a.Foo ACTAGGA GAGATTT >Ref.2.Bar TAGACT """) filtered_hcv = StringIO() expected_filtered_hcv = """\ >Ref.1a.Foo-1a ACTAGGA GAGATTT """ expected_invalid_headers = ['>Ref.2.Bar'] invalid_headers = filter_hcv_fasta(raw_hcv, filtered_hcv) assert expected_filtered_hcv == filtered_hcv.getvalue() assert expected_invalid_headers == invalid_headers
def test_filter_missing_subtype(): raw_hcv = StringIO("""\ >Ref.1a.Foo ACTAGGA GAGATTT >Ref.2.Bar TAGACT """) filtered_hcv = StringIO() expected_filtered_hcv = """\ >Ref.1a.Foo-1a ACTAGGA GAGATTT """ expected_invalid_headers = ['>Ref.2.Bar'] invalid_headers = filter_hcv_fasta(raw_hcv, filtered_hcv) assert expected_filtered_hcv == filtered_hcv.getvalue() assert expected_invalid_headers == invalid_headers
def test_filter_exclusions(): raw_hcv = StringIO("""\ >Ref.1a.Foo ACTAGGA GAGATTT >Ref.2b.Bar TAGACT """) excluded = ['Bar'] filtered_hcv = StringIO() expected_filtered_hcv = """\ >Ref.1a.Foo-1a ACTAGGA GAGATTT """ expected_invalid_headers = ['>Ref.2b.Bar (excluded)'] invalid_headers = filter_hcv_fasta(raw_hcv, filtered_hcv, excluded) assert expected_filtered_hcv == filtered_hcv.getvalue() assert expected_invalid_headers == invalid_headers
def test_filter_exclusions(): raw_hcv = StringIO("""\ >Ref.1a.Foo ACTAGGA GAGATTT >Ref.2b.Bar TAGACT """) excluded = ['Bar'] filtered_hcv = StringIO() expected_filtered_hcv = """\ >Ref.1a.Foo-1a ACTAGGA GAGATTT """ expected_invalid_headers = ['>Ref.2b.Bar (excluded)'] invalid_headers = filter_hcv_fasta(raw_hcv, filtered_hcv, excluded) assert expected_filtered_hcv == filtered_hcv.getvalue() assert expected_invalid_headers == invalid_headers