## Tools.ftp.NcbiFTPClient


Access NCBI directories over FTP and download data over HTTPS.


Usage

``` python
Tools.ftp.NcbiFTPClient(
    email,
    max_workers=4,
    **kwargs,
)
```


## Methods

| Name | Description |
|----|----|
| [__init__()](#__init__) | Initialize an anonymous NCBI connection. |
| [download_file()](#download_file) | Download a file from the current or specified NCBI directory. |
| [extract_file()](#extract_file) | Extract a gzip or tar-gzip archive into a controlled directory. |
| [getblastdb()](#getblastdb) | Download a complete preformatted NCBI BLAST database. |
| [getblastfasta()](#getblastfasta) | Download one of NCBI's convenience BLAST FASTA archives. |
| [getrefseqrelease()](#getrefseqrelease) | Download one molecule and format selection from a RefSeq release. |
| [getwindowmaskerfiles()](#getwindowmaskerfiles) | Reject downloads from NCBI's retired WindowMasker file service. |
| [listdirectories()](#listdirectories) | List subdirectories in an FTP directory. |
| [listfiles()](#listfiles) | List files in an FTP directory. |
| [updatedb()](#updatedb) | Refresh recognized local databases after a minimum age. |
| [walk()](#walk) | List immediate directories and files in an NCBI FTP path. |

------------------------------------------------------------------------


#### \_\_init\_\_()


Initialize an anonymous NCBI connection.


Usage

``` python
__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](Tools.ftp.BaseFTPClient.md#OrthoEvol.Tools.ftp.BaseFTPClient).


------------------------------------------------------------------------


#### download_file()


Download a file from the current or specified NCBI directory.


Usage

``` python
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

``` python
extract_file(file2extract, download_path=None, remove_archive=True)
```


------------------------------------------------------------------------


#### getblastdb()


Download a complete preformatted NCBI BLAST database.


Usage

``` python
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

``` python
getblastfasta(database_name, download_path, extract=True)
```


------------------------------------------------------------------------


#### getrefseqrelease()


Download one molecule and format selection from a RefSeq release.


Usage

``` python
getrefseqrelease(
    collection_subset, seqtype, seqformat, download_path, extract=True
)
```


------------------------------------------------------------------------


#### getwindowmaskerfiles()


Reject downloads from NCBI's retired WindowMasker file service.


Usage

``` python
getwindowmaskerfiles(taxonomy_ids, download_path)
```


------------------------------------------------------------------------


#### listdirectories()


List subdirectories in an FTP directory.


Usage

``` python
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

``` python
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

``` python
updatedb(database_path=None, update_days=7)
```


------------------------------------------------------------------------


#### walk()


List immediate directories and files in an NCBI FTP path.


Usage

``` python
walk(path)
```


##### Parameters


`path: str`  
Absolute FTP directory path.


##### Returns


`tuple[list[str], list[str]]`  
Directory names followed by file names.
