scripts/export/genomes/fetch_gen_metadata.py
def dump_uniprot_genome_metadata(upid, kingdom):
    """
    Parses ENA GCA accession xml, and returns the accession's data in the
    form of a dictionary

    proteome_dict: A proteome dict built from Uniprot's proteome xml files
    upid: A valid Uniprot proteome accession (e.g. UP000005640 - Homo Sapiens)
    assembly_acc: A valid ENA GCA accession
    kingdom: The corresponding species' kingdom
    """

    genome_entry = {}
    fields = {}

    # extract the values from the corresponding xml
    proteome_dict = extract_uniprot_genome_metadata(upid)

    if len(proteome_dict.keys()) > 0:

        fields["gca_acc"] = None
        fields["gca_version"] = None

        # add ensembl fields as a post-processing step
        fields["ensembl_id"] = None
        fields["ensembl_source"] = None

        fields["assembly_name"] = None
        fields["assembly_level"] = None

        # check if there is a WGS accession
        if "WGS" in proteome_dict["accessions"].keys():
            fields["wgs_acc"] = proteome_dict["accessions"]["WGS"]
            fields["wgs_version"] = int(proteome_dict["accessions"]["WGS"][4:6])
        else:
            fields["wgs_acc"] = None
            fields["wgs_version"] = None

        fields["study_ref"] = None

        # description can be very long, using title instead as short description
        fields["description"] = proteome_dict["description"]

        fields["total_length"] = None
        fields["ungapped_length"] = None
        fields["circular"] = None

        fields["ncbi_id"] = proteome_dict["ncbi_id"]

        fields["scientific_name"] = proteome_dict["scientific_name"]
        fields["common_name"] = None
        fields["kingdom"] = kingdom

        fields["num_rfam_regions"] = None
        fields["num_families"] = None

        fields["is_reference"] = proteome_dict["is_reference"]
        fields["is_representative"] = proteome_dict["is_representative"]

        # 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

        genome_entry["model"] = gc.GENOME_MODEL
        genome_entry["pk"] = upid
        genome_entry["fields"] = fields

    # return genome dictionary (in Django format)
    return genome_entry

    Parses ENA GCA accession xml, and returns the accession's data in the
    form of a dictionary

    proteome_dict: A proteome dict built from Uniprot's proteome xml files
    upid: A valid Uniprot proteome accession (e.g. UP000005640 - Homo Sapiens)
    assembly_acc: A valid ENA GCA accession
    kingdom: The corresponding species' kingdom
    
Parses ENA GCA accession xml, and returns the accession's data in the
form of a dictionary

A proteome dict built from Uniprot's proteome xml files
upid: A valid Uniprot proteome accession
assembly_acc: A valid ENA GCA accession
kingdom: The corresponding species' kingdom
Parses ENA GCA accession xml and returns the accession ' s data in the form of a dictionary A proteome dict built from Uniprot ' s proteome xml files upid : A valid Uniprot proteome accession assembly_acc : A valid ENA GCA accession kingdom : The corresponding species ' kingdom
def dump_uniprot_genome_metadata(upid, kingdom):
    genome_entry = {}
    fields = {}
    proteome_dict = extract_uniprot_genome_metadata(upid)
    if len(proteome_dict.keys()) > 0:
        fields["gca_acc"] = None
        fields["gca_version"] = None
        fields["ensembl_id"] = None
        fields["ensembl_source"] = None
        fields["assembly_name"] = None
        fields["assembly_level"] = None
        if "WGS" in proteome_dict["accessions"].keys():
            fields["wgs_acc"] = proteome_dict["accessions"]["WGS"]
            fields["wgs_version"] = int(proteome_dict["accessions"]["WGS"][4:6])
        else:
            fields["wgs_acc"] = None
            fields["wgs_version"] = None
        fields["study_ref"] = None
        fields["description"] = proteome_dict["description"]
        fields["total_length"] = None
        fields["ungapped_length"] = None
        fields["circular"] = None
        fields["ncbi_id"] = proteome_dict["ncbi_id"]
        fields["scientific_name"] = proteome_dict["scientific_name"]
        fields["common_name"] = None
        fields["kingdom"] = kingdom
        fields["num_rfam_regions"] = None
        fields["num_families"] = None
        fields["is_reference"] = proteome_dict["is_reference"]
        fields["is_representative"] = proteome_dict["is_representative"]
        entry_date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        fields["created"] = entry_date
        fields["updated"] = entry_date
        genome_entry["model"] = gc.GENOME_MODEL
        genome_entry["pk"] = upid
        genome_entry["fields"] = fields
    return genome_entry
def dump_uniprot_genome_metadata ( upid , kingdom ) : genome_entry = { } fields = { } proteome_dict = extract_uniprot_genome_metadata ( upid ) if len ( proteome_dict . keys ( ) ) > 0 : fields [ "gca_acc" ] = None fields [ "gca_version" ] = None fields [ "ensembl_id" ] = None fields [ "ensembl_source" ] = None fields [ "assembly_name" ] = None fields [ "assembly_level" ] = None if "WGS" in proteome_dict [ "accessions" ] . keys ( ) : fields [ "wgs_acc" ] = proteome_dict [ "accessions" ] [ "WGS" ] fields [ "wgs_version" ] = int ( proteome_dict [ "accessions" ] [ "WGS" ] [ 4 : 6 ] ) else : fields [ "wgs_acc" ] = None fields [ "wgs_version" ] = None fields [ "study_ref" ] = None fields [ "description" ] = proteome_dict [ "description" ] fields [ "total_length" ] = None fields [ "ungapped_length" ] = None fields [ "circular" ] = None fields [ "ncbi_id" ] = proteome_dict [ "ncbi_id" ] fields [ "scientific_name" ] = proteome_dict [ "scientific_name" ] fields [ "common_name" ] = None fields [ "kingdom" ] = kingdom fields [ "num_rfam_regions" ] = None fields [ "num_families" ] = None fields [ "is_reference" ] = proteome_dict [ "is_reference" ] fields [ "is_representative" ] = proteome_dict [ "is_representative" ] entry_date = datetime . datetime . now ( ) . strftime ( "%Y-%m-%d %H:%M:%S" ) fields [ "created" ] = entry_date fields [ "updated" ] = entry_date genome_entry [ "model" ] = gc . GENOME_MODEL genome_entry [ "pk" ] = upid genome_entry [ "fields" ] = fields return genome_entry
Parses ENA GCA accession xml, and returns the accession's data in the
form of a dictionary
Parses ENA GCA accession xml and returns the accession ' s data in the form of a dictionary
"""
    Parses ENA GCA accession xml, and returns the accession's data in the
    form of a dictionary

    proteome_dict: A proteome dict built from Uniprot's proteome xml files
    upid: A valid Uniprot proteome accession (e.g. UP000005640 - Homo Sapiens)
    assembly_acc: A valid ENA GCA accession
    kingdom: The corresponding species' kingdom
    """ # extract the values from the corresponding xml # add ensembl fields as a post-processing step # check if there is a WGS accession # description can be very long, using title instead as short description # this takes the date of the entry is created # return genome dictionary (in Django format)
upid
kingdom