Tools.ftp.NcbiFTPClient
Access NCBI directories over FTP and download data over HTTPS.
Usage
Tools.ftp.NcbiFTPClient(
email,
max_workers=4,
**kwargs,
)Methods
| Name | Description |
|---|---|
| __init__() | Initialize an anonymous NCBI connection. |
| download_file() | Download a file from the current or specified NCBI directory. |
| extract_file() | Extract a gzip or tar-gzip archive into a controlled directory. |
| getblastdb() | Download a complete preformatted NCBI BLAST database. |
| getblastfasta() | Download one of NCBI’s convenience BLAST FASTA archives. |
| getrefseqrelease() | Download one molecule and format selection from a RefSeq release. |
| getwindowmaskerfiles() | Reject downloads from NCBI’s retired WindowMasker file service. |
| listdirectories() | List subdirectories in an FTP directory. |
| listfiles() | List files in an FTP directory. |
| updatedb() | Refresh recognized local databases after a minimum age. |
| walk() | List immediate directories and files in an NCBI FTP path. |
__init__()
Initialize an anonymous NCBI connection.
Usage
__init__(email, max_workers=4, **kwargs)Parameters
email: str-
Contact email used as the anonymous FTP password.
max_workers: int = 4-
Maximum number of concurrent HTTPS transfers.
kwargs: Any = {}- Additional arguments for BaseFTPClient.
download_file()
Download a file from the current or specified NCBI directory.
Usage
download_file(filename, download_path=".")Parameters
filename: str-
Remote file name or absolute remote path.
download_path: str | Path = "."- Local destination directory.
Returns
Path- Local file path.
extract_file()
Extract a gzip or tar-gzip archive into a controlled directory.
Usage
extract_file(file2extract, download_path=None, remove_archive=True)getblastdb()
Download a complete preformatted NCBI BLAST database.
Usage
getblastdb(
database_name, download_path, v5=True, extract=True, include_taxonomy=True
)Version 5 selections come from NCBI’s metadata manifest, which avoids partial or substring-based database matches.
getblastfasta()
Download one of NCBI’s convenience BLAST FASTA archives.
Usage
getblastfasta(database_name, download_path, extract=True)getrefseqrelease()
Download one molecule and format selection from a RefSeq release.
Usage
getrefseqrelease(
collection_subset, seqtype, seqformat, download_path, extract=True
)getwindowmaskerfiles()
Reject downloads from NCBI’s retired WindowMasker file service.
Usage
getwindowmaskerfiles(taxonomy_ids, download_path)listdirectories()
List subdirectories in an FTP directory.
Usage
listdirectories(path="cwd")Parameters
path: str = "cwd"-
Absolute directory path or
cwd.
Returns
list[str]- Sorted directory names.
listfiles()
List files in an FTP directory.
Usage
listfiles(path="cwd")Parameters
path: str = "cwd"-
Absolute directory path or
cwd.
Returns
list[str]- Sorted file names.
updatedb()
Refresh recognized local databases after a minimum age.
Usage
updatedb(database_path=None, update_days=7)walk()
List immediate directories and files in an NCBI FTP path.
Usage
walk(path)Parameters
path: str- Absolute FTP directory path.
Returns
tuple[list[str], list[str]]- Directory names followed by file names.