Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions Scripts/GenBank/check_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,9 @@ def do_comparison(good_record, test_record):
good_handle = StringIO(good_record)
test_handle = StringIO(test_record)

while True:
good_line = good_handle.readline()
test_line = test_handle.readline()

if not(good_line) and not(test_line):
break

good_line = good_handle.readline()
test_line = test_handle.readline()
while good_line or test_line:
if not(good_line):
if good_line.strip():
raise AssertionError("Extra info in Test: `%s`" % test_line)
Expand All @@ -51,12 +47,16 @@ def do_comparison(good_record, test_record):
assert test_line == good_line, \
"Expected does not match Test.\nExpect:`%s`\nTest :`%s`\n" % \
(good_line, test_line)

good_line = good_handle.readline()
test_line = test_handle.readline()


def write_format(file):
record_parser = GenBank.RecordParser(debug_level=2)

print("Testing GenBank writing for %s..." % os.path.basename(file))

# be able to handle gzipped files
if '.gz' in file:
cur_handle = gzip.open(file, "r")
Expand All @@ -68,22 +68,19 @@ def write_format(file):
iterator = GenBank.Iterator(cur_handle, record_parser)
compare_iterator = GenBank.Iterator(compare_handle)

while True:
cur_record = next(iterator)
compare_record = next(compare_iterator)

if cur_record is None or compare_record is None:
break

# print("\tTesting for %s" % cur_record.version)

cur_record = next(iterator)
compare_record = next(compare_iterator)
while cur_record != None and compare_record != None:
output_record = str(cur_record) + "\n"
try:
do_comparison(compare_record, output_record)
except AssertionError as msg:
print("\tTesting for %s" % cur_record.version)
print(msg)

cur_record = next(iterator)
compare_record = next(compare_iterator)

cur_handle.close()
compare_handle.close()

Expand Down