Include the sequence elements matching the filter set.
495231
def including(self, sequence) -> Generator:
        """"""
        return (element for element in sequence
                if self.indexer(element) in self.predicates)
600006
public void setImportSequences(String[] sequences) {
        for (String s : sequences) {
            s = s.trim();
            if (s.length() > 0) {
                String[] ts = s.split("\\s+");
                List<String> sequence = new ArrayList<String>();
                for (String t : ts) {
                    t = t.trim();
                    if (t.length() > 0) {
                        sequence.add(t);
                    }
                }
                this.importSequences.add(new StringSequence(sequence));
            }
        }
    }
1154833
def join_filter(sep, seq, pred=bool):
    
    return sep.join([text_type(i) for i in seq if pred(i)])
1169256
def _filter(self, text, context, encoding):
        """"""

        content = []
        blocks, attributes, comments = self.to_text(bs4.BeautifulSoup(text, self.parser))
        if self.comments:
            for c, desc in comments:
                content.append(filters.SourceText(c, context + ': ' + desc, encoding, self.type + 'comment'))
        if self.attributes:
            for a, desc in attributes:
                content.append(filters.SourceText(a, context + ': ' + desc, encoding, self.type + 'attribute'))
        for b, desc in blocks:
            content.append(filters.SourceText(b, context + ': ' + desc, encoding, self.type + 'content'))
        return content
1219585
def match_subgroup(sequence, pattern):
    """"""

    for element in sequence:
        match = re.match(pattern, element)

        if match:
            yield match.groupdict()
1285026
public void fitOnSequences(Integer[][] sequences) {
        documentCount += 1;
        for (Integer[] sequence: sequences) {
            Set<Integer> sequenceSet = new HashSet<>(Arrays.asList(sequence));
            for (Integer index: sequenceSet)
                indexDocs.put(index, indexDocs.get(index) + 1);
        }
    }
695186
private void filter(ValueSet filterValueSet, ValueSet valueSet) {
        if (filterValueSet != null && valueSet != null && !filterValueSet.isEmpty() && !valueSet.isEmpty()) {
            Iterator it = filterValueSet.iterator();
            while (it.hasNext()) {
                Object o = it.next();
                if (valueSet.contains(o)) {
                    it.remove();
                }
            }
        }
    }
448704
def _combine(self, other, conn='and'):
        
        f = F()

        self_filters = copy.deepcopy(self.filters)
        other_filters = copy.deepcopy(other.filters)

        if not self.filters:
            f.filters = other_filters
        elif not other.filters:
            f.filters = self_filters
        elif conn in self.filters[0]:
            f.filters = self_filters
            f.filters[0][conn].extend(other_filters)
        elif conn in other.filters[0]:
            f.filters = other_filters
            f.filters[0][conn].extend(self_filters)
        else:
            f.filters = [{conn: self_filters + other_filters}]

        return f
914010
def get_interested_subsequences(subsequences):#, subseqdim):
    
    keep_indices = []
    # if subseqdim == 'ALLD':
    #     filter_subseq_suffixes = filter_subseq_suffixes
    # elif subseqdim == '3D':
    #     filter_subseq_suffixes = filter_subseq_3D_suffixes
    # elif subseqdim == '2D':
    #     filter_subseq_suffixes = filter_subseq_2D_suffixes
    # else:
    #     raise ValueError('ALLD, 3D, or 2D only!')

    for subseq in subsequences:
        if subseq == 'all':
            keep_indices.extend([x for x in filter_subseq_suffixes[subseq]])
        else:
            keep_indices.extend([subseq + '_' + x for x in filter_subseq_suffixes[subseq]])
    return keep_indices
36388
def match(self, seq, **kwargs):
        '''
        '''
        strict = kwargs.get('strict', False)
        top_level = kwargs.get('top_level', True)
        match = kwargs.get('match', list())

        if top_level:
            kwargs['top_level'] = False
            kwargs['match'] = match

            try:
                seq = IterableList(seq)
                self.match(seq, **kwargs)

                if strict:
                    if not seq.empty():
                        raise MatchFailed('Sequence is too long', seq)

            except MatchFailed as e:
                return e.failure()

            return Match(*match)

        for elem in self.elems:
            elem.match(seq, **kwargs)
