def __init__(self, name, configuration_dict, non_ids=None, display_synonyms=None, kv_separator='__', kvsv_separator='=', nested_separator='\"\"', sorted_by_key=True, first_ks=None, last_ks=None, length_limit=255): super(Configuration, self).__init__() self.name = name self.dict = configuration_dict self.sorted_by_key = sorted_by_key self.kv_separator = kv_separator self.kvsv_separator = kvsv_separator self.nested_separator = nested_separator self.length_limit = length_limit self.display_synonyms = display_synonyms if display_synonyms else {} self.first_ks = first_ks if first_ks else [] self.last_ks = last_ks if last_ks else [] #Keys here won't make it to the configuration string if not non_ids: self.non_ids = set() elif is_iterable(non_ids): self.non_ids = set(non_ids) else: raise Exception('non_ids must be None or an iterable')
def assign_feature(self, substructures): if not is_iterable(substructures): substructures = (substructures,) features = self.hash(substructures) % self.fold_size if self._save_map: for feature, key in izip(features, substructures): self._features[feature].add(key) return features
def molids2mols(self, molids): """Returns a list of rdkit molecules (None also possible) for the molids.""" if not is_iterable(molids): molids = (molids,) return list(map(self.molid2mol, molids))