def get_filter_to_core_f(table, sample_ids=None, fraction_for_core=1.0):
 if (not (0.0 <= fraction_for_core <= 1.0)):
  raise ValueError(('invalid fraction_for_core passed to core filter: %1.2f is outside of range [0,1].' % fraction_for_core))
 if (sample_ids is None):
  position_mask = array(([True] * len(table.ids())))
 else:
  position_mask = array([(s in sample_ids) for s in table.ids()])
 min_count = (fraction_for_core * position_mask.sum())
 def f(values, obs_ids, obs_md):
  return (((values != 0) & position_mask).sum() >= min_count)
 return f

def get_filter_to_core_f ( table , sample_ids = None , fraction_for_core = 1.0 ) : if ( not ( 0.0 <= fraction_for_core <= 1.0 ) ) : raise ValueError ( ( 'invalid fraction_for_core passed to core filter: %1.2f is outside of range [0,1].' % fraction_for_core ) ) if ( sample_ids is None ) : position_mask = array ( ( [ True ] * len ( table . ids ( ) ) ) ) else : position_mask = array ( [ ( s in sample_ids ) for s in table . ids ( ) ] ) min_count = ( fraction_for_core * position_mask . sum ( ) ) def f ( values , obs_ids , obs_md ) : return ( ( ( values != 0 ) & position_mask ) . sum ( ) >= min_count ) return f
return function that filters a table to its core observations table: the biom-format table object to filter sample_ids: list of sample ids of interest for the core computation fraction_for_core: the fraction of the sample_ids that an observation must have a non-zero count for to be considered a core observation .