def __init__(self, effects, distinct=False, sort_key=None, sources=set([])): """ Parameters ---------- effects : list Collection of any class which is compatible with the sort key distinct : bool Only keep distinct entries or allow duplicates. sort_key : fn Function which maps each element to a sorting criterion. sources : set Set of files from which this collection was generated. """ self.effects = effects Collection.__init__(self, elements=effects, distinct=distinct, sort_key=sort_key, sources=sources)
def __init__( self, binding_predictions, path=None, distinct=True, sort_key=lambda x: x.value): Collection.__init__( self, elements=binding_predictions, sources=[path] if path else [], distinct=distinct, sort_key=sort_key)
def __init__( self, variants, distinct=True, sort_key=variant_ascending_position_sort_key, sources=None, source_to_metadata_dict={}): """ Construct a VariantCollection from a list of Variant records. Parameters ---------- variants : iterable Variant objects contained in this VariantCollection distinct : bool Don't keep repeated variants sort_key : callable sources : set Optional set of source names, may be larger than those for which we have metadata dictionaries. source_to_metadata_dict : dict Dictionary mapping each source name (e.g. VCF path) to a dictionary from metadata attributes to values. """ self.source_to_metadata_dict = source_to_metadata_dict self.variants = variants if sources is None: sources = set(source_to_metadata_dict.keys()) if any(source not in sources for source in source_to_metadata_dict.keys()): raise ValueError( "Mismatch between sources=%s and keys of source_to_metadata_dict=%s" % ( sources, set(source_to_metadata_dict.keys()))) Collection.__init__( self, elements=variants, distinct=distinct, sort_key=sort_key, sources=sources)
def __init__(self, variants, distinct=True, sort_key=variant_ascending_position_sort_key, sources=None, source_to_metadata_dict={}): """ Construct a VariantCollection from a list of Variant records. Parameters ---------- variants : iterable Variant objects contained in this VariantCollection distinct : bool Don't keep repeated variants sort_key : callable sources : set Optional set of source names, may be larger than those for which we have metadata dictionaries. source_to_metadata_dict : dict Dictionary mapping each source name (e.g. VCF path) to a dictionary from metadata attributes to values. """ self.source_to_metadata_dict = source_to_metadata_dict self.variants = variants if sources is None: sources = set(source_to_metadata_dict.keys()) if any(source not in sources for source in source_to_metadata_dict.keys()): raise ValueError( "Mismatch between sources=%s and keys of source_to_metadata_dict=%s" % (sources, set(source_to_metadata_dict.keys()))) Collection.__init__(self, elements=variants, distinct=distinct, sort_key=sort_key, sources=sources)
def __init__(self, effects, distinct=False, sort_key=None, sources=set([])): """ Parameters ---------- effects : list Collection of any class which is compatible with the sort key distinct : bool Only keep distinct entries or allow duplicates. sort_key : fn Function which maps each element to a sorting criterion. sources : set Set of files from which this collection was generated. """ self.effects = effects Collection.__init__( self, elements=effects, distinct=distinct, sort_key=sort_key, sources=sources)
def clone_with_new_elements(self, new_elements): return Collection.clone_with_new_elements( self, new_elements, rename_dict={"elements": "effects"})