Add a FILTER value to a cyvcf2 record
508685
def cyvcf_add_filter(rec, name):
    
    if rec.FILTER:
        filters = rec.FILTER.split(";")
    else:
        filters = []
    if name not in filters:
        filters.append(name)
        rec.FILTER = filters
    return rec
1062390
private Filter createValueMatchFilter(
      FilterAdapterContext context, SingleColumnValueFilter filter) throws IOException {
    ValueFilter valueFilter = new ValueFilter(filter.getOperator(), filter.getComparator());
    return delegateAdapter.toFilter(context, valueFilter);
  }
939533
def attach_filter(fd, bpf_filter, iface):
    """"""
    bp = compile_filter(bpf_filter, iface)
    # Assign the BPF program to the interface
    ret = LIBC.ioctl(c_int(fd), BIOCSETF, cast(pointer(bp), c_char_p))
    if ret < 0:
        raise Scapy_Exception("Can't attach the BPF filter !")
841573
def filter(self, table, vg_snapshots, filter_string):
        """"""
        query = filter_string.lower()
        return [vg_snapshot for vg_snapshot in vg_snapshots
                if query in vg_snapshot.name.lower()]
629432
def _delly_count_evidence_filter(in_file, data):
    
    filtname = "DVSupport"
    filtdoc = "FMT/DV < 4 || (SR < 1 && PE < 5) || (SR < 5 && PE < 1)"
    out_file = "%s-filter%s" % utils.splitext_plus(in_file)
    cur_out_file = out_file.replace(".vcf.gz", ".vcf")
    if not utils.file_exists(out_file):
        with file_transaction(data, cur_out_file) as tx_out_file:
            with utils.open_gzipsafe(in_file) as in_handle:
                with open(tx_out_file, "w") as out_handle:
                    inp = vcf.Reader(in_handle, in_file)
                    inp.filters["DVSupport"] = vcf.parser._Filter(filtname, filtdoc)
                    outp = vcf.Writer(out_handle, inp)
                    for rec in inp:
                        sr = rec.INFO.get("SR", 0)
                        pe = rec.INFO.get("PE", 0)
                        call = rec.samples[0].data
                        dv = call.DV if hasattr(call, "DV") else 0
                        if dv < 4 or (sr < 1 and pe < 5) or (sr < 5 and pe < 1):
                            rec.add_filter(filtname)
                        outp.write_record(rec)
    if out_file.endswith(".vcf.gz"):
        out_file = vcfutils.bgzip_and_index(cur_out_file, data["config"])
    return out_file
927850
def _do_filter(cnf, args):
    
    if args.query:
        cnf = API.query(cnf, args.query)
    elif args.get:
        cnf = _do_get(cnf, args.get)
    elif args.set:
        (key, val) = args.set.split('=')
        API.set_(cnf, key, anyconfig.parser.parse(val))

    return cnf
1127174
def add_filter(self, filter_key, operator, value):
        
        filter_key = self._metadata_map.get(filter_key, filter_key)
        self.filters.append({'filter': filter_key, 'operator': operator, 'value': value})
1246576
public void addSubFileFilter()
    {
        ContactType recContactType = (ContactType)((ReferenceField)this.getScreenRecord().getField(MessageLogScreenRecord.CONTACT_TYPE_ID)).getReference();
        Record recHeader = this.getHeaderRecord();
        if (recHeader != null)
        {
            recContactType = recContactType.getContactType(recHeader);
            this.getScreenRecord().getField(MessageLogScreenRecord.CONTACT_TYPE_ID).moveFieldToThis(recContactType.getField(ContactType.ID));   // Display the field
            if ((recHeader.getEditMode() == DBConstants.EDIT_CURRENT) || (recHeader.getEditMode() == DBConstants.EDIT_IN_PROGRESS))
                this.getScreenRecord().getField(MessageLogScreenRecord.CONTACT_ID).moveFieldToThis(recHeader.getField(VirtualRecord.ID));   // Display the field
        }
        Record recMessageDetail = this.getMainRecord();
        this.getMainRecord().addListener(new CompareFileFilter(this.getMainRecord().getField(MessageLog.CONTACT_TYPE_ID), this.getScreenRecord().getField(MessageLogScreenRecord.CONTACT_TYPE_ID), DBConstants.EQUALS, null, true));
        this.getScreenRecord().getField(MessageLogScreenRecord.CONTACT_TYPE_ID).addListener(new FieldReSelectHandler(this));
        
        this.getMainRecord().addListener(new CompareFileFilter(this.getMainRecord().getField(MessageLog.CONTACT_ID), this.getScreenRecord().getField(MessageLogScreenRecord.CONTACT_ID), DBConstants.EQUALS, null, true));
        FieldListener listener = null;
        this.getScreenRecord().getField(MessageLogScreenRecord.CONTACT_ID).addListener(listener = new FieldListener(null)
        {
            public int fieldChanged(boolean bDisplayOption, int iMoveMode)
            {
                String iKeyOrder = MessageLog.CONTACT_TYPE_ID_KEY;
                if (this.getOwner().isNull())
                    iKeyOrder = MessageLog.MESSAGE_TIME_KEY;
                getMainRecord().setKeyArea(iKeyOrder);
                return super.fieldChanged(bDisplayOption, iMoveMode);
            }
        });
        listener.fieldChanged(true, DBConstants.INIT_MOVE); // Initialize EY order.
        this.getScreenRecord().getField(MessageLogScreenRecord.CONTACT_ID).addListener(new FieldReSelectHandler(this));
    }
