scripts/preprocessing/relabel_seed.py
def rewrite_seed_with_sscons(input_seed, ss_cons, dest_dir=None):
    """
    Rewrites a SEED alignment in stockholm format with a ss_cons

    param input_seed: Initial seed to rewrite and add ss_cons to.
    The seed alignment needs to be in stockholm format

    param ss_cons: Consensus secondary structure to add to the alignment

    return: The path to the new SEED is successful, otherwise None
    """

    if dest_dir is None:
        dest_dir = os.path.split(input_seed)[0]

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

    new_seed_loc = os.path.join(dest_dir, filename + "ss_cons.stk")

    new_seed_fp = open(new_seed_loc, 'w')

    old_seed_fp = open(input_seed, 'r')

    for line in old_seed_fp:
        # write all lines in new file
        if line.find("//") == -1:
            new_seed_fp.write(line)
        else:
            # now we are going to write the ss_cons
            new_seed_fp.write(ss_cons + '\n' + "\\" + '\n')

    old_seed_fp.close()
    new_seed_fp.close()

    if os.path.exists(new_seed_fp) and os.path.getsize(new_seed_fp) > 0:
        return new_seed_loc

    return None

    Rewrites a SEED alignment in stockholm format with a ss_cons

    param input_seed: Initial seed to rewrite and add ss_cons to.
    The seed alignment needs to be in stockholm format

    param ss_cons: Consensus secondary structure to add to the alignment

    return: The path to the new SEED is successful, otherwise None
    
Rewrites a SEED alignment in stockholm format with a ss_cons
param input_seed: Initial seed to rewrite and add ss_cons to.
The seed alignment needs to be in stockholm format

param ss_cons: Consensus secondary structure to add to the alignment

The path to the new SEED is successful, otherwise None
Rewrites a SEED alignment in stockholm format with a ss_cons param input_seed : Initial seed to rewrite and add ss_cons to . The seed alignment needs to be in stockholm format param ss_cons : Consensus secondary structure to add to the alignment The path to the new SEED is successful otherwise None
def rewrite_seed_with_sscons(input_seed, ss_cons, dest_dir=None):
    if dest_dir is None:
        dest_dir = os.path.split(input_seed)[0]
    filename = os.path.basename(input_seed).partition('.')[0]
    new_seed_loc = os.path.join(dest_dir, filename + "ss_cons.stk")
    new_seed_fp = open(new_seed_loc, 'w')
    old_seed_fp = open(input_seed, 'r')
    for line in old_seed_fp:
        if line.find("//") == -1:
            new_seed_fp.write(line)
        else:
            new_seed_fp.write(ss_cons + '\n' + "\\" + '\n')
    old_seed_fp.close()
    new_seed_fp.close()
    if os.path.exists(new_seed_fp) and os.path.getsize(new_seed_fp) > 0:
        return new_seed_loc
    return None
def rewrite_seed_with_sscons ( input_seed , ss_cons , dest_dir = None ) : if dest_dir is None : dest_dir = os . path . split ( input_seed ) [ 0 ] filename = os . path . basename ( input_seed ) . partition ( '.' ) [ 0 ] new_seed_loc = os . path . join ( dest_dir , filename + "ss_cons.stk" ) new_seed_fp = open ( new_seed_loc , 'w' ) old_seed_fp = open ( input_seed , 'r' ) for line in old_seed_fp : if line . find ( "//" ) == - 1 : new_seed_fp . write ( line ) else : new_seed_fp . write ( ss_cons + '\n' + "\\" + '\n' ) old_seed_fp . close ( ) new_seed_fp . close ( ) if os . path . exists ( new_seed_fp ) and os . path . getsize ( new_seed_fp ) > 0 : return new_seed_loc return None
Rewrites a SEED alignment in stockholm format with a ss_cons
param input_seed: Initial seed to rewrite and add ss_cons to.
Rewrites a SEED alignment in stockholm format with a ss_cons param input_seed : Initial seed to rewrite and add ss_cons to .
"""
    Rewrites a SEED alignment in stockholm format with a ss_cons

    param input_seed: Initial seed to rewrite and add ss_cons to.
    The seed alignment needs to be in stockholm format

    param ss_cons: Consensus secondary structure to add to the alignment

    return: The path to the new SEED is successful, otherwise None
    """ # write all lines in new file # now we are going to write the ss_cons
input_seed
ss_cons
dest_dir