scripts/export/genomes/fetch_gen_metadata.py
def fetch_gca_acc_metadata(accession):
    """
    Fetch accession metadata and return a dictionary with ncbi_id, molecule's
    type, description and tax id

    accession: A valid GCA accession from ENA
    """

    metadata = {}

    response = requests.get(gc.ENA_XML_URL % accession)

    if response.status_code == httplib.OK:
        xml_str = response.content
        xml_root = ET.fromstring(xml_str)
        entry = xml_root.find("entry")

        # return an empty dictionary if the accession is unavailable
        if entry is None:
            return metadata

        # None if no moleculeType found
        mol_type = entry.find("moleculeType")

        if mol_type is not None:
            metadata["mol_type"] = entry.get("moleculeType")

        # get molecule description and tax id
        metadata["description"] = entry.find("description").text
        metadata["ncbi_id"] = int(entry.find("feature").find("taxon").get("taxId"))

        # perhaps get a an else statement and return None?

    return metadata

    Fetch accession metadata and return a dictionary with ncbi_id, molecule's
    type, description and tax id

    accession: A valid GCA accession from ENA
    
Fetch accession metadata and return a dictionary with ncbi_id, molecule's
type, description and tax id

A valid GCA accession from ENA
Fetch accession metadata and return a dictionary with ncbi_id molecule ' s type description and tax id A valid GCA accession from ENA
def fetch_gca_acc_metadata(accession):
    metadata = {}
    response = requests.get(gc.ENA_XML_URL % accession)
    if response.status_code == httplib.OK:
        xml_str = response.content
        xml_root = ET.fromstring(xml_str)
        entry = xml_root.find("entry")
        if entry is None:
            return metadata
        mol_type = entry.find("moleculeType")
        if mol_type is not None:
            metadata["mol_type"] = entry.get("moleculeType")
        metadata["description"] = entry.find("description").text
        metadata["ncbi_id"] = int(entry.find("feature").find("taxon").get("taxId"))
    return metadata
def fetch_gca_acc_metadata ( accession ) : metadata = { } response = requests . get ( gc . ENA_XML_URL % accession ) if response . status_code == httplib . OK : xml_str = response . content xml_root = ET . fromstring ( xml_str ) entry = xml_root . find ( "entry" ) if entry is None : return metadata mol_type = entry . find ( "moleculeType" ) if mol_type is not None : metadata [ "mol_type" ] = entry . get ( "moleculeType" ) metadata [ "description" ] = entry . find ( "description" ) . text metadata [ "ncbi_id" ] = int ( entry . find ( "feature" ) . find ( "taxon" ) . get ( "taxId" ) ) return metadata
Fetch accession metadata and return a dictionary with ncbi_id, molecule's
type, description and tax id
Fetch accession metadata and return a dictionary with ncbi_id molecule ' s type description and tax id
"""
    Fetch accession metadata and return a dictionary with ncbi_id, molecule's
    type, description and tax id

    accession: A valid GCA accession from ENA
    """ # return an empty dictionary if the accession is unavailable # None if no moleculeType found # get molecule description and tax id # perhaps get a an else statement and return None?
accession