def filter_otus(otus, prefs):
 new_otus_list = []
 for i in otus:
  new_otus = []
  for j in otus[i]:
   sample_seq = j.split('_')
   if (len(sample_seq) > 1):
    new_name = ''.join(sample_seq[:(-1)])
   else:
    new_name = sample_seq[0]
   is_sample = False
   for sample_id in prefs:
    if (prefs[sample_id] == new_name):
     is_sample = True
   if is_sample:
    pass
   else:
    new_otus.append(('%s' % j))
  if new_otus:
   new_otus_list.append((i, new_otus))
 return new_otus_list

def filter_otus ( otus , prefs ) : new_otus_list = [ ] for i in otus : new_otus = [ ] for j in otus [ i ] : sample_seq = j . split ( '_' ) if ( len ( sample_seq ) > 1 ) : new_name = '' . join ( sample_seq [ : ( - 1 ) ] ) else : new_name = sample_seq [ 0 ] is_sample = False for sample_id in prefs : if ( prefs [ sample_id ] == new_name ) : is_sample = True if is_sample : pass else : new_otus . append ( ( '%s' % j ) ) if new_otus : new_otus_list . append ( ( i , new_otus ) ) return new_otus_list
filters the otus file based on which samples should be removed and determines which sequences to remove .