def strip_msa(msa, threshold, plot = False):
msa = [seq for seq in parse_fasta(msa)]<EOL>columns = [[<NUM_LIT:0>, <NUM_LIT:0>] for pos in msa[<NUM_LIT:0>][<NUM_LIT:1>]] <EOL>for seq in msa:<EOL><INDENT>for position, base in enumerate(seq[<NUM_LIT:1>]):<EOL><INDENT>if base == '<STR_LIT:->' or base == '<STR_LIT:.>':<EOL><INDENT>columns[position][<NUM_LIT:1>] += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>columns[position][<NUM_LIT:0>] += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>columns = [float(float(g)/float(g+b)*<NUM_LIT:100>) for b, g in columns] <EOL>for seq in msa:<EOL><INDENT>stripped = []<EOL>for position, base in enumerate(seq[<NUM_LIT:1>]):<EOL><INDENT>if columns[position] <= threshold:<EOL><INDENT>stripped.append(base)<EOL><DEDENT><DEDENT>yield [seq[<NUM_LIT:0>], '<STR_LIT>'.join(stripped)]<EOL><DEDENT>if plot is not False:<EOL><INDENT>plot_gaps(plot, columns)<EOL><DEDENT>
strip out columns of a MSA that represent gaps for X percent (threshold) of sequences