scripts/export/genomes/genome_fetch.py
def fetch_accessions_from_proteome_xml(proteome):
    """
    Parses Uniprot's proteome xml and extracts all available ENA accessions

    proteome: A valid Uniprot's proteome accession

    returns: A list of genome accessions
    """
    prot_accessions = []

    # namespace prefix # or register a namespace in the ET
    prefix = "{http://uniprot.org/uniprot}%s"

    response = requests.get(gc.PROTEOME_XML_URL % proteome)

    if response.status_code == 200:
        # convert from string to xml format
        prot_tree_root = ET.fromstring(response.content)

        # get proteome node
        proteome = prot_tree_root.find(prefix % "proteome")

        # get proteome's component nodes/genome accession nodes
        component_nodes = proteome.findall(prefix % "component")

        # loop over all component nodes and extract genome accessions
        for node in component_nodes:
            gen_acc_nodes = node.findall(prefix % "genome_accession")

            for gen_acc_node in gen_acc_nodes:
                prot_accessions.append(gen_acc_node.text)

    return prot_accessions

    Parses Uniprot's proteome xml and extracts all available ENA accessions

    proteome: A valid Uniprot's proteome accession

    returns: A list of genome accessions
    
Parses Uniprot's proteome xml and extracts all available ENA accessions
proteome: A valid Uniprot's proteome accession

A list of genome accessions
Parses Uniprot ' s proteome xml and extracts all available ENA accessions proteome : A valid Uniprot ' s proteome accession A list of genome accessions
def fetch_accessions_from_proteome_xml(proteome):
    prot_accessions = []
    prefix = "{http://uniprot.org/uniprot}%s"
    response = requests.get(gc.PROTEOME_XML_URL % proteome)
    if response.status_code == 200:
        prot_tree_root = ET.fromstring(response.content)
        proteome = prot_tree_root.find(prefix % "proteome")
        component_nodes = proteome.findall(prefix % "component")
        for node in component_nodes:
            gen_acc_nodes = node.findall(prefix % "genome_accession")
            for gen_acc_node in gen_acc_nodes:
                prot_accessions.append(gen_acc_node.text)
    return prot_accessions
def fetch_accessions_from_proteome_xml ( proteome ) : prot_accessions = [ ] prefix = "{http://uniprot.org/uniprot}%s" response = requests . get ( gc . PROTEOME_XML_URL % proteome ) if response . status_code == 200 : prot_tree_root = ET . fromstring ( response . content ) proteome = prot_tree_root . find ( prefix % "proteome" ) component_nodes = proteome . findall ( prefix % "component" ) for node in component_nodes : gen_acc_nodes = node . findall ( prefix % "genome_accession" ) for gen_acc_node in gen_acc_nodes : prot_accessions . append ( gen_acc_node . text ) return prot_accessions
Parses Uniprot's proteome xml and extracts all available ENA accessions
proteome: A valid Uniprot's proteome accession
Parses Uniprot ' s proteome xml and extracts all available ENA accessions proteome : A valid Uniprot ' s proteome accession
"""
    Parses Uniprot's proteome xml and extracts all available ENA accessions

    proteome: A valid Uniprot's proteome accession

    returns: A list of genome accessions
    """ # namespace prefix # or register a namespace in the ET # convert from string to xml format # get proteome node # get proteome's component nodes/genome accession nodes # loop over all component nodes and extract genome accessions
proteome