def sampleId_pairs(mapping_data, rarefaction_data, category):
 sids = rarefaction_data[0][3:]
 categories = []
 check = 0
 for k in sids:
  try:
   categories.append(mapping_data[k][category])
  except KeyError:
   check += 1
 if (check == len(sids)):
  raise ValueError(("No samples had a value for category: '%s'." % category))
 combos = list(combinations(set(categories), 2))
 sid_pairs = []
 for (pair0, pair1) in combos:
  pair0_sids = [sid for sid in sids if ((category in mapping_data[sid]) and (mapping_data[sid][category] == pair0))]
  pair1_sids = [sid for sid in sids if ((category in mapping_data[sid]) and (mapping_data[sid][category] == pair1))]
  sid_pairs.append((pair0_sids, pair1_sids))
 return (sid_pairs, combos)

def sampleId_pairs ( mapping_data , rarefaction_data , category ) : sids = rarefaction_data [ 0 ] [ 3 : ] categories = [ ] check = 0 for k in sids : try : categories . append ( mapping_data [ k ] [ category ] ) except KeyError : check += 1 if ( check == len ( sids ) ) : raise ValueError ( ( "No samples had a value for category: '%s'." % category ) ) combos = list ( combinations ( set ( categories ) , 2 ) ) sid_pairs = [ ] for ( pair0 , pair1 ) in combos : pair0_sids = [ sid for sid in sids if ( ( category in mapping_data [ sid ] ) and ( mapping_data [ sid ] [ category ] == pair0 ) ) ] pair1_sids = [ sid for sid in sids if ( ( category in mapping_data [ sid ] ) and ( mapping_data [ sid ] [ category ] == pair1 ) ) ] sid_pairs . append ( ( pair0_sids , pair1_sids ) ) return ( sid_pairs , combos )
returns list of sampleid tuples .