scripts/export/rnac2json.py
def build_json_dict(entry, sequence):
    """
    RNAcentral specific method to build the json dictionary for each entry.
    Sequences are provided as a parameter as they are exported using
    esl-sfetch and ENA via the url API.

    entry:    A list of the fields in a DB entry resulting from
              Rfam2RNAcentral export
    sequence: Entry's corresponding sequence
    """

    edict = {}
    species = ''

    edict["parent_accession"] = entry[SEQACC].partition('.')[0]
    edict["seq_version"] = entry[VERSION]
    edict["feature_location_start"] = entry[SEQ_START]
    edict["feature_location_end"] = entry[SEQ_END]

    edict["ncrna_class"] = entry[NCRNA_CLASS]
    edict["feature_type"] = entry[RNA_TYPE]

    if entry[ALIGNMENT] == "seed":
        edict["is_seed"] = '1'
    else:
        edict["is_seed"] = '0'

    edict["primary_id"] = entry[RFAM_ACC]
    edict["optional_id"] = entry[RFAM_ID]
    edict["description"] = entry[DESCRIPTION]

    edict["sequence"] = sequence

    edict["lineage"] = entry[TAX_STR].replace(';', '')

    species = entry[SPECIES]
    common_name = ''

    if species.find('(') != -1:
        if species.count('(') > 1:
            species = species.rsplit('(', 1)
            common_name = species[1]
        else:
            species = species.partition('(')
            common_name = species[2]
        common_name = common_name.partition(')')
        common_name = common_name[0].capitalize()
        species = species[0].strip()

    edict["species"] = species
    edict["common_name"] = common_name

    edict["ncbi_tax_id"] = entry[NCBI_ID]

    references = map(lambda x: x[5:].strip(), entry[PMIDS].split(','))
    edict["references"] = references

    ontology = map(lambda x: x.strip(), entry[DBXREFS].split(','))
    ontology_dict = {}

    if len(ontology) > 0:
        for ontology_element in ontology:
            elements = ontology_element.partition(':')
            ontology_dict[elements[0]] = elements[2]
    
        edict["ontology"] = ontology_dict
    else:
        edict["ontology"] = ontology

    return edict

    RNAcentral specific method to build the json dictionary for each entry.
    Sequences are provided as a parameter as they are exported using
    esl-sfetch and ENA via the url API.

    entry:    A list of the fields in a DB entry resulting from
              Rfam2RNAcentral export
    sequence: Entry's corresponding sequence
    
RNAcentral specific method to build the json dictionary for each entry.
Sequences are provided as a parameter as they are exported using
esl-sfetch and ENA via the url API.

A list of the fields in a DB entry resulting from
Rfam2RNAcentral export
sequence: Entry's corresponding sequence
RNAcentral specific method to build the json dictionary for each entry . Sequences are provided as a parameter as they are exported using esl - sfetch and ENA via the url API . A list of the fields in a DB entry resulting from Rfam2RNAcentral export sequence : Entry ' s corresponding sequence
def build_json_dict(entry, sequence):
    edict = {}
    species = ''
    edict["parent_accession"] = entry[SEQACC].partition('.')[0]
    edict["seq_version"] = entry[VERSION]
    edict["feature_location_start"] = entry[SEQ_START]
    edict["feature_location_end"] = entry[SEQ_END]
    edict["ncrna_class"] = entry[NCRNA_CLASS]
    edict["feature_type"] = entry[RNA_TYPE]
    if entry[ALIGNMENT] == "seed":
        edict["is_seed"] = '1'
    else:
        edict["is_seed"] = '0'
    edict["primary_id"] = entry[RFAM_ACC]
    edict["optional_id"] = entry[RFAM_ID]
    edict["description"] = entry[DESCRIPTION]
    edict["sequence"] = sequence
    edict["lineage"] = entry[TAX_STR].replace(';', '')
    species = entry[SPECIES]
    common_name = ''
    if species.find('(') != -1:
        if species.count('(') > 1:
            species = species.rsplit('(', 1)
            common_name = species[1]
        else:
            species = species.partition('(')
            common_name = species[2]
        common_name = common_name.partition(')')
        common_name = common_name[0].capitalize()
        species = species[0].strip()
    edict["species"] = species
    edict["common_name"] = common_name
    edict["ncbi_tax_id"] = entry[NCBI_ID]
    references = map(lambda x: x[5:].strip(), entry[PMIDS].split(','))
    edict["references"] = references
    ontology = map(lambda x: x.strip(), entry[DBXREFS].split(','))
    ontology_dict = {}
    if len(ontology) > 0:
        for ontology_element in ontology:
            elements = ontology_element.partition(':')
            ontology_dict[elements[0]] = elements[2]
        edict["ontology"] = ontology_dict
    else:
        edict["ontology"] = ontology
    return edict
def build_json_dict ( entry , sequence ) : edict = { } species = '' edict [ "parent_accession" ] = entry [ SEQACC ] . partition ( '.' ) [ 0 ] edict [ "seq_version" ] = entry [ VERSION ] edict [ "feature_location_start" ] = entry [ SEQ_START ] edict [ "feature_location_end" ] = entry [ SEQ_END ] edict [ "ncrna_class" ] = entry [ NCRNA_CLASS ] edict [ "feature_type" ] = entry [ RNA_TYPE ] if entry [ ALIGNMENT ] == "seed" : edict [ "is_seed" ] = '1' else : edict [ "is_seed" ] = '0' edict [ "primary_id" ] = entry [ RFAM_ACC ] edict [ "optional_id" ] = entry [ RFAM_ID ] edict [ "description" ] = entry [ DESCRIPTION ] edict [ "sequence" ] = sequence edict [ "lineage" ] = entry [ TAX_STR ] . replace ( ';' , '' ) species = entry [ SPECIES ] common_name = '' if species . find ( '(' ) != - 1 : if species . count ( '(' ) > 1 : species = species . rsplit ( '(' , 1 ) common_name = species [ 1 ] else : species = species . partition ( '(' ) common_name = species [ 2 ] common_name = common_name . partition ( ')' ) common_name = common_name [ 0 ] . capitalize ( ) species = species [ 0 ] . strip ( ) edict [ "species" ] = species edict [ "common_name" ] = common_name edict [ "ncbi_tax_id" ] = entry [ NCBI_ID ] references = map ( lambda x : x [ 5 : ] . strip ( ) , entry [ PMIDS ] . split ( ',' ) ) edict [ "references" ] = references ontology = map ( lambda x : x . strip ( ) , entry [ DBXREFS ] . split ( ',' ) ) ontology_dict = { } if len ( ontology ) > 0 : for ontology_element in ontology : elements = ontology_element . partition ( ':' ) ontology_dict [ elements [ 0 ] ] = elements [ 2 ] edict [ "ontology" ] = ontology_dict else : edict [ "ontology" ] = ontology return edict
RNAcentral specific method to build the json dictionary for each entry.
RNAcentral specific method to build the json dictionary for each entry .
"""
    RNAcentral specific method to build the json dictionary for each entry.
    Sequences are provided as a parameter as they are exported using
    esl-sfetch and ENA via the url API.

    entry:    A list of the fields in a DB entry resulting from
              Rfam2RNAcentral export
    sequence: Entry's corresponding sequence
    """
entry
sequence