File: check_output_simple.py

package info (click to toggle)
python-biopython 1.78%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 65,756 kB
  • sloc: python: 221,141; xml: 178,777; ansic: 13,369; sql: 1,208; makefile: 131; sh: 70
file content (58 lines) | stat: -rw-r--r-- 1,675 bytes parent folder | download
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
57
58
#!/usr/bin/env python
# Copyright 2000 Brad Chapman.  All rights reserved.
#
# This code is part of the Biopython distribution and governed by its
# license.  Please see the LICENSE file that should have been included
# as part of this package.

"""Display the SeqFeatures produced by the parser.

This produces a ton of output so it is possible to hand check what is
produced by the parser with the original GenBank file to make sure
everything is being parsed and output properly.

Usage:
./check_output.py <GenBank file to parse>

"""
# standard library

import sys

# GenBank stuff to test
from Bio import GenBank


if len(sys.argv) != 2:
    print("Usage ./check_output.py <GenBank file to parse>")
    sys.exit()

parser = GenBank.FeatureParser(debug_level=2)

with open(sys.argv[1]) as handle:

    iterator = GenBank.Iterator(handle, parser)

    while True:
        cur_record = next(iterator)

        if not cur_record:
            break

        print("***Record")
        print(f"Seq: {cur_record.seq}")
        print(f"Id: {cur_record.id}")
        print(f"Name: {cur_record.name}")
        print(f"Description: {cur_record.description}")
        print("Annotations****")
        for annotation_key in cur_record.annotations:
            if annotation_key != "references":
                print(f"Key: {annotation_key}")
                print(f"Value: {cur_record.annotations[annotation_key]}")
            else:
                print("References*")
                for reference in cur_record.annotations[annotation_key]:
                    print(str(reference))
        print("Feaures")
        for feature in cur_record.features:
            print(feature)