Web

magna.ncbi.web.get_ncbi_assembly_id(gid)

Return the assembly ID for a given NCBI accession.

Parameters

gid (str) – The NCBI accession.

Return type

str

Returns

The NCBI assembly.

Examples

>>> get_ncbi_assembly_id('GCA_003138775.1')
'GCA_003138775.1_20110800_S2D'
magna.ncbi.web.get_ncbi_ftp_root(gid)

Return the FTP root and assembly ID for a given NCBI accession.

Parameters

gid (str) – The NCBI accession.

Return type

Tuple[str, str]

Returns

The FTP root and assembly ID.

Examples

>>> get_ncbi_ftp_root('GCA_003138775.1')
('https://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/003/138/775/GCA_003138775.1_20110800_S2D/', 'GCA_003138775.1_20110800_S2D')
magna.ncbi.web.get_md5checksums(url)

Retrieve the md5checksums.txt file and parse the content.

Parameters

url (str) – The URL to the md5checksums.txt file.

Return type

Dict[str, str]

Returns

A dictionary of md5checksums.

Examples

>>> get_md5checksums('https://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/003/138/775/GCA_003138775.1_20110800_S2D/md5checksums.txt')
{'GCA_003138775.1_20110800_S2D.fna.gz': 'f9f8f8f8f8f8f8f8f8f8f8f8f8f8f8', ...}
magna.ncbi.web.download_ncbi_assembly_file_to_disk(gid, target, file, silent=False)

Download a file from the NCBI assembly directory to disk.

Parameters
  • gid (str) – The NCBI accession.

  • target (str) – The target path.

  • file (NcbiAssemblyFileType) – The file type to download.

  • silent (bool) – True if the progress should be hidden.

Examples

>>> download_ncbi_assembly_file_to_disk('GCA_003138775.1', '/tmp/foo.fna.gz', NcbiAssemblyFileType.fna)