utils/genome_search_utils.py
def cleanup_illegal_lines_from_fasta(fasta_file, dest_dir=None):
    """
    The purpose of this function is to cleanup any illegal lines
    from merged genome fasta files. Looks for any illegal characters
    in a sequence line and skips those while re-writting the fasta file.
    Prints any illegal lines found

    fasta_file: The path to a fasta file
    dest_dir: The path to a directory where the new fasta will
    be created

    return: Void
    """
    regex = re.compile("[^ATKMBVCNSWD-GUYRHatkbbvcnswdguyrh]")

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

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

    if not os.path.exists(dest_dir):
        os.mkdir(dest_dir)

    old_fasta = open(fasta_file, 'r')
    new_fasta = open(os.path.join(dest_dir, filename+'_cleaned.fa'), 'w')

    for line in old_fasta:
        line = line.strip()
        if len(line) > 0:
            if line[0] != '>':
                # if illegal chars in sequence, continue with next line
                if regex.search(line):
                    print line
                    continue

            new_fasta.write(line + '\n')

    new_fasta.close()
    old_fasta.close()

    The purpose of this function is to cleanup any illegal lines
    from merged genome fasta files. Looks for any illegal characters
    in a sequence line and skips those while re-writting the fasta file.
    Prints any illegal lines found

    fasta_file: The path to a fasta file
    dest_dir: The path to a directory where the new fasta will
    be created

    return: Void
    
The purpose of this function is to cleanup any illegal lines
from merged genome fasta files. Looks for any illegal characters
in a sequence line and skips those while re-writting the fasta file.
Prints any illegal lines found

The path to a fasta file
dest_dir: The path to a directory where the new fasta will
be created

Void
The purpose of this function is to cleanup any illegal lines from merged genome fasta files . Looks for any illegal characters in a sequence line and skips those while re - writting the fasta file . Prints any illegal lines found The path to a fasta file dest_dir : The path to a directory where the new fasta will be created Void
def cleanup_illegal_lines_from_fasta(fasta_file, dest_dir=None):
    regex = re.compile("[^ATKMBVCNSWD-GUYRHatkbbvcnswdguyrh]")
    filename = os.path.basename(fasta_file).partition('.')[0]
    if dest_dir is None:
        dest_dir = os.path.split(fasta_file)[0]
    if not os.path.exists(dest_dir):
        os.mkdir(dest_dir)
    old_fasta = open(fasta_file, 'r')
    new_fasta = open(os.path.join(dest_dir, filename+'_cleaned.fa'), 'w')
    for line in old_fasta:
        line = line.strip()
        if len(line) > 0:
            if line[0] != '>':
                if regex.search(line):
                    print line
                    continue
            new_fasta.write(line + '\n')
    new_fasta.close()
    old_fasta.close()
def cleanup_illegal_lines_from_fasta ( fasta_file , dest_dir = None ) : regex = re . compile ( "[^ATKMBVCNSWD-GUYRHatkbbvcnswdguyrh]" ) filename = os . path . basename ( fasta_file ) . partition ( '.' ) [ 0 ] if dest_dir is None : dest_dir = os . path . split ( fasta_file ) [ 0 ] if not os . path . exists ( dest_dir ) : os . mkdir ( dest_dir ) old_fasta = open ( fasta_file , 'r' ) new_fasta = open ( os . path . join ( dest_dir , filename + '_cleaned.fa' ) , 'w' ) for line in old_fasta : line = line . strip ( ) if len ( line ) > 0 : if line [ 0 ] != '>' : if regex . search ( line ) : print line continue new_fasta . write ( line + '\n' ) new_fasta . close ( ) old_fasta . close ( )
The purpose of this function is to cleanup any illegal lines
from merged genome fasta files.
The purpose of this function is to cleanup any illegal lines from merged genome fasta files .
"""
    The purpose of this function is to cleanup any illegal lines
    from merged genome fasta files. Looks for any illegal characters
    in a sequence line and skips those while re-writting the fasta file.
    Prints any illegal lines found

    fasta_file: The path to a fasta file
    dest_dir: The path to a directory where the new fasta will
    be created

    return: Void
    """ # if illegal chars in sequence, continue with next line
fasta_file
dest_dir