scripts/support/genseq_to_rfamseq.py
def genseq_file_to_rfamseq(genseq_json_dump):
    """
    Loads genseq json object and generates a rfamseq dump in txt format

    genseq_dump:  A genseq .json file generated from metadata export

    return: void
    """

    genseq_fp = open(genseq_json_dump, 'r')
    genseq_entries = json.load(genseq_fp)
    rfamseq_entries = []

    for genseq_dict in genseq_entries:

        # get fields
        fields = genseq_dict["fields"]
        genseq_fp.close()

        # initializing list with pk
        rfamseq_acc = genseq_dict["pk"]
        rfamseq_attributes = [rfamseq_acc]

        accession = ''
        version = ''
        if rfamseq_acc.find('.'):
            accession = rfamseq_acc.partition('.')[0]
            version = rfamseq_acc.partition('.')[2]
        else:
            accession = rfamseq_acc
            version = fields["seq_version"]

        rfamseq_attributes.append(accession)
        rfamseq_attributes.append(version)

        # ncbi_id
        rfamseq_attributes.append(str(fields["ncbi_id"]))

        # setting mol_type to other RNA for all new sequneces
        rfamseq_attributes.append("genomic DNA")

        # length
        rfamseq_attributes.append(str(fields["seq_length"]))

        # description
        rfamseq_attributes.append(fields["description"])

        # set previous accession and source
        previous_accession = ''
        source = "UNIPROT; ENA"
        rfamseq_attributes.append(previous_accession)
        rfamseq_attributes.append(source)

        rfamseq_entries.append(rfamseq_attributes)

    return rfamseq_entries

    Loads genseq json object and generates a rfamseq dump in txt format

    genseq_dump:  A genseq .json file generated from metadata export

    return: void
    
Loads genseq json object and generates a rfamseq dump in txt format
genseq_dump:  A genseq .json file generated from metadata export

void
Loads genseq json object and generates a rfamseq dump in txt format genseq_dump : A genseq . json file generated from metadata export void
def genseq_file_to_rfamseq(genseq_json_dump):
    genseq_fp = open(genseq_json_dump, 'r')
    genseq_entries = json.load(genseq_fp)
    rfamseq_entries = []
    for genseq_dict in genseq_entries:
        fields = genseq_dict["fields"]
        genseq_fp.close()
        rfamseq_acc = genseq_dict["pk"]
        rfamseq_attributes = [rfamseq_acc]
        accession = ''
        version = ''
        if rfamseq_acc.find('.'):
            accession = rfamseq_acc.partition('.')[0]
            version = rfamseq_acc.partition('.')[2]
        else:
            accession = rfamseq_acc
            version = fields["seq_version"]
        rfamseq_attributes.append(accession)
        rfamseq_attributes.append(version)
        rfamseq_attributes.append(str(fields["ncbi_id"]))
        rfamseq_attributes.append("genomic DNA")
        rfamseq_attributes.append(str(fields["seq_length"]))
        rfamseq_attributes.append(fields["description"])
        previous_accession = ''
        source = "UNIPROT; ENA"
        rfamseq_attributes.append(previous_accession)
        rfamseq_attributes.append(source)
        rfamseq_entries.append(rfamseq_attributes)
    return rfamseq_entries
def genseq_file_to_rfamseq ( genseq_json_dump ) : genseq_fp = open ( genseq_json_dump , 'r' ) genseq_entries = json . load ( genseq_fp ) rfamseq_entries = [ ] for genseq_dict in genseq_entries : fields = genseq_dict [ "fields" ] genseq_fp . close ( ) rfamseq_acc = genseq_dict [ "pk" ] rfamseq_attributes = [ rfamseq_acc ] accession = '' version = '' if rfamseq_acc . find ( '.' ) : accession = rfamseq_acc . partition ( '.' ) [ 0 ] version = rfamseq_acc . partition ( '.' ) [ 2 ] else : accession = rfamseq_acc version = fields [ "seq_version" ] rfamseq_attributes . append ( accession ) rfamseq_attributes . append ( version ) rfamseq_attributes . append ( str ( fields [ "ncbi_id" ] ) ) rfamseq_attributes . append ( "genomic DNA" ) rfamseq_attributes . append ( str ( fields [ "seq_length" ] ) ) rfamseq_attributes . append ( fields [ "description" ] ) previous_accession = '' source = "UNIPROT; ENA" rfamseq_attributes . append ( previous_accession ) rfamseq_attributes . append ( source ) rfamseq_entries . append ( rfamseq_attributes ) return rfamseq_entries
Loads genseq json object and generates a rfamseq dump in txt format
genseq_dump:  A genseq .json file generated from metadata export
Loads genseq json object and generates a rfamseq dump in txt format genseq_dump : A genseq . json file generated from metadata export
"""
    Loads genseq json object and generates a rfamseq dump in txt format

    genseq_dump:  A genseq .json file generated from metadata export

    return: void
    """ # get fields # initializing list with pk # ncbi_id # setting mol_type to other RNA for all new sequneces # length # description # set previous accession and source
genseq_json_dump