biotite.database.uniprot.fetch

biotite.database.uniprot.fetch(ids, format, target_path=None, overwrite=False, verbose=False)[source]

Download files from the UniProt in various formats.

Available databases are UniProtKB, UniRef and UniParc.

This function requires an internet connection.

Parameters
idsstr or iterable object of str

A single ID or a list of IDs of the file(s) to be downloaded.

format{‘fasta’, ‘gff’, ‘txt’, ‘xml’, ‘rdf’, ‘tab’}

The format of the files to be downloaded.

target_pathstr, optional

The target directory of the downloaded files. By default, the file content is stored in a file-like object (StringIO or BytesIO, respectively).

overwritebool, optional

If true, existing files will be overwritten. Otherwise the respective file will only be downloaded if the file does not exist yet in the specified target directory or if the file is empty. (Default: False)

verbose: bool, optional

If true, the function will output the download progress. (Default: False)

Returns
filesstr or StringIO or BytesIO or list of (str or StringIO or BytesIO)

The file path(s) to the downloaded files. If a single string (a single ID) was given in ids, a single string is returned. If a list (or other iterable object) was given, a list of strings is returned. If no target_path was given, the file contents are stored in either StringIO or BytesIO objects.

Examples

>>> import os.path
>>> file = fetch("P12345", "fasta", path_to_directory)
>>> print(os.path.basename(file))
P12345.fasta
>>> files = fetch(["P12345", "Q8K9I1"], "fasta", path_to_directory)
>>> print([os.path.basename(file) for file in files])
['P12345.fasta', 'Q8K9I1.fasta']