# Bio.GenBank package

## Submodules

- Bio.GenBank.Record module
  - `Record`
    - `Record.GB_LINE_LENGTH`
    - `Record.GB_BASE_INDENT`
    - `Record.GB_FEATURE_INDENT`
    - `Record.GB_INTERNAL_INDENT`
    - `Record.GB_OTHER_INTERNAL_INDENT`
    - `Record.GB_FEATURE_INTERNAL_INDENT`
    - `Record.GB_SEQUENCE_INDENT`
    - `Record.BASE_FORMAT`
    - `Record.INTERNAL_FORMAT`
    - `Record.OTHER_INTERNAL_FORMAT`
    - `Record.BASE_FEATURE_FORMAT`
    - `Record.INTERNAL_FEATURE_FORMAT`
    - `Record.SEQUENCE_FORMAT`
    - `Record.__init__()`
    - `Record.__str__()`
    - `Record.__annotations_cache__`
    - `Record.__firstlineno__`
    - `Record.__static_attributes__`
  - `Reference`
    - `Reference.__init__()`
    - `Reference.__str__()`
    - `Reference.__annotate_func__`
    - `Reference.__annotations_cache__`
    - `Reference.__firstlineno__`
    - `Reference.__static_attributes__`
  - `Feature`
    - `Feature.__init__()`
    - `Feature.__repr__()`
    - `Feature.__str__()`
    - `Feature.__annotate_func__`
    - `Feature.__annotations_cache__`
    - `Feature.__firstlineno__`
    - `Feature.__static_attributes__`
  - `Qualifier`
    - `Qualifier.__init__()`
    - `Qualifier.__repr__()`
    - `Qualifier.__str__()`
    - `Qualifier.__annotate_func__`
    - `Qualifier.__annotations_cache__`
    - `Qualifier.__firstlineno__`
    - `Qualifier.__static_attributes__`
- Bio.GenBank.Scanner module
  - `InsdcScanner`
    - `InsdcScanner.RECORD_START`
    - `InsdcScanner.HEADER_WIDTH`
    - `InsdcScanner.FEATURE_START_MARKERS`
    - `InsdcScanner.FEATURE_END_MARKERS`
    - `InsdcScanner.FEATURE_QUALIFIER_INDENT`
    - `InsdcScanner.FEATURE_QUALIFIER_SPACER`
    - `InsdcScanner.SEQUENCE_HEADERS`
    - `InsdcScanner.__init__()`
    - `InsdcScanner.set_handle()`
    - `InsdcScanner.find_start()`
    - `InsdcScanner.parse_header()`
    - `InsdcScanner.parse_features()`
    - `InsdcScanner.parse_feature()`
    - `InsdcScanner.parse_footer()`
    - `InsdcScanner.feed()`
    - `InsdcScanner.parse()`
    - `InsdcScanner.parse_records()`
    - `InsdcScanner.parse_cds_features()`
    - `InsdcScanner.__annotations_cache__`
    - `InsdcScanner.__firstlineno__`
    - `InsdcScanner.__static_attributes__`
  - `EmblScanner`
    - `EmblScanner.RECORD_START`
    - `EmblScanner.HEADER_WIDTH`
    - `EmblScanner.FEATURE_START_MARKERS`
    - `EmblScanner.FEATURE_END_MARKERS`
    - `EmblScanner.FEATURE_QUALIFIER_INDENT`
    - `EmblScanner.FEATURE_QUALIFIER_SPACER`
    - `EmblScanner.SEQUENCE_HEADERS`
    - `EmblScanner.EMBL_INDENT`
    - `EmblScanner.EMBL_SPACER`
    - `EmblScanner.parse_footer()`
    - `EmblScanner.__annotations_cache__`
    - `EmblScanner.__firstlineno__`
    - `EmblScanner.__static_attributes__`
  - `GenBankScanner`
    - `GenBankScanner.RECORD_START`
    - `GenBankScanner.HEADER_WIDTH`
    - `GenBankScanner.FEATURE_START_MARKERS`
    - `GenBankScanner.FEATURE_END_MARKERS`
    - `GenBankScanner.FEATURE_QUALIFIER_INDENT`
    - `GenBankScanner.FEATURE_QUALIFIER_SPACER`
    - `GenBankScanner.SEQUENCE_HEADERS`
    - `GenBankScanner.GENBANK_INDENT`
    - `GenBankScanner.GENBANK_SPACER`
    - `GenBankScanner.STRUCTURED_COMMENT_START`
    - `GenBankScanner.STRUCTURED_COMMENT_END`
    - `GenBankScanner.STRUCTURED_COMMENT_DELIM`
    - `GenBankScanner.parse_footer()`
    - `GenBankScanner.__annotate_func__()`
    - `GenBankScanner.__annotations_cache__`
    - `GenBankScanner.__firstlineno__`
    - `GenBankScanner.__static_attributes__`
- Bio.GenBank.utils module
  - `FeatureValueCleaner`
    - `FeatureValueCleaner.keys_to_process`
    - `FeatureValueCleaner.__init__()`
    - `FeatureValueCleaner.__repr__()`
    - `FeatureValueCleaner.clean_value()`
    - `FeatureValueCleaner.__annotate_func__`
    - `FeatureValueCleaner.__annotations_cache__`
    - `FeatureValueCleaner.__firstlineno__`
    - `FeatureValueCleaner.__static_attributes__`