619019
def add_filter(filter, filter_options = {})
      filter = RequestLogAnalyzer::Filter.const_get(RequestLogAnalyzer.to_camelcase(filter)) if filter.is_a?(Symbol)
      @filters << filter.new(source.file_format, @options.merge(filter_options))
    end
1311155
def apply_filters(query, args):
    
    pre_joins = []
    for querystring_key, filter_value in args.items(multi=True):
        if querystring_key in filter_registry:
            cls_inst = filter_registry[querystring_key]
            query = cls_inst.apply_filter(query, args, pre_joins)
        elif querystring_key in PaginationKeys._value_list:
            pass
        else:
            raise InvalidQueryString(querystring_key, filter_value)
    return query
837051
def filter_record(self, record):
        

        if len(record) >= self.min_length:
            return record
        else:
            raise FailedFilter(len(record))
898081
def add_filter_by_client(self, query, out_params):
        
        current_client = logged_in_client(self.context)
        if current_client:
            query['getClientUID'] = api.get_uid(current_client)
        elif self.request.form.get("ClientUID", ""):
            query['getClientUID'] = self.request.form['ClientUID']
            client = api.get_object_by_uid(query['getClientUID'])
            out_params.append({'title': _('Client'),
                               'value': client.Title(),
                               'type': 'text'})
858502
def filter(self, record):
        '''
        '''

        # When running in XBMC, any logged statements will be double printed
        # since we are calling xbmc.log() explicitly. Therefore we return False
        # so every log message is filtered out and not printed again.
        if CLI_MODE:
            return True
        else:
            # Must not be imported until here because of import order issues
            # when running in CLI
            from xbmcswift2 import xbmc
            xbmc_level = XBMCFilter.xbmc_levels.get(
                XBMCFilter.python_to_xbmc.get(record.levelname))
            xbmc.log('%s%s' % (self.prefix, record.getMessage()), xbmc_level)
            return False
132807
def form_for_filterrific(record, options = {}, &block)
      options[:as] ||= :filterrific
      options[:html] ||= {}
      options[:html][:method] ||= :get
      options[:html][:id] ||= :filterrific_filter
      options[:url] ||= url_for(
        :controller => controller.controller_name,
        :action => controller.action_name
      )
      form_for(record, options, &block)
    end
1027631
def run_filter_calculation(self):
        """"""
        inputs = {
            'cif': self.inputs.cif,
            'code': self.inputs.cif_filter,
            'parameters': self.inputs.cif_filter_parameters,
            'metadata': {
                'options': self.inputs.options.get_dict(),
            }
        }

        calculation = self.submit(CifFilterCalculation, **inputs)
        self.report('submitted {}<{}>'.format(CifFilterCalculation.__name__, calculation.uuid))

        return ToContext(cif_filter=calculation)
234561
def _filter_by_background(base_name, back_samples, gt_vcfs, data):
    
    filtname = "InBackground"
    filtdoc = "Variant also present in background samples with same genotype"
    orig_vcf = gt_vcfs[base_name]
    out_file = "%s-backfilter.vcf" % (utils.splitext_plus(orig_vcf)[0])
    if not utils.file_exists(out_file) and not utils.file_exists(out_file + ".gz"):
        with file_transaction(data, out_file) as tx_out_file:
            with utils.open_gzipsafe(orig_vcf) as in_handle:
                inp = vcf.Reader(in_handle, orig_vcf)
                inp.filters[filtname] = vcf.parser._Filter(filtname, filtdoc)
                with open(tx_out_file, "w") as out_handle:
                    outp = vcf.Writer(out_handle, inp)
                    for rec in inp:
                        if _genotype_in_background(rec, base_name, back_samples):
                            rec.add_filter(filtname)
                        outp.write_record(rec)
    if utils.file_exists(out_file + ".gz"):
        out_file = out_file + ".gz"
    gt_vcfs[base_name] = vcfutils.bgzip_and_index(out_file, data["config"])
    return gt_vcfs
1094648
def fix(source_key, rownum, line, source, sample_only_filter, sample_size):
    
    value = json2value(line)

    if rownum == 0:
        if len(line) > MAX_RECORD_LENGTH:
            _shorten(source_key, value, source)
        value = _fix(value)
        if sample_only_filter and Random.int(int(1.0/coalesce(sample_size, 0.01))) != 0 and jx.filter([value], sample_only_filter):
            # INDEX etl.id==0, BUT NO MORE
            if value.etl.id != 0:
                Log.error("Expecting etl.id==0")
            row = {"value": value}
            return row, True
    elif len(line) > MAX_RECORD_LENGTH:
        _shorten(source_key, value, source)
        value = _fix(value)
    elif '"resource_usage":' in line:
        value = _fix(value)

    row = {"value": value}
    return row, False