scripts/preprocessing/relabel_seed.py
def fix_coordinates(seed_file, dest_dir=None):
    """
    Replaces 0 starting points with 1s in SEED sequences

    seed_file: Seed alignment in Stockhold format

    dest_dir: dest_dir: Destination directory where the output will be
    generated

    return: The path to the updated SEED
    """

    filename = os.path.basename(seed_file).partition('.')[0]

    pfam_aln = stockhom_to_pfam_format(seed_file, dest_dir=dest_dir)

    if pfam_aln is None:
        sys.exit("Unsuccessul stockholm to pfam conversion!")

    fp = open(pfam_aln, 'r')
    outfile = os.path.join(dest_dir, filename + '_corrected.pfam')
    fp_out = open(outfile, 'w')

    new_line = ''
    for line in fp:
        seq_dict = {}

        if line[0] != '#' and len(line) > 1 and line[0:2] != '//':
            line = [x for x in line.strip().split(' ') if x != '']
            seed_seq = line[1].replace('.', '').replace('-', '').replace('T', 'U').replace('t', 'u').upper()
            label_elements = line[0].split('/')
            coords = label_elements[1].split('-')
            new_label = ''
            new_label = label_elements[0] + '/' + str(int(coords[0])+1) + '-' + coords[1]
            seq_dict[label_elements[0]] = fetch_sequence_from_rnacentral(label_elements[0])
            temp_fasta = write_fasta_file(seq_dict, "temp", dest_dir)

            test_seq = fetch_sequence_from_file(temp_fasta, label_elements[0], str(int(coords[0])+1) + '-' + coords[1])
            check = validate_sequences(seed_seq, test_seq)

            if check is False:
                fp_out.close()
                print ("Incorrect coordinates for seequence %s" % label_elements[0])
                return None

            elements = [new_label]
            elements.extend(line[1:])
            new_line = "\t".join(elements) + '\n'

        else:
            new_line = line

        fp_out.write(new_line)

    fp.close()
    fp_out.close()

    if os.path.exists(outfile):
        return outfile

    return None

    Replaces 0 starting points with 1s in SEED sequences

    seed_file: Seed alignment in Stockhold format

    dest_dir: dest_dir: Destination directory where the output will be
    generated

    return: The path to the updated SEED
    
Replaces 0 starting points with 1s in SEED sequences
seed_file: Seed alignment in Stockhold format

Destination directory where the output will be
generated

The path to the updated SEED
Replaces 0 starting points with 1s in SEED sequences seed_file : Seed alignment in Stockhold format Destination directory where the output will be generated The path to the updated SEED
def fix_coordinates(seed_file, dest_dir=None):
    filename = os.path.basename(seed_file).partition('.')[0]
    pfam_aln = stockhom_to_pfam_format(seed_file, dest_dir=dest_dir)
    if pfam_aln is None:
        sys.exit("Unsuccessul stockholm to pfam conversion!")
    fp = open(pfam_aln, 'r')
    outfile = os.path.join(dest_dir, filename + '_corrected.pfam')
    fp_out = open(outfile, 'w')
    new_line = ''
    for line in fp:
        seq_dict = {}
        if line[0] != '#' and len(line) > 1 and line[0:2] != '//':
            line = [x for x in line.strip().split(' ') if x != '']
            seed_seq = line[1].replace('.', '').replace('-', '').replace('T', 'U').replace('t', 'u').upper()
            label_elements = line[0].split('/')
            coords = label_elements[1].split('-')
            new_label = ''
            new_label = label_elements[0] + '/' + str(int(coords[0])+1) + '-' + coords[1]
            seq_dict[label_elements[0]] = fetch_sequence_from_rnacentral(label_elements[0])
            temp_fasta = write_fasta_file(seq_dict, "temp", dest_dir)
            test_seq = fetch_sequence_from_file(temp_fasta, label_elements[0], str(int(coords[0])+1) + '-' + coords[1])
            check = validate_sequences(seed_seq, test_seq)
            if check is False:
                fp_out.close()
                print ("Incorrect coordinates for seequence %s" % label_elements[0])
                return None
            elements = [new_label]
            elements.extend(line[1:])
            new_line = "\t".join(elements) + '\n'
        else:
            new_line = line
        fp_out.write(new_line)
    fp.close()
    fp_out.close()
    if os.path.exists(outfile):
        return outfile
    return None
def fix_coordinates ( seed_file , dest_dir = None ) : filename = os . path . basename ( seed_file ) . partition ( '.' ) [ 0 ] pfam_aln = stockhom_to_pfam_format ( seed_file , dest_dir = dest_dir ) if pfam_aln is None : sys . exit ( "Unsuccessul stockholm to pfam conversion!" ) fp = open ( pfam_aln , 'r' ) outfile = os . path . join ( dest_dir , filename + '_corrected.pfam' ) fp_out = open ( outfile , 'w' ) new_line = '' for line in fp : seq_dict = { } if line [ 0 ] != '#' and len ( line ) > 1 and line [ 0 : 2 ] != '//' : line = [ x for x in line . strip ( ) . split ( ' ' ) if x != '' ] seed_seq = line [ 1 ] . replace ( '.' , '' ) . replace ( '-' , '' ) . replace ( 'T' , 'U' ) . replace ( 't' , 'u' ) . upper ( ) label_elements = line [ 0 ] . split ( '/' ) coords = label_elements [ 1 ] . split ( '-' ) new_label = '' new_label = label_elements [ 0 ] + '/' + str ( int ( coords [ 0 ] ) + 1 ) + '-' + coords [ 1 ] seq_dict [ label_elements [ 0 ] ] = fetch_sequence_from_rnacentral ( label_elements [ 0 ] ) temp_fasta = write_fasta_file ( seq_dict , "temp" , dest_dir ) test_seq = fetch_sequence_from_file ( temp_fasta , label_elements [ 0 ] , str ( int ( coords [ 0 ] ) + 1 ) + '-' + coords [ 1 ] ) check = validate_sequences ( seed_seq , test_seq ) if check is False : fp_out . close ( ) print ( "Incorrect coordinates for seequence %s" % label_elements [ 0 ] ) return None elements = [ new_label ] elements . extend ( line [ 1 : ] ) new_line = "\t" . join ( elements ) + '\n' else : new_line = line fp_out . write ( new_line ) fp . close ( ) fp_out . close ( ) if os . path . exists ( outfile ) : return outfile return None
Replaces 0 starting points with 1s in SEED sequences
seed_file: Seed alignment in Stockhold format
Replaces 0 starting points with 1s in SEED sequences seed_file : Seed alignment in Stockhold format
"""
    Replaces 0 starting points with 1s in SEED sequences

    seed_file: Seed alignment in Stockhold format

    dest_dir: dest_dir: Destination directory where the output will be
    generated

    return: The path to the updated SEED
    """
seed_file
dest_dir