305777
def add_sequence(tag, options={})
      add(s = Sequence.new(tag, options))
      s
    end
710699
def Filter(self, match=None, **_):
    """"""
    arg = self.stack.pop(-1)

    # Filters can be specified as a comma separated list.
    for filter_name in match.group(1).split(","):
      filter_object = ConfigFilter.classes_by_name.get(filter_name)
      if filter_object is None:
        raise FilterError("Unknown filter function %r" % filter_name)

      if not filter_object.sensitive_arg:
        logging.debug("Applying filter %s for %s.", filter_name, arg)
      arg = filter_object().Filter(arg)
      precondition.AssertType(arg, Text)

    self.stack[-1] += arg
336163
def Compile(self, filter_implementation):
    """"""
    arguments = [self.attribute]
    for argument in self.args:
      arguments.append(argument.Compile(filter_implementation))
    expander = filter_implementation.FILTERS['ValueExpander']
    context_cls = filter_implementation.FILTERS['Context']
    return context_cls(arguments=arguments,
                       value_expander=expander)
1210375
def _add_filter_node(root, filter_, value):
        """"""
        filter_el = ElementTree.SubElement(root, 'Filter')
        filter_el.set('name', filter_.name)

        # Set filter value depending on type.
        if filter_.type == 'boolean':
            # Boolean case.
            if value is True or value.lower() in {'included', 'only'}:
                filter_el.set('excluded', '0')
            elif value is False or value.lower() == 'excluded':
                filter_el.set('excluded', '1')
            else:
                raise ValueError('Invalid value for boolean filter ({})'
                                 .format(value))
        elif isinstance(value, list) or isinstance(value, tuple):
            # List case.
            filter_el.set('value', ','.join(map(str, value)))
        else:
            # Default case.
            filter_el.set('value', str(value))
229585
def filter_seq(seq):
     ''''''
     if seq.res:
          return None
     n = nt.Factors(seq.factors)
     guide, s, t = aq.canonical_form(n)
     seq.guide = guide
     # The target_tau for the composite is at most the class minus extant prime factor count
     cls = aq.get_class(guide=guide)
     num_larges = seq.factors.count('P')
     upper_bound_tau = cls - num_larges - len(t)

     if cls < 2 or upper_bound_tau < 2: # Cheap tests to eliminate almost all sequences
          return None

     # Next we ignore sequences whose guide is solely a power of 2 greater than 3
     v = nt.Factors({p: a for p, a in guide.items() if p != 2 and a > 0})
     if int(v) == 1 and cls > 3:
          return None
     # This condition greatly reduces fdb load, but excludes a lot of sequences
     if not aq.is_driver(guide=guide):
          return None

     return n, guide
890250
def filter_rep_set(inF, otuSet):
    
    seqs = []
    for record in SeqIO.parse(inF, "fasta"):
        if record.id in otuSet:
            seqs.append(record)
    return seqs
191789
def add_filter_set(self, filter_name, filter_set, cached=True):
        
        try:
            hash(filter_name)
        except TypeError as err:
            raise ValueError('Filter set name must be as instance of hashable type: %s' % str(err))

        if not isinstance(filter_set, list):
            raise ValueError('Filters must be a list.')

        if len(filter_set) == 0:
            raise ValueError('Filters count must be greater than 0.')

        for filter_instance in filter_set:
            if not isinstance(filter_instance, ImagineFilterInterface):
                raise ValueError('All filters must implement of ImagineFilterInterface.')

        if not isinstance(cached, bool):
            raise ValueError('Cached parameter must be a bool.')

        filter_config = {
            'filters': filter_set,
            'cached': cached
        }

        if filter_name not in self._filter_sets:
            self._filter_sets.update({filter_name: filter_config})
        else:
            raise ValueError('Duplicate filter set name.')