Skip to content

Commit

Permalink
-Fixed #24
Browse files Browse the repository at this point in the history
  • Loading branch information
kwade4 committed Aug 15, 2019
1 parent 079a07d commit c24bfb9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 9 additions & 0 deletions poplars/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ def convert_fasta(handle):
"""
result = []
sequence, h = '', ''

# Verifies files have correct formatting
ln = handle.readline()
if ln.startswith('$'):
ln = handle.readline()
if not (ln.startswith('>') or ln.startswith('#')):
print('Invalid FASTA format')
raise NameError

for line in handle:
if line.startswith('$'): # skip header line
continue
Expand Down
3 changes: 1 addition & 2 deletions poplars/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from io import StringIO
from poplars.common import convert_fasta


class TestConvertFasta(unittest.TestCase):
def testSimpleConversion(self):
# create file stream as test fixture
Expand All @@ -26,5 +27,3 @@ def testMultilineConversion(self):
['b', 'GCTAAAAAAAAA']
]
self.assertEqual(expected, result)


0 comments on commit c24bfb9

Please sign in to comment.