scripts/export/genomes/fetch_gen_metadata.py
def fetch_wgs_acc_metadata(wgs_acc):
    """
    Return a fields dictionary

    wgs_acc: A valid ENA wgs accession
    """

    fields = {}
    response = requests.get(gf.ENA_XML_URL % wgs_acc)

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

        if entry is None:
            return fields

        fields["seq_version"] = 0
        if entry.get("entryVersion") is not None:
            fields["seq_version"] = int(entry.get("entryVersion"))

        fields["seq_length"] = int(entry.get("sequenceLength"))
        fields["seq_role"] = "contig"
        fields["mol_type"] = entry.get("moleculeType")

        taxon_node = None
        taxon_node = entry.find("feature").find("taxon")
        fields["ncbi_id"] = int(taxon_node.get("taxId"))

        location = None
        refs = None
        refs = entry.findall("reference")

        for ref in refs:
            location = ref.get("location")
            if location is not None:
                break

        if location is not None:
            location = location.strip().split('-')
            fields["seq_start"] = int(location[0])
            fields["seq_end"] = int(location[1])
        else:
            fields["seq_start"] = 0
            fields["seq_end"] = 0

        fields["assembly_unit"] = None  # need to check this one
        fields["description"] = entry.find("description").text

        # this takes the date of the entry is created
        entry_date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        fields["created"] = entry_date
        fields["updated"] = entry_date  # when adding a new genome

    return fields

    Return a fields dictionary

    wgs_acc: A valid ENA wgs accession
    
Return a fields dictionary
wgs_acc: A valid ENA wgs accession
Return a fields dictionary wgs_acc : A valid ENA wgs accession
def fetch_wgs_acc_metadata(wgs_acc):
    fields = {}
    response = requests.get(gf.ENA_XML_URL % wgs_acc)
    if response.status_code == httplib.OK:
        acc_xml = ET.fromstring(response.content)
        entry = acc_xml.find("entry")
        if entry is None:
            return fields
        fields["seq_version"] = 0
        if entry.get("entryVersion") is not None:
            fields["seq_version"] = int(entry.get("entryVersion"))
        fields["seq_length"] = int(entry.get("sequenceLength"))
        fields["seq_role"] = "contig"
        fields["mol_type"] = entry.get("moleculeType")
        taxon_node = None
        taxon_node = entry.find("feature").find("taxon")
        fields["ncbi_id"] = int(taxon_node.get("taxId"))
        location = None
        refs = None
        refs = entry.findall("reference")
        for ref in refs:
            location = ref.get("location")
            if location is not None:
                break
        if location is not None:
            location = location.strip().split('-')
            fields["seq_start"] = int(location[0])
            fields["seq_end"] = int(location[1])
        else:
            fields["seq_start"] = 0
            fields["seq_end"] = 0
        fields["assembly_unit"] = None  
        fields["description"] = entry.find("description").text
        entry_date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        fields["created"] = entry_date
        fields["updated"] = entry_date  
    return fields
def fetch_wgs_acc_metadata ( wgs_acc ) : fields = { } response = requests . get ( gf . ENA_XML_URL % wgs_acc ) if response . status_code == httplib . OK : acc_xml = ET . fromstring ( response . content ) entry = acc_xml . find ( "entry" ) if entry is None : return fields fields [ "seq_version" ] = 0 if entry . get ( "entryVersion" ) is not None : fields [ "seq_version" ] = int ( entry . get ( "entryVersion" ) ) fields [ "seq_length" ] = int ( entry . get ( "sequenceLength" ) ) fields [ "seq_role" ] = "contig" fields [ "mol_type" ] = entry . get ( "moleculeType" ) taxon_node = None taxon_node = entry . find ( "feature" ) . find ( "taxon" ) fields [ "ncbi_id" ] = int ( taxon_node . get ( "taxId" ) ) location = None refs = None refs = entry . findall ( "reference" ) for ref in refs : location = ref . get ( "location" ) if location is not None : break if location is not None : location = location . strip ( ) . split ( '-' ) fields [ "seq_start" ] = int ( location [ 0 ] ) fields [ "seq_end" ] = int ( location [ 1 ] ) else : fields [ "seq_start" ] = 0 fields [ "seq_end" ] = 0 fields [ "assembly_unit" ] = None fields [ "description" ] = entry . find ( "description" ) . text entry_date = datetime . datetime . now ( ) . strftime ( "%Y-%m-%d %H:%M:%S" ) fields [ "created" ] = entry_date fields [ "updated" ] = entry_date return fields
Return a fields dictionary
wgs_acc: A valid ENA wgs accession
Return a fields dictionary wgs_acc : A valid ENA wgs accession
"""
    Return a fields dictionary

    wgs_acc: A valid ENA wgs accession
    """ # need to check this one # this takes the date of the entry is created # when adding a new genome
wgs_acc