def test_with_comments(self): fasta = BytesIO( dedent(""" # a comment # another one >first_sequence SEQUENCE1 >second_sequence SEQUENCE2 """).encode()) reads = list(FastaReader(fasta)) assert reads == simple_fasta
def test_wrong_format(self): fasta = BytesIO( dedent("""# a comment # another one unexpected >first_sequence SEQUENCE1 >second_sequence SEQUENCE2 """).encode()) with raises(FastaFormatError) as info: list(FastaReader(fasta)) assert info.value.line == 2
def test_fastareader_keeplinebreaks(self): with FastaReader("tests/data/simple.fasta", keep_linebreaks=True) as f: reads = list(f) assert reads[0] == simple_fasta[0] assert reads[1].sequence == 'SEQUEN\nCE2'
def test_bytesio(self): fasta = BytesIO( b">first_sequence\nSEQUENCE1\n>second_sequence\nSEQUENCE2\n") reads = list(FastaReader(fasta)) assert reads == simple_fasta
def test_file(self): with FastaReader("tests/data/simple.fasta") as f: reads = list(f) assert reads == simple_fasta