Run filtering on the input call file, handling SNPs and indels separately.
172966
def run(call_file, ref_file, vrn_files, data):
    
    algs = [data["config"]["algorithm"]] * len(data.get("vrn_files", [1]))
    if includes_missingalt(data):
        logger.info("Removing variants with missing alts from %s." % call_file)
        call_file = gatk_remove_missingalt(call_file, data)

    if "gatkcnn" in dd.get_tools_on(data):
        return _cnn_filter(call_file, vrn_files, data)
    elif config_utils.use_vqsr(algs, call_file):
        if vcfutils.is_gvcf_file(call_file):
            raise ValueError("Cannot force gVCF output with joint calling using tools_on: [gvcf] and use VQSR. "
                             "Try using cutoff-based soft filtering with tools_off: [vqsr]")
        snp_file, indel_file = vcfutils.split_snps_indels(call_file, ref_file, data["config"])
        snp_filter_file = _variant_filtration(snp_file, ref_file, vrn_files, data, "SNP",
                                              vfilter.gatk_snp_cutoff)
        indel_filter_file = _variant_filtration(indel_file, ref_file, vrn_files, data, "INDEL",
                                                vfilter.gatk_indel_cutoff)
        orig_files = [snp_filter_file, indel_filter_file]
        out_file = "%scombined.vcf.gz" % os.path.commonprefix(orig_files)
        combined_file = vcfutils.combine_variant_files(orig_files, out_file, ref_file, data["config"])
        return combined_file
    else:
        snp_filter = vfilter.gatk_snp_cutoff(call_file, data)
        indel_filter = vfilter.gatk_indel_cutoff(snp_filter, data)
        return indel_filter
1328645
def run_genotyper(bam_file, ref_file, dbsnp_file, config_file):
    
    cl = ["gatk_genotyper.py", config_file, ref_file, bam_file]
    if dbsnp_file:
        cl.append(dbsnp_file)
    subprocess.check_call(cl)
1118912
function filter_and_recursion_processing(file) {
    const filePath = path.join(...basePath, ...directoryPath, file);

    if (path.extname(file) === extension) {
      // partial file is found, passing through filter, process it later
      return file;
    } else if (fs.statSync(filePath).isDirectory()) {
      // directory found, do recursion and get processed partials back
      partials = partials.concat(
        getPartials({
          basePath,
          directoryPath: [...directoryPath, file],
          extension,
          encoding,
          getNameFunc
        })
      );
    }

    return false;
  }
943038
def fix_input_files_for_numbered_seq(sourceDir, suffix, timestamp, containers):
    """"""
    # Fix input files for each MPL-container type.
    for container in containers:
        files = glob.glob( os.path.join( sourceDir, container, container + '*' + suffix ) )
        for currentFile in sorted( files ):
            fix_header_comment( currentFile, timestamp )
1248849
def execute(self, input_data):
        '''  '''

        # Just a small check to make sure we haven't been called on the wrong file type
        if (input_data['meta']['type_tag'] != 'exe'):
            return {'error': self.__class__.__name__+': called on '+input_data['meta']['type_tag']}

        view = {}
        view['indicators'] = list(set([item['category'] for item in input_data['pe_indicators']['indicator_list']]))
        view['peid_matches'] = input_data['pe_peid']['match_list']
        view['yara_sigs'] = input_data['yara_sigs']['matches'].keys()
        view['classification'] = input_data['pe_classifier']['classification']
        view['disass'] = self.safe_get(input_data, ['pe_disass', 'decode'])[:15]
        view.update(input_data['meta'])

        return view
999223
def _input_as_lines(self,data):
        
        if data:
            self.Parameters['--in']\
                .on(super(Clearcut,self)._input_as_lines(data))
        return ''
1180120
def execute(self, input_data):
        '''  '''
        raw_bytes = input_data['sample']['raw_bytes']

        # Analyze the output of pefile for any anomalous conditions.
        # Have the PE File module process the file
        try:
            self.pefile_handle = pefile.PE(data=raw_bytes, fast_load=False)
        except (AttributeError, pefile.PEFormatError), error:
            return {'error': str(error), 'indicator_list': [{'Error': 'PE module failed!'}]}

        indicators = []
        indicators += [{'description': warn, 'severity': 2, 'category': 'PE_WARN'} 
                       for warn in self.pefile_handle.get_warnings()]

        # Automatically invoke any method of this class that starts with 'check'
        check_methods = self._get_check_methods()
        for check_method in check_methods:
            hit_data = check_method()
            if hit_data:
                indicators.append(hit_data)

        return {'indicator_list': indicators}
