def extract_seqs_by_sample_id(seqs, sample_ids, negate=False):
 sample_ids = {}.fromkeys(sample_ids)
 if (not negate):
  def f(s):
   return (s in sample_ids)
 else:
  def f(s):
   return (s not in sample_ids)
 for (seq_id, seq) in seqs:
  sample_id = seq_id.split('_')[0]
  if f(sample_id):
   (yield (seq_id, seq))

def extract_seqs_by_sample_id ( seqs , sample_ids , negate = False ) : sample_ids = { } . fromkeys ( sample_ids ) if ( not negate ) : def f ( s ) : return ( s in sample_ids ) else : def f ( s ) : return ( s not in sample_ids ) for ( seq_id , seq ) in seqs : sample_id = seq_id . split ( '_' ) [ 0 ] if f ( sample_id ) : ( yield ( seq_id , seq ) )
returns pairs if sample_id is in sample_ids .