## Module contents

Code to work with GenBank formatted files.

Rather than using Bio.GenBank, you are now encouraged to use Bio.SeqIO with the “genbank” or “embl” format names to parse GenBank or EMBL files into SeqRecord and SeqFeature objects (see the Biopython tutorial for details).

Using Bio.GenBank directly to parse GenBank files is only useful if you want to obtain GenBank-specific Record objects, which is a much closer representation to the raw file contents than the SeqRecord alternative from the FeatureParser (used in Bio.SeqIO).

To use the Bio.GenBank parser, there are two helper functions:

> - read Parse a handle containing a single GenBank record as Bio.GenBank specific Record objects.

> - parse Iterate over a handle containing multiple GenBank records as Bio.GenBank specific Record objects.

The following internal classes are not intended for direct use and may be deprecated in a future release.

Classes:

  - Iterator Iterate through a file of GenBank entries

  - FeatureParser Parse GenBank data in SeqRecord and SeqFeature objects.

  - RecordParser Parse GenBank data into a Record object.

Exceptions:

  - ParserFailureError Exception indicating a failure in the parser (ie. scanner or consumer)

class Bio.GenBank.Iterator(handle, parser=None)

  Bases: `object`

  Iterator interface to move over a file of GenBank entries one at a time (OBSOLETE).

  This class is likely to be deprecated in a future release of Biopython. Please use Bio.SeqIO.parse(…, format=”gb”) or Bio.GenBank.parse(…) for SeqRecord and GenBank specific Record objects respectively instead.

  __init__(handle, parser=None)

    Initialize the iterator.

    Arguments:

      - handle - A handle with GenBank entries to iterate through.

      - parser - An optional parser to pass the entries through before returning them. If None, then the raw entry will be returned.

  __next__()

    Return the next GenBank record from the handle.

    Will return None if we ran out of records.

  __iter__()

    Iterate over the records.

  __annotate_func__ = None
  __annotations_cache__ = {}
  __firstlineno__ = 65
  __static_attributes__ = ('_parser', 'handle')

exception Bio.GenBank.ParserFailureError

  Bases: `ValueError`

  Failure caused by some kind of problem in the parser.

  __firstlineno__ = 110
  __static_attributes__ = ()

class Bio.GenBank.FeatureParser(debug_level=0, use_fuzziness=1, feature_cleaner=None)

  Bases: `object`

  Parse GenBank files into Seq + Feature objects (OBSOLETE).

  Direct use of this class is discouraged, and may be deprecated in a future release of Biopython.

  Please use Bio.SeqIO.parse(…) or Bio.SeqIO.read(…) instead.

  __init__(debug_level=0, use_fuzziness=1, feature_cleaner=None)

    Initialize a GenBank parser and Feature consumer.

    Arguments:

      - debug_level - An optional argument that species the amount of debugging information the parser should spit out. By default we have no debugging info (the fastest way to do things), but if you want you can set this as high as two and see exactly where a parse fails.

      - use_fuzziness - Specify whether or not to use fuzzy representations. The default is 1 (use fuzziness).

      - feature_cleaner - A class which will be used to clean out the values of features. This class must implement the function clean_value. GenBank.utils has a “standard” cleaner class, which is used by default.

  parse(handle)

    Parse the specified handle.

  __annotate_func__ = None
  __annotations_cache__ = {}
  __firstlineno__ = 117
  __static_attributes__ = ('_cleaner', '_scanner', 'use_fuzziness')

class Bio.GenBank.RecordParser(debug_level=0)

  Bases: `object`

  Parse GenBank files into Record objects (OBSOLETE).

  Direct use of this class is discouraged, and may be deprecated in a future release of Biopython.

  Please use the Bio.GenBank.parse(…) or Bio.GenBank.read(…) functions instead.

  __init__(debug_level=0)

    Initialize the parser.

    Arguments:

      - debug_level - An optional argument that species the amount of debugging information the parser should spit out. By default we have no debugging info (the fastest way to do things), but if you want you can set this as high as two and see exactly where a parse fails.

  parse(handle)

    Parse the specified handle into a GenBank record.

  __annotate_func__ = None
  __annotations_cache__ = {}
  __firstlineno__ = 156
  __static_attributes__ = ('_scanner',)

Bio.GenBank.parse(handle)

  Iterate over GenBank formatted entries as Record objects.

      >>> from Bio import GenBank
      >>> with open("GenBank/NC_000932.gb") as handle:
      ...     for record in GenBank.parse(handle):
      ...         print(record.accession)
      ['NC_000932']

  To get SeqRecord objects use Bio.SeqIO.parse(…, format=”gb”) instead.

Bio.GenBank.read(handle)

  Read a handle containing a single GenBank entry as a Record object.

      >>> from Bio import GenBank
      >>> with open("GenBank/NC_000932.gb") as handle:
      ...     record = GenBank.read(handle)
      ...     print(record.accession)
      ['NC_000932']

  To get a SeqRecord object use Bio.SeqIO.read(…, format=”gb”) instead.

Biopython v: 1.86

Versions
  Previous
  Latest
  Develop

Biopython Project
  Homepage
  On GitHub