scripts/export/rfam_xml_dumper.py
def format_full_region(entries, region, genome, chromosome, rnacentral_ids):
    """
    Format full regions for a genome. Genome metadata is retrieved only once.
    """
    timestamp = datetime.datetime.now().strftime("%d %b %Y")
    name = '%s/%s:%s' % (region["rfamseq_acc"], region["seq_start"], region["seq_end"])

    scientific_name = None
    if genome is not None:
        scientific_name = genome.scientific_name
    else:
        scientific_name = region['scientific_name']

    description = '%s %s' % (scientific_name, region["rfam_id"])

    # add a new family entry to the xml tree
    entry_id = '%s_%s_%s' % (region["rfamseq_acc"], region["seq_start"], region["seq_end"])
    entry = ET.SubElement(entries, "entry", id=entry_id)

    ET.SubElement(entry, "name").text = name
    ET.SubElement(entry, "description").text = description
    dates = ET.SubElement(entry, "dates")
    ET.SubElement(dates, "date", value=timestamp, type="created")
    ET.SubElement(dates, "date", value=timestamp, type="updated")

    # additional fields
    build_full_region_additional_fields(entry, region, genome, chromosome)

    # adding cross references
    cross_refs = {}

    ncbi_id = None
    if genome is not None:
        ncbi_id = genome.ncbi_id
    else:
        ncbi_id = region['ncbi_id']

    # create cross references dictionary
    cross_refs["ncbi_taxonomy_id"] = [ncbi_id]
    cross_refs["RFAM"] = [region["rfam_acc"]]

    ena_accession = ''
    if region["rfamseq_acc"].find('.') != -1:
        ena_accession = region["rfamseq_acc"].partition('.')[0]
        cross_refs["ENA"] = [ena_accession]

    elif region["rfamseq_acc"][0:3] != "URS":
        ena_accession = region["rfamseq_acc"]
        cross_refs["ENA"] = [ena_accession]

    if genome is not None:
        cross_refs["Uniprot"] = [genome.upid]

    if name in rnacentral_ids:
        cross_refs["RNACENTRAL"] = [rnacentral_ids[name] + '_' + str(ncbi_id)]
    else:
        if "/" in name:
            name = name.partition("/")[0]
        cross_refs["RNACENTRAL"] = [name]

    build_cross_references(entry, cross_refs)

    Format full regions for a genome. Genome metadata is retrieved only once.
    
Format full regions for a genome. Genome metadata is retrieved only once.
Format full regions for a genome . Genome metadata is retrieved only once .
def format_full_region(entries, region, genome, chromosome, rnacentral_ids):
    timestamp = datetime.datetime.now().strftime("%d %b %Y")
    name = '%s/%s:%s' % (region["rfamseq_acc"], region["seq_start"], region["seq_end"])
    scientific_name = None
    if genome is not None:
        scientific_name = genome.scientific_name
    else:
        scientific_name = region['scientific_name']
    description = '%s %s' % (scientific_name, region["rfam_id"])
    entry_id = '%s_%s_%s' % (region["rfamseq_acc"], region["seq_start"], region["seq_end"])
    entry = ET.SubElement(entries, "entry", id=entry_id)
    ET.SubElement(entry, "name").text = name
    ET.SubElement(entry, "description").text = description
    dates = ET.SubElement(entry, "dates")
    ET.SubElement(dates, "date", value=timestamp, type="created")
    ET.SubElement(dates, "date", value=timestamp, type="updated")
    build_full_region_additional_fields(entry, region, genome, chromosome)
    cross_refs = {}
    ncbi_id = None
    if genome is not None:
        ncbi_id = genome.ncbi_id
    else:
        ncbi_id = region['ncbi_id']
    cross_refs["ncbi_taxonomy_id"] = [ncbi_id]
    cross_refs["RFAM"] = [region["rfam_acc"]]
    ena_accession = ''
    if region["rfamseq_acc"].find('.') != -1:
        ena_accession = region["rfamseq_acc"].partition('.')[0]
        cross_refs["ENA"] = [ena_accession]
    elif region["rfamseq_acc"][0:3] != "URS":
        ena_accession = region["rfamseq_acc"]
        cross_refs["ENA"] = [ena_accession]
    if genome is not None:
        cross_refs["Uniprot"] = [genome.upid]
    if name in rnacentral_ids:
        cross_refs["RNACENTRAL"] = [rnacentral_ids[name] + '_' + str(ncbi_id)]
    else:
        if "/" in name:
            name = name.partition("/")[0]
        cross_refs["RNACENTRAL"] = [name]
    build_cross_references(entry, cross_refs)
def format_full_region ( entries , region , genome , chromosome , rnacentral_ids ) : timestamp = datetime . datetime . now ( ) . strftime ( "%d %b %Y" ) name = '%s/%s:%s' % ( region [ "rfamseq_acc" ] , region [ "seq_start" ] , region [ "seq_end" ] ) scientific_name = None if genome is not None : scientific_name = genome . scientific_name else : scientific_name = region [ 'scientific_name' ] description = '%s %s' % ( scientific_name , region [ "rfam_id" ] ) entry_id = '%s_%s_%s' % ( region [ "rfamseq_acc" ] , region [ "seq_start" ] , region [ "seq_end" ] ) entry = ET . SubElement ( entries , "entry" , id = entry_id ) ET . SubElement ( entry , "name" ) . text = name ET . SubElement ( entry , "description" ) . text = description dates = ET . SubElement ( entry , "dates" ) ET . SubElement ( dates , "date" , value = timestamp , type = "created" ) ET . SubElement ( dates , "date" , value = timestamp , type = "updated" ) build_full_region_additional_fields ( entry , region , genome , chromosome ) cross_refs = { } ncbi_id = None if genome is not None : ncbi_id = genome . ncbi_id else : ncbi_id = region [ 'ncbi_id' ] cross_refs [ "ncbi_taxonomy_id" ] = [ ncbi_id ] cross_refs [ "RFAM" ] = [ region [ "rfam_acc" ] ] ena_accession = '' if region [ "rfamseq_acc" ] . find ( '.' ) != - 1 : ena_accession = region [ "rfamseq_acc" ] . partition ( '.' ) [ 0 ] cross_refs [ "ENA" ] = [ ena_accession ] elif region [ "rfamseq_acc" ] [ 0 : 3 ] != "URS" : ena_accession = region [ "rfamseq_acc" ] cross_refs [ "ENA" ] = [ ena_accession ] if genome is not None : cross_refs [ "Uniprot" ] = [ genome . upid ] if name in rnacentral_ids : cross_refs [ "RNACENTRAL" ] = [ rnacentral_ids [ name ] + '_' + str ( ncbi_id ) ] else : if "/" in name : name = name . partition ( "/" ) [ 0 ] cross_refs [ "RNACENTRAL" ] = [ name ] build_cross_references ( entry , cross_refs )
Format full regions for a genome.
Format full regions for a genome .
"""
    Format full regions for a genome. Genome metadata is retrieved only once.
    """ # add a new family entry to the xml tree # additional fields # adding cross references # create cross references dictionary
entries
region
genome
chromosome
rnacentral_ids