scripts/export/genomes/genome_fetch.py
def proteome_xml_accessions_to_dict(upid):
    """
    Parses a valid proteome xml file and returns all accessions in the form of
    a dictionary. Component names from proteome xml are used as dictionary keys

    upid: A valid Uniprot proteome upid

    returns: A dictionary with all proteome associated accessions.
    """

    proteome_accs = {"GCA": -1, "WGS": -1}
    other = {}

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

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

    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
        gca_acc = None
        gca_acc = proteome.find(prefix % "genomeAssembly").find(prefix % "genomeAssembly")
        if gca_acc is not None:
            proteome_accs["GCA"] = gca_acc.text

        component_nodes = proteome.findall(prefix % "component")

        # loop over all component nodes and extract genome accessions
        for node in component_nodes:
            name = node.get("name")

            if name.find("WGS") != -1:
                accession = node.find(prefix % "genome_accession").text
                proteome_accs["WGS"] = accession

            else:
                accession = node.find(prefix % "genome_accession")
                # if there is an accession available
                if accession is not None:
                    accession = accession.text
                    other[name] = accession

        proteome_accs["OTHER"] = copy.deepcopy(other)

    return proteome_accs

    Parses a valid proteome xml file and returns all accessions in the form of
    a dictionary. Component names from proteome xml are used as dictionary keys

    upid: A valid Uniprot proteome upid

    returns: A dictionary with all proteome associated accessions.
    
Parses a valid proteome xml file and returns all accessions in the form of
a dictionary. Component names from proteome xml are used as dictionary keys

A valid Uniprot proteome upid

A dictionary with all proteome associated accessions.
Parses a valid proteome xml file and returns all accessions in the form of a dictionary . Component names from proteome xml are used as dictionary keys A valid Uniprot proteome upid A dictionary with all proteome associated accessions .
def proteome_xml_accessions_to_dict(upid):
    proteome_accs = {"GCA": -1, "WGS": -1}
    other = {}
    prefix = "{http://uniprot.org/uniprot}%s"
    response = requests.get(gc.PROTEOME_XML_URL % upid)
    if response.status_code == 200:
        prot_tree_root = ET.fromstring(response.content)
        proteome = prot_tree_root.find(prefix % "proteome")
        gca_acc = None
        gca_acc = proteome.find(prefix % "genomeAssembly").find(prefix % "genomeAssembly")
        if gca_acc is not None:
            proteome_accs["GCA"] = gca_acc.text
        component_nodes = proteome.findall(prefix % "component")
        for node in component_nodes:
            name = node.get("name")
            if name.find("WGS") != -1:
                accession = node.find(prefix % "genome_accession").text
                proteome_accs["WGS"] = accession
            else:
                accession = node.find(prefix % "genome_accession")
                if accession is not None:
                    accession = accession.text
                    other[name] = accession
        proteome_accs["OTHER"] = copy.deepcopy(other)
    return proteome_accs
def proteome_xml_accessions_to_dict ( upid ) : proteome_accs = { "GCA" : - 1 , "WGS" : - 1 } other = { } prefix = "{http://uniprot.org/uniprot}%s" response = requests . get ( gc . PROTEOME_XML_URL % upid ) if response . status_code == 200 : prot_tree_root = ET . fromstring ( response . content ) proteome = prot_tree_root . find ( prefix % "proteome" ) gca_acc = None gca_acc = proteome . find ( prefix % "genomeAssembly" ) . find ( prefix % "genomeAssembly" ) if gca_acc is not None : proteome_accs [ "GCA" ] = gca_acc . text component_nodes = proteome . findall ( prefix % "component" ) for node in component_nodes : name = node . get ( "name" ) if name . find ( "WGS" ) != - 1 : accession = node . find ( prefix % "genome_accession" ) . text proteome_accs [ "WGS" ] = accession else : accession = node . find ( prefix % "genome_accession" ) if accession is not None : accession = accession . text other [ name ] = accession proteome_accs [ "OTHER" ] = copy . deepcopy ( other ) return proteome_accs
Parses a valid proteome xml file and returns all accessions in the form of
a dictionary.
Parses a valid proteome xml file and returns all accessions in the form of a dictionary .
"""
    Parses a valid proteome xml file and returns all accessions in the form of
    a dictionary. Component names from proteome xml are used as dictionary keys

    upid: A valid Uniprot proteome upid

    returns: A dictionary with all proteome associated 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 # if there is an accession available
upid