def get_sam_ids(map_data, map_header, colorby, cat, primary_state, secondary_state):
 if (colorby is None):
  sample_ids = [sam[0] for sam in map_data]
 else:
  sample_ids = get_sample_ids(map_data, map_header, {colorby: [cat]})
 primary_states = parse_metadata_state_descriptions(primary_state)
 if (colorby is not None):
  primary_states[colorby] = [cat]
 state1_samids = get_sample_ids(map_data, map_header, primary_states)
 if (secondary_state is None):
  state2_samids = set(sample_ids).difference(set(state1_samids))
 else:
  secondary_states = parse_metadata_state_descriptions(secondary_state)
  if (colorby is not None):
   secondary_states[colorby] = [cat]
  state2_samids = get_sample_ids(map_data, map_header, secondary_states)
 return (list(set(state1_samids)), list(set(state2_samids)))

def get_sam_ids ( map_data , map_header , colorby , cat , primary_state , secondary_state ) : if ( colorby is None ) : sample_ids = [ sam [ 0 ] for sam in map_data ] else : sample_ids = get_sample_ids ( map_data , map_header , { colorby : [ cat ] } ) primary_states = parse_metadata_state_descriptions ( primary_state ) if ( colorby is not None ) : primary_states [ colorby ] = [ cat ] state1_samids = get_sample_ids ( map_data , map_header , primary_states ) if ( secondary_state is None ) : state2_samids = set ( sample_ids ) . difference ( set ( state1_samids ) ) else : secondary_states = parse_metadata_state_descriptions ( secondary_state ) if ( colorby is not None ) : secondary_states [ colorby ] = [ cat ] state2_samids = get_sample_ids ( map_data , map_header , secondary_states ) return ( list ( set ( state1_samids ) ) , list ( set ( state2_samids ) ) )
returns all sample ids matching the state strings and colorby:cat colorby: eg: country .