Back to index

python-biopython  1.60
check_output_simple.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 """Display the SeqFeatures produced by the parser.
00003 
00004 This produces a ton of output so it is possible to hand check what is
00005 produced by the parser with the original GenBank file to make sure
00006 everything is being parsed and output properly.
00007 
00008 Usage:
00009 ./check_output.py <GenBank file to parse>
00010 
00011 """
00012 # standard library
00013 import sys
00014 
00015 # GenBank stuff to test
00016 from Bio import GenBank
00017 
00018 if len(sys.argv) != 2:
00019     print "Usage ./check_output.py <GenBank file to parse>"
00020     sys.exit()
00021 
00022 parser = GenBank.FeatureParser(debug_level = 2)
00023 
00024 handle = open(sys.argv[1], 'r')
00025 
00026 iterator = GenBank.Iterator(handle, parser)
00027 
00028 while 1:
00029     cur_record = iterator.next()
00030 
00031     if not(cur_record):
00032         break
00033     
00034     print "***Record"
00035     print "Seq:", cur_record.seq
00036     print "Id:", cur_record.id
00037     print "Name:", cur_record.name
00038     print "Description", cur_record.description
00039     print "Annotations****"
00040     for annotation_key in cur_record.annotations.keys():
00041         if annotation_key != 'references':
00042             print "Key: %s" % annotation_key
00043             print "Value: %s" % cur_record.annotations[annotation_key]
00044         else:
00045             print "References*"
00046             for reference in cur_record.annotations[annotation_key]:
00047                 print str(reference)
00048     print "Feaures"
00049     for feature in cur_record.features:
00050         print feature
00051 
00052 handle.close()
00053     
00054 
00055