scripts/preprocessing/relabel_seed.py
def seed_to_fasta(seed_msa, dest_dir=None):
    """
    Converts a multiple sequence alignment (MSA) to fasta

    param seed_msa: A valid Rfam SEED file in stockholm format to convert to fasta

    return: Path to updated seed file
    """

    filename = ""

    path_elements = os.path.split(seed_msa)

    if dest_dir is None:
        dest_dir = path_elements[0]

    if "." in path_elements[1]:
        filename = path_elements[1].partition('.')[0]
    else:
        filename = path_elements[1]

    cmd = "esl-sfetch -o %s -f %s %s"

    seed_fp = open(seed_msa, 'r')
    tmp_acc_list = os.path.join("/tmp", filename + "_acc_list.txt")
    tmp_acc_fp = open(tmp_acc_list, 'w')

    for line in seed_fp:
        line = line.strip()

        if line != '' and line[0] != "#":
            accession = line.split(' ')[0]

            if accession.find('//') == -1:
                tmp_acc_fp.write(accession+'\n')

    seed_fp.close()
    tmp_acc_fp.close()

    seed_fasta_path = os.path.join(dest_dir, filename + '.fa')
    subprocess.call(cmd % (seed_fasta_path, seed_msa, tmp_acc_list), shell=True)

    # clean temp file
    os.remove(tmp_acc_list)

    # return None if the fasta file was not created
    if not os.path.exists:
        return None

    return seed_fasta_path

    Converts a multiple sequence alignment (MSA) to fasta

    param seed_msa: A valid Rfam SEED file in stockholm format to convert to fasta

    return: Path to updated seed file
    
Converts a multiple sequence alignment (MSA) to fasta
param seed_msa: A valid Rfam SEED file in stockholm format to convert to fasta

Path to updated seed file
Converts a multiple sequence alignment ( MSA ) to fasta param seed_msa : A valid Rfam SEED file in stockholm format to convert to fasta Path to updated seed file
def seed_to_fasta(seed_msa, dest_dir=None):
    filename = ""
    path_elements = os.path.split(seed_msa)
    if dest_dir is None:
        dest_dir = path_elements[0]
    if "." in path_elements[1]:
        filename = path_elements[1].partition('.')[0]
    else:
        filename = path_elements[1]
    cmd = "esl-sfetch -o %s -f %s %s"
    seed_fp = open(seed_msa, 'r')
    tmp_acc_list = os.path.join("/tmp", filename + "_acc_list.txt")
    tmp_acc_fp = open(tmp_acc_list, 'w')
    for line in seed_fp:
        line = line.strip()
        if line != '' and line[0] != "#":
            accession = line.split(' ')[0]
            if accession.find('//') == -1:
                tmp_acc_fp.write(accession+'\n')
    seed_fp.close()
    tmp_acc_fp.close()
    seed_fasta_path = os.path.join(dest_dir, filename + '.fa')
    subprocess.call(cmd % (seed_fasta_path, seed_msa, tmp_acc_list), shell=True)
    os.remove(tmp_acc_list)
    if not os.path.exists:
        return None
    return seed_fasta_path
def seed_to_fasta ( seed_msa , dest_dir = None ) : filename = "" path_elements = os . path . split ( seed_msa ) if dest_dir is None : dest_dir = path_elements [ 0 ] if "." in path_elements [ 1 ] : filename = path_elements [ 1 ] . partition ( '.' ) [ 0 ] else : filename = path_elements [ 1 ] cmd = "esl-sfetch -o %s -f %s %s" seed_fp = open ( seed_msa , 'r' ) tmp_acc_list = os . path . join ( "/tmp" , filename + "_acc_list.txt" ) tmp_acc_fp = open ( tmp_acc_list , 'w' ) for line in seed_fp : line = line . strip ( ) if line != '' and line [ 0 ] != "#" : accession = line . split ( ' ' ) [ 0 ] if accession . find ( '//' ) == - 1 : tmp_acc_fp . write ( accession + '\n' ) seed_fp . close ( ) tmp_acc_fp . close ( ) seed_fasta_path = os . path . join ( dest_dir , filename + '.fa' ) subprocess . call ( cmd % ( seed_fasta_path , seed_msa , tmp_acc_list ) , shell = True ) os . remove ( tmp_acc_list ) if not os . path . exists : return None return seed_fasta_path
Converts a multiple sequence alignment (MSA) to fasta
param seed_msa: A valid Rfam SEED file in stockholm format to convert to fasta
Converts a multiple sequence alignment ( MSA ) to fasta param seed_msa : A valid Rfam SEED file in stockholm format to convert to fasta
"""
    Converts a multiple sequence alignment (MSA) to fasta

    param seed_msa: A valid Rfam SEED file in stockholm format to convert to fasta

    return: Path to updated seed file
    """ # clean temp file # return None if the fasta file was not created
seed_msa
dest_dir