scripts/preprocessing/relabel_seed.py
def relabel_seed_accessions(seed, accession_coords, dest_dir = None):
    """
    Re-writes a seed file with the sequence coordinates appended to the
    sequence accessions

    seed: A seed file with no star-end sequence coordinates

    return: The path to the newly relabelled SEED alignment
    """

    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 != '']

            sequence_label = line_elements[0] + '/' + accession_coords[line_elements[0]]

            new_line = "\t".join([sequence_label, line_elements[1], '\n'])
        else:
            new_line = line

        new_seed_fp.write(new_line)

    seed_fp.close()

    return new_seed_loc

    Re-writes a seed file with the sequence coordinates appended to the
    sequence accessions

    seed: A seed file with no star-end sequence coordinates

    return: The path to the newly relabelled SEED alignment
    
Re-writes a seed file with the sequence coordinates appended to the
sequence accessions

A seed file with no star-end sequence coordinates

The path to the newly relabelled SEED alignment
Re - writes a seed file with the sequence coordinates appended to the sequence accessions A seed file with no star - end sequence coordinates The path to the newly relabelled SEED alignment
def relabel_seed_accessions(seed, accession_coords, 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 != '']
            sequence_label = line_elements[0] + '/' + accession_coords[line_elements[0]]
            new_line = "\t".join([sequence_label, line_elements[1], '\n'])
        else:
            new_line = line
        new_seed_fp.write(new_line)
    seed_fp.close()
    return new_seed_loc
def relabel_seed_accessions ( seed , accession_coords , 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 != '' ] sequence_label = line_elements [ 0 ] + '/' + accession_coords [ line_elements [ 0 ] ] new_line = "\t" . join ( [ sequence_label , line_elements [ 1 ] , '\n' ] ) else : new_line = line new_seed_fp . write ( new_line ) seed_fp . close ( ) return new_seed_loc
Re-writes a seed file with the sequence coordinates appended to the
sequence accessions
Re - writes a seed file with the sequence coordinates appended to the sequence accessions
"""
    Re-writes a seed file with the sequence coordinates appended to the
    sequence accessions

    seed: A seed file with no star-end sequence coordinates

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