scripts/preprocessing/relabel_seed.py
def relabel_seeds_from_rnacentral_md5_mapping(seed, dest_dir=None):
    """
    Relabels the accessions of a SEED alignment using RNAcentral
    identifiers. This is done by matching the seed sequences, with
    sequences existing in RNAcentral using md5 hashing.

    seed: A reformatted seed in Pfam format
    dest_dir: The path to the destination directory. None by default

    return: The path to the relabelled SEED alignement
    """

    if dest_dir is None:
        # fetch path of seed alignment
        dest_dir = os.path.split(seed)[0]

    sequence_label = 0
    new_line = ''

    filename = os.path.split(seed)[1].partition('.')[0]

    new_seed_loc = os.path.join(dest_dir, filename+'_relabelled')
    seed_fp = open(seed, 'r')
    new_seed_fp = open(new_seed_loc, 'w')

    for line in seed_fp:
        # check if this is an actual sequence line
        if line[0] != '#' and len(line) > 1 and line[0:2] != '//':
            line_elements = [x for x in line.strip().split(' ') if x != '']

            # replace alignment characters
            miRNA_seq = line_elements[1].replace('.', '')
            miRNA_seq = miRNA_seq.replace('-', '').replace('T', 'U').replace('t', 'u')

            sequence_label = generate_seed_id_from_RNAcentral(miRNA_seq.upper())

            new_line = "\t".join([sequence_label, miRNA_seq.upper(), '\n'])

        else:
            new_line = line

        new_seed_fp.write(new_line)

    seed_fp.close()

    return new_seed_loc

    Relabels the accessions of a SEED alignment using RNAcentral
    identifiers. This is done by matching the seed sequences, with
    sequences existing in RNAcentral using md5 hashing.

    seed: A reformatted seed in Pfam format
    dest_dir: The path to the destination directory. None by default

    return: The path to the relabelled SEED alignement
    
Relabels the accessions of a SEED alignment using RNAcentral
identifiers. This is done by matching the seed sequences, with
sequences existing in RNAcentral using md5 hashing.

A reformatted seed in Pfam format
dest_dir: The path to the destination directory. None by default

The path to the relabelled SEED alignement
Relabels the accessions of a SEED alignment using RNAcentral identifiers . This is done by matching the seed sequences with sequences existing in RNAcentral using md5 hashing . A reformatted seed in Pfam format dest_dir : The path to the destination directory . None by default The path to the relabelled SEED alignement
def relabel_seeds_from_rnacentral_md5_mapping(seed, dest_dir=None):
    if dest_dir is None:
        dest_dir = os.path.split(seed)[0]
    sequence_label = 0
    new_line = ''
    filename = os.path.split(seed)[1].partition('.')[0]
    new_seed_loc = os.path.join(dest_dir, filename+'_relabelled')
    seed_fp = open(seed, 'r')
    new_seed_fp = open(new_seed_loc, 'w')
    for line in seed_fp:
        if line[0] != '#' and len(line) > 1 and line[0:2] != '//':
            line_elements = [x for x in line.strip().split(' ') if x != '']
            miRNA_seq = line_elements[1].replace('.', '')
            miRNA_seq = miRNA_seq.replace('-', '').replace('T', 'U').replace('t', 'u')
            sequence_label = generate_seed_id_from_RNAcentral(miRNA_seq.upper())
            new_line = "\t".join([sequence_label, miRNA_seq.upper(), '\n'])
        else:
            new_line = line
        new_seed_fp.write(new_line)
    seed_fp.close()
    return new_seed_loc
def relabel_seeds_from_rnacentral_md5_mapping ( seed , dest_dir = None ) : if dest_dir is None : dest_dir = os . path . split ( seed ) [ 0 ] sequence_label = 0 new_line = '' filename = os . path . split ( seed ) [ 1 ] . partition ( '.' ) [ 0 ] new_seed_loc = os . path . join ( dest_dir , filename + '_relabelled' ) seed_fp = open ( seed , 'r' ) new_seed_fp = open ( new_seed_loc , 'w' ) for line in seed_fp : if line [ 0 ] != '#' and len ( line ) > 1 and line [ 0 : 2 ] != '//' : line_elements = [ x for x in line . strip ( ) . split ( ' ' ) if x != '' ] miRNA_seq = line_elements [ 1 ] . replace ( '.' , '' ) miRNA_seq = miRNA_seq . replace ( '-' , '' ) . replace ( 'T' , 'U' ) . replace ( 't' , 'u' ) sequence_label = generate_seed_id_from_RNAcentral ( miRNA_seq . upper ( ) ) new_line = "\t" . join ( [ sequence_label , miRNA_seq . upper ( ) , '\n' ] ) else : new_line = line new_seed_fp . write ( new_line ) seed_fp . close ( ) return new_seed_loc
Relabels the accessions of a SEED alignment using RNAcentral
identifiers.
Relabels the accessions of a SEED alignment using RNAcentral identifiers .
"""
    Relabels the accessions of a SEED alignment using RNAcentral
    identifiers. This is done by matching the seed sequences, with
    sequences existing in RNAcentral using md5 hashing.

    seed: A reformatted seed in Pfam format
    dest_dir: The path to the destination directory. None by default

    return: The path to the relabelled SEED alignement
    """ # fetch path of seed alignment # check if this is an actual sequence line # replace alignment characters
seed
dest_dir