scripts/export/genomes/genome_fetch.py
def proteome_xml_scanner(proteome):
    """
    Scans a Uniprot's reference proteome rdf file and looks for all
    available accessions. Returns a dictionary with GCA and WGS accessions
    where applicable

    prot_xml: Uniprot's proteome rdf url or file path
    """

    # need to do some http error handling here and if resource is unavailable
    # return None and or http error code

    prot_xml = PROTEOME_XML_URL % proteome
    prefix = "{http://uniprot.org/uniprot}%s"

    accessions = {"GCA": -1, "WGS": -1}

    if requests.get(prot_xml).status_code == httplib.OK:
        xml_root = ET.fromstring(requests.get(prot_xml).content)
        proteome = xml_root.find(prefix % "proteome")

        # look for a GCA accession
        gen_assembly = None
        gen_assembly = proteome.find(prefix % "genome_assembly")
        if gen_assembly is not None:
            accessions["GCA"] = gen_assembly.text

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

        # scan WGS accession
        for component in prot_components:
            component_name = component.get("name")
            if component_name.find("WGS") != -1:
                accessions["WGS"] = component.find(prefix % "genome_accession").text
    else:
        pass

    return accessions

    Scans a Uniprot's reference proteome rdf file and looks for all
    available accessions. Returns a dictionary with GCA and WGS accessions
    where applicable

    prot_xml: Uniprot's proteome rdf url or file path
    
Scans a Uniprot's reference proteome rdf file and looks for all
available accessions. Returns a dictionary with GCA and WGS accessions
where applicable

Uniprot's proteome rdf url or file path
Scans a Uniprot ' s reference proteome rdf file and looks for all available accessions . Returns a dictionary with GCA and WGS accessions where applicable Uniprot ' s proteome rdf url or file path
def proteome_xml_scanner(proteome):
    prot_xml = PROTEOME_XML_URL % proteome
    prefix = "{http://uniprot.org/uniprot}%s"
    accessions = {"GCA": -1, "WGS": -1}
    if requests.get(prot_xml).status_code == httplib.OK:
        xml_root = ET.fromstring(requests.get(prot_xml).content)
        proteome = xml_root.find(prefix % "proteome")
        gen_assembly = None
        gen_assembly = proteome.find(prefix % "genome_assembly")
        if gen_assembly is not None:
            accessions["GCA"] = gen_assembly.text
        prot_components = proteome.findall(prefix % "component")
        for component in prot_components:
            component_name = component.get("name")
            if component_name.find("WGS") != -1:
                accessions["WGS"] = component.find(prefix % "genome_accession").text
    else:
        pass
    return accessions
def proteome_xml_scanner ( proteome ) : prot_xml = PROTEOME_XML_URL % proteome prefix = "{http://uniprot.org/uniprot}%s" accessions = { "GCA" : - 1 , "WGS" : - 1 } if requests . get ( prot_xml ) . status_code == httplib . OK : xml_root = ET . fromstring ( requests . get ( prot_xml ) . content ) proteome = xml_root . find ( prefix % "proteome" ) gen_assembly = None gen_assembly = proteome . find ( prefix % "genome_assembly" ) if gen_assembly is not None : accessions [ "GCA" ] = gen_assembly . text prot_components = proteome . findall ( prefix % "component" ) for component in prot_components : component_name = component . get ( "name" ) if component_name . find ( "WGS" ) != - 1 : accessions [ "WGS" ] = component . find ( prefix % "genome_accession" ) . text else : pass return accessions
Scans a Uniprot's reference proteome rdf file and looks for all
available accessions.
Scans a Uniprot ' s reference proteome rdf file and looks for all available accessions .
"""
    Scans a Uniprot's reference proteome rdf file and looks for all
    available accessions. Returns a dictionary with GCA and WGS accessions
    where applicable

    prot_xml: Uniprot's proteome rdf url or file path
    """ # need to do some http error handling here and if resource is unavailable # return None and or http error code # look for a GCA accession # scan WGS accession
proteome