biotite.sequence.io.genbank.MultiFile

class biotite.sequence.io.genbank.MultiFile[source]

Bases: TextFile

This class represents a file in GenBank or GenPept format, that contains multiple entries, for more than one UID.

The information for each UID are appended to each other in such a file. Objects of this class can be iterated to obtain a GenBankFile for each entry in the file.

Examples

>>> import os.path
>>> file_name = fetch_single_file(
...     ["1L2Y_A", "3O5R_A", "5UGO_A"],
...     os.path.join(path_to_directory, "multifile.gp"),
...     "protein", "gp"
... )
>>> multi_file = MultiFile.read(file_name)
>>> for gp_file in multi_file:
...     print(get_accession(gp_file))
1L2Y_A
3O5R_A
5UGO_A
copy()

Create a deep copy of this object.

Returns
copy

A copy of this object.

classmethod read(file, *args, **kwargs)

Parse a file (or file-like object).

Parameters
filefile-like object or str

The file to be read. Alternatively a file path can be supplied.

Returns
file_objectFile

An instance from the respective File subclass representing the parsed file.

static read_iter(file)

Create an iterator over each line of the given text file.

Parameters
filefile-like object or str

The file to be read. Alternatively a file path can be supplied.

Yields
linestr

The current line in the file.

write(file)

Write the contents of this object into a file (or file-like object).

Parameters
filefile-like object or str

The file to be written to. Alternatively a file path can be supplied.

static write_iter(file, lines)

Iterate over the given lines of text and write each line into the specified file.

In contrast to write(), each line of text is not stored in an intermediate TextFile, but is directly written to the file. Hence, this static method may save a large amount of memory if a large file should be written, especially if the lines are provided as generator.

Parameters
filefile-like object or str

The file to be written to. Alternatively a file path can be supplied.

linesgenerator or array-like of str

The lines of text to be written. Must not include line break characters.