def query(self, *tags, **kwtags): """ :type position_cutoff: float or int :param position_cutoff: only optimizations with position less than the cutoff are returned. """ opts = super(SequenceDB, self).query(*tags, **kwtags) position_cutoff = kwtags.pop('position_cutoff', config.optdb.position_cutoff) if len(tags) >= 1 and isinstance(tags[0], Query): #the call to super should have raise an error with a good message assert len(tags) == 1 if getattr(tags[0], 'position_cutoff', None): position_cutoff = tags[0].position_cutoff opts = [o for o in opts if self.__position__[o.name] < position_cutoff] # We want to sort by position and then if collision by name # for deterministic optimization. Since Python 2.2, sort is # stable, so sort by name first, then by position. This give # the order we want. opts.sort(key=lambda obj: obj.name) opts.sort(key=lambda obj: self.__position__[obj.name]) ret = opt.SeqOptimizer(opts, failure_callback=self.failure_callback) if hasattr(tags[0], 'name'): ret.name = tags[0].name return ret
def query(self, *tags, **kwtags): """ :type position_cutoff: float or int :param position_cutoff: only optimizations with position less than the cutoff are returned. """ opts = super(SequenceDB, self).query(*tags, **kwtags) position_cutoff = kwtags.pop('position_cutoff', config.optdb.position_cutoff) if len(tags) >= 1 and isinstance(tags[0], Query): #the call to super should have raise an error with a good message assert len(tags) == 1 if getattr(tags[0], 'position_cutoff', None): position_cutoff = tags[0].position_cutoff opts = [o for o in opts if self.__position__[o.name] < position_cutoff] opts.sort(key=lambda obj: self.__position__[obj.name]) ret = opt.SeqOptimizer(opts, failure_callback=self.failure_callback) if hasattr(tags[0], 'name'): ret.name = tags[0].name return ret