def filter_aln_by_otus(aln, prefs):
 filtered_seqs = []
 removed_seqs = []
 for j in range(aln.sequence_count()):
  remove = False
  aln_name = aln[j].id
  stripped_aln_name = aln_name.split(' ')[0].split('_')
  if (len(stripped_aln_name) > 1):
   new_aln_name = ''.join(stripped_aln_name[:(-1)])
  else:
   new_aln_name = stripped_aln_name[0]
  for sample_id in prefs:
   if (prefs[sample_id] == new_aln_name):
    remove = True
  if remove:
   removed_seqs.append((aln_name, str(aln[aln_name])))
  else:
   filtered_seqs.append((aln_name, str(aln[aln_name])))
 return (filtered_seqs, removed_seqs)

def filter_aln_by_otus ( aln , prefs ) : filtered_seqs = [ ] removed_seqs = [ ] for j in range ( aln . sequence_count ( ) ) : remove = False aln_name = aln [ j ] . id stripped_aln_name = aln_name . split ( ' ' ) [ 0 ] . split ( '_' ) if ( len ( stripped_aln_name ) > 1 ) : new_aln_name = '' . join ( stripped_aln_name [ : ( - 1 ) ] ) else : new_aln_name = stripped_aln_name [ 0 ] for sample_id in prefs : if ( prefs [ sample_id ] == new_aln_name ) : remove = True if remove : removed_seqs . append ( ( aln_name , str ( aln [ aln_name ] ) ) ) else : filtered_seqs . append ( ( aln_name , str ( aln [ aln_name ] ) ) ) return ( filtered_seqs , removed_seqs )
filters the representative set of seqs based on which samples should be removed .