code: def _freebayes_cutoff(in_file, data):
      
      if not vcfutils.vcf_has_variants(in_file):
          base, ext = utils.splitext_plus(in_file)
          out_file = "{base}-filter{ext}".format(**locals())
          if not utils.file_exists(out_file):
              shutil.copy(in_file, out_file)
          if out_file.endswith(".vcf.gz"):
              out_file = vcfutils.bgzip_and_index(out_file, data["config"])
          return out_file
  
      depth_thresh, qual_thresh = None, None
      if _do_high_depth_filter(data):
          stats = _calc_vcf_stats(in_file)
          if stats["avg_depth"] > 0:
              depth_thresh = int(math.ceil(stats["avg_depth"] + 3 * math.pow(stats["avg_depth"], 0.5)))
              qual_thresh = depth_thresh * 2.0  # Multiplier from default GATK QD cutoff filter
      filters = ('(AF[0] <= 0.5 && (max(FORMAT/DP) < 4 || (max(FORMAT/DP) < 13 && %QUAL < 10))) || '
                 '(AF[0] > 0.5 && (max(FORMAT/DP) < 4 && %QUAL < 50))')
      if depth_thresh:
          filters += ' || (%QUAL < {qual_thresh} && max(FORMAT/DP) > {depth_thresh} && AF[0] <= 0.5)'.format(**locals())
      return cutoff_w_expression(in_file, filters, data, name="FBQualDepth")
docs: Perform filtering of FreeBayes results, flagging low confidence calls.
  
      Filters using cutoffs on low depth based on Meynert et al's work modeling sensitivity
      of homozygote and heterozygote calling on depth:
  
      http://www.ncbi.nlm.nih.gov/pubmed/23773188
  
      and high depth heterozygote SNP filtering based on Heng Li's work
      evaluating variant calling artifacts:
  
      http://arxiv.org/abs/1404.0929
  
      Tuned based on NA12878 call comparisons to Genome in a Bottle reference genome.