Functions#

Reading#

gb_io.load(fh)#

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

Parameters:

fh (str or file-handle) – The path to a GenBank file, or a stream that contains data serialized in GenBank format.

Returns:

list of Record – A list containing all the records in the file.

gb_io.iter(fh)#

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

Parameters:

fh (str or file-handle) – The path to a GenBank file, or a stream that contains data serialized in GenBank format.

Returns:

RecordReader – An iterator over the GenBank records in the given file or file-handle.

Writing#

gb_io.dump(records, fh, *, escape_locus=False, truncate_locus=False)#

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

Parameters:
  • records (Record or iterable of Record) – The records to write to the file.

  • fh (str or file-handle) – The path to a GenBank file, or a stream that contains data serialized in GenBank format.

  • escape_locus (bool) – Pass True to escape any whitespace in the locus name with an underscore character.

  • truncate_locus (bool) – Pass True to trim the locus fields so that the locus line is no longer than 79 characters.

Added in version 0.2.0.