API Reference

A fast GenBank I/O library based on the gb-io Rust crate.

Example

Load all the GenBank records from a single file, and print their accession:

>>> import gb_io
>>> records = gb_io.load("tests/data/AY048670.1.gb")
>>> print([record.accession for record in records])
['AY048670']

Iterate over records inside a gzip compressed GenBank file, and display the accession and sequence length of each record larger than 400,000bp:

>>> import gb_io
>>> import gzip
>>> with gzip.open("tests/data/JAOQKG01.1.gb.gz", "rb") as reader:
...     for record in gb_io.iter(reader):
...         if len(record.sequence) > 400000:
...             print(record.name, len(record.sequence))
JAOQKG010000001 754685
JAOQKG010000002 569365
JAOQKG010000003 418835
JAOQKG010000004 418347

Functions

gb_io.load

Load all GenBank records from the given path or file handle.

gb_io.iter

Iterate over the GenBank records in the given file or file handle.

gb_io.dump

Write one or more GenBank records to the given path or file handle.

Classes

Record

gb_io.Record

A single GenBank record.

gb_io.Feature

A feature located somewhere in the record.

gb_io.Reference

A reference for a record.

gb_io.Source

The source of a GenBank record.

gb_io.Qualifier

A single key-value qualifier for a Feature.

Locations

gb_io.Location

A base location for a Feature.

gb_io.Between

A location for a Feature located between two consecutive positions.

gb_io.Bond

A location for a Feature corresponding to a bond between locations.

gb_io.Complement

A location for a Feature on the opposite strand of a given Location.

gb_io.External

A location for a Feature located in an external record.

gb_io.Join

A location for a Feature consisting in joined sequence spans.

gb_io.OneOf

A location for a Feature located at one of the given locations.

gb_io.Order

A location for a Feature over disjoint locations in the given order.

gb_io.Range

A location for a Feature spanning over a range of consecutive positions.

Reader

gb_io.RecordReader

An iterator over the Record contained in a file.