1067968
function runFilter(data, filter) {
  var k, key, keys = Object.keys(filter), keysLength = keys.length;
  var i;

  if (!Object.keys(filter).length) {
    return true;
  }

  keyCheck: for (k = 0; k < keysLength; k++) {
    key = keys[k];

    // Match
    if (key.startsWith('$')) {
      //if (key.startsWith(
      switch (key) {
        case '$or':
          for (i = 0; i < filter[key].length; i++) {
            if (runFilter(data, filter[key][i])) {
              continue keyCheck;
            }
          }
          return false;
        case '$and':
          for (i = 0; i < filter[key].length; i++) {
            if (!runFilter(data, filter[key][i])) {
              return false;
            }
          }
          break;
        case '$not':
          if(runFilter(data, filter[key])) {
            return false;
          }
          break;
      }
    } else if (typeof data === 'object') {
      if (typeof filter[key] === 'object') {
        if (Object.keys(filter[key]).find(function(operator) {
          switch (operator) {
            case '$eq':
              if (data[key] instanceof Array) {
                return data[key].indexOf(filter[key]['$eq']) === -1;
              } else {
                return !data[key] || data[key] !== filter[key]['$eq'];
              }
            case '$ne':
              if (data[key] instanceof Array) {
                return data[key].indexOf(filter[key]['$ne']) !== -1;
              } else {
                return data[key] === filter[key]['$ne'];
              }
            case '$gt':
              return !data[key] || data[key] <= filter[key]['$gt'];
            case '$gte':
              return !data[key] || data[key] < filter[key]['$gte'];
            case '$lt':
              return !data[key] || data[key] >= filter[key]['$lt'];
            case '$lte':
              return !data[key] || data[key] > filter[key]['$lte'];
            case '$in':
              if (!filter[key]['$in'] instanceof Array) {
                throw new Error('$in test values should be an array');
              }

              return filter[key]['$in'].indexOf(data[key]) === -1;
            case '$nin':
              if (!filter[key]['$nin'] instanceof Array) {
                throw new Error('$in test values should be an array');
              }

              return filter[key]['$nin'].indexOf(data[key]) !== -1;
            default:
              throw new Error('Unknown operator ' + operator);
          }
        })) {
          return false;
        }
      } else if (!((data[key] instanceof Array
          && data[key].indexOf(filter[key]) !== -1)
          || data[key] === filter[key])) {
        return false;
      }
    } else {
      return false;
    }
  }

  return true;
  // TODO Handle logical operators
}
1187069
def autorun_filters(filters, doc, search_dirs, verbose):
    
    def remove_py(s):
            return s[:-3] if s.endswith('.py') else s

    filter_paths = []
    for filter_ in filters:
        filter_exp = p.normpath(p.expanduser(p.expandvars(filter_)))

        if filter_exp == remove_py(p.basename(filter_exp)).lstrip('.'):
            # import .foo  # is not supported
            module = True
            mod_path = filter_exp.replace('.', p.sep)
            path_postfixes = (p.join(mod_path, '__init__.py'), mod_path + '.py')
        else:
            module = False
            # allow with and without .py ending
            path_postfixes = (remove_py(filter_exp) + '.py',)

        for path, path_postf in [(path, path_postf)
                                 for path in search_dirs
                                 for path_postf in path_postfixes]:
            if p.isabs(path_postf):
                filter_path = path_postf
            else:
                filter_path = p.abspath(p.normpath(p.join(path, path_postf)))

            if p.isfile(filter_path):
                if verbose:
                    debug("panflute: filter <{}> found in {}".format(filter_, filter_path))

                if module and not (path in reduced_sys_path):
                    extra_dir = p.abspath(path)
                    # `path` already doesn't contain `.`, `..`, env vars or `~`
                else:
                    extra_dir = None
                module_ = filter_exp if module else filter_path

                filter_paths.append((filter_, filter_path, module_, extra_dir))
                break
            elif p.isabs(path_postf):
                if verbose:
                    debug("          filter <{}> NOT found in {}".format(filter_, filter_path))
                raise Exception("filter not found: " + filter_)
            elif verbose:
                debug("          filter <{}> NOT found in {}".format(filter_, filter_path))
        else:
            raise Exception("filter not found: " + filter_)

    for filter_, filter_path, module_, extra_dir in filter_paths:
        if verbose:
            debug("panflute: running filter <{}>".format(filter_))
        with ContextImport(module_, extra_dir) as module:
            try:
                module.main(doc)
            except Exception as e:
                debug("Failed to run filter: " + filter_)
                if not hasattr(module, 'main'):
                    debug(' - Possible cause: filter lacks a main() function')
                debug('Filter code:')
                debug('-' * 64)
                with open(filter_path) as fp:
                    debug(fp.read())
                debug('-' * 64)
                raise Exception(e)
        if verbose:
            debug("panflute: filter <{}> completed".format(filter_))

    return doc
271251
def _filter_file(src, dest, subst):
    
    substre = re.compile(r'\$(%s)' % '|'.join(subst.keys()))
    def repl(m):
        return subst[m.group(1)]
    with open(src, "rt") as sf, open(dest, "wt") as df:
        while True:
            l = sf.readline()
            if not l:
                break
            df.write(re.sub(substre, repl, l))
469003
def run(self) -> Generator[Tuple[int, int, str, type], None, None]:
        
        if self.filename != STDIN:
            buffer = StringIO()
            options = _Options(aggressive=self.options.eradicate_aggressive)
            fix_file(self.filename, options, buffer)
            traceback = buffer.getvalue()

            if traceback:
                yield 1, 0, self._error(traceback), type(self)
710072
def filter(self, table, idps, filter_string):
        """"""
        q = filter_string.lower()
        return [idp for idp in idps
                if q in idp.ud.lower()]
367664
def filter_data(self, data, values=None, args=None):
        """"""
        if args:
            if not args.pattern:
                return data
        if not values: values = args.pattern
        newdata = {}
        if 'parser' in data.keys():
            newdata['parser'] = data['parser']
            newdata['source_path'] = data['source_path']
            newdata['source_file'] = data['source_file']
            newdata['source_file_mtime'] = data['source_file_mtime']
            newdata['source_file_year'] = data['source_file_year']
        newdata['entries'] = []

        repatterns = {}
        for pat in values:
            repatterns[pat] = re.compile(r".*({}).*".format(pat))

        for entry in data['entries']:
            for repat in repatterns:
                if re.match(repatterns[repat], entry['raw_text']):
                    newdata['entries'].append(entry)
                    break

        return newdata
178675
def selectSNPsAccordingToLD(options):
    
    # The plink command
    outPrefix = options.out + ".pruning_" + options.indep_pairwise[2]
    plinkCommand = [
        "plink",
        "--noweb",
        "--bfile", options.bfile,
        "--maf", options.maf,
        "--indep-pairwise",
    ] + options.indep_pairwise + ["--out", outPrefix]

    runCommand(plinkCommand)

    # Finding the autosomal markers
    autosomes = {str(i) for i in range(1, 23)}
    autosomal_snps = set()
    with open(options.bfile + ".bim", "r") as i_file:
        for line in i_file:
            chrom, snp = line.rstrip("\r\n").split("\t")[:2]
            if chrom in autosomes:
                autosomal_snps.add(snp)

    # Reading the pruned markers
    pruned_snps = None
    with open(outPrefix + ".prune.in", "r") as i_file:
        pruned_snps = set(i_file.read().splitlines())

    # Writing the pruned markers located on an autosome
    with open(outPrefix + ".prune.in.autosomal", "w") as o_file:
        for snp in autosomal_snps & pruned_snps:
            print >>o_file, snp

    return outPrefix + ".prune.in.autosomal"
213106
def clean(inputline, strip=True, rem_indents=True, encoding_errors="replace"):
    """"""
    stdout_encoding = get_encoding(sys.stdout)
    inputline = str(inputline)
    if rem_indents:
        inputline = inputline.replace(openindent, "").replace(closeindent, "")
    if strip:
        inputline = inputline.strip()
    return inputline.encode(stdout_encoding, encoding_errors).decode(stdout_encoding)
328412
function filter(file) {
    if (files.indexOf(file) !== -1) return false;
    let include = true;
    regexs.forEach((regex) => {
      if (file.search(regex) !== -1) include = false;
    });
    return include;
  }
729904
def scrub(data):
    """"""
    # blanks, Nones, and empty strings can stay as is
    if not data:
        return data
    if isinstance(data, (int, float)):
        return data
    if isinstance(data, list):
        return [scrub(entry) for entry in data]
    if isinstance(data, dict):
        return {scrub(key): scrub(value) for key, value in data.items()}
    try:
        return json.encoder.encode_basestring(data)[1:-1]
    except TypeError as exc:
        raise ValidationError("Input '%s' is not a permitted type: %s" % (data,
                                                                          exc))
    except Exception as exc:
        raise ValidationError("Input '%s' not permitted: %s" % (data, exc))