forked from biopython/biopython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_parser_problems.py
More file actions
58 lines (42 loc) · 1.35 KB
/
Copy pathfind_parser_problems.py
File metadata and controls
58 lines (42 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
"""Find GenBank records that the parser has problems with within a big file.
This is meant to make it easy to get accession numbers for records that
don't parse properly.
Usage:
find_parser_problems.py <GenBank file to parse>
"""
# standard library
import sys
# GenBank
from Bio import GenBank
verbose = 0
if len(sys.argv) != 2:
print "Usage ./find_parser_problems <GenBank file to parse>"
sys.exit()
feature_parser = GenBank.FeatureParser(debug_level = 0)
parser = GenBank.ErrorParser(feature_parser)
handle = open(sys.argv[1], 'r')
iterator = GenBank.Iterator(handle, parser, has_header = 1)
while 1:
have_record = 0
while have_record == 0:
try:
cur_record = iterator.next()
have_record = 1
except GenBank.ParserFailureError, msg:
print "Parsing Problem:", msg
sys.exit()
if cur_record is None:
break
print "Successfully parsed record", cur_record.id
if verbose:
print "***Record"
print "Seq:", cur_record.seq
print "Id:", cur_record.id
print "Name:", cur_record.name
print "Description", cur_record.description
print "Annotations", cur_record.annotations
print "Feaures"
for feature in cur_record.features:
print feature
handle.close()