示例#1
0
文件: SnpEff.java 项目: wenjiany/gatk
  @Override
  public void initialize(
      AnnotatorCompatible walker, GenomeAnalysisEngine toolkit, Set<VCFHeaderLine> headerLines) {
    // Make sure that we actually have a valid SnpEff rod binding (just in case the user specified
    // -A SnpEff
    // without providing a SnpEff rod via --snpEffFile):
    if (!isValidRodBinding(walker.getSnpEffRodBinding())) {
      canAnnotate = false;
      return;
    }

    RodBinding<VariantContext> snpEffRodBinding = walker.getSnpEffRodBinding();

    // Make sure that the SnpEff version number and command-line header lines are present in the VCF
    // header of
    // the SnpEff rod, and that the file was generated by a supported version of SnpEff:
    VCFHeader snpEffVCFHeader =
        GATKVCFUtils.getVCFHeadersFromRods(toolkit, Arrays.asList(snpEffRodBinding.getName()))
            .get(snpEffRodBinding.getName());
    VCFHeaderLine snpEffVersionLine =
        snpEffVCFHeader.getOtherHeaderLine(SNPEFF_VCF_HEADER_VERSION_LINE_KEY);
    VCFHeaderLine snpEffCommandLine =
        snpEffVCFHeader.getOtherHeaderLine(SNPEFF_VCF_HEADER_COMMAND_LINE_KEY);

    if (!isValidSnpEffVersionAndCommandLine(snpEffVersionLine, snpEffCommandLine)) {
      canAnnotate = false;
      return;
    }

    // If everything looks ok, add the SnpEff version number and command-line header lines to the
    // header of the VCF output file, changing the key names so that our output file won't be
    // mistaken in the future for a SnpEff output file:
    headerLines.add(
        new VCFHeaderLine(OUTPUT_VCF_HEADER_VERSION_LINE_KEY, snpEffVersionLine.getValue()));
    headerLines.add(
        new VCFHeaderLine(OUTPUT_VCF_HEADER_COMMAND_LINE_KEY, snpEffCommandLine.getValue()));

    // Can only be called from VariantAnnotator
    if (!(walker instanceof VariantAnnotator)) {
      if (walker != null)
        logger.warn(
            "Annotation will not be calculated, must be called from VariantAnnotator, not "
                + walker.getClass().getName());
      else logger.warn("Annotation will not be calculated, must be called from VariantAnnotator");
      canAnnotate = false;
      return;
    }
  }
示例#2
0
文件: SnpEff.java 项目: wenjiany/gatk
  private boolean isValidSnpEffVersionAndCommandLine(
      final VCFHeaderLine snpEffVersionLine, final VCFHeaderLine snpEffCommandLine) {
    if (snpEffVersionLine == null
        || snpEffVersionLine.getValue() == null
        || snpEffVersionLine.getValue().trim().length() == 0) {
      logger.warn(
          String.format(
              "Could not find a %s entry in the VCF header for the SnpEff input file, "
                  + "and so could not verify that the file was generated by a supported version of SnpEff (%s)",
              SNPEFF_VCF_HEADER_VERSION_LINE_KEY, supportedSnpEffVersionsString()));
      return false;
    }

    if (snpEffCommandLine == null
        || snpEffCommandLine.getValue() == null
        || snpEffCommandLine.getValue().trim().length() == 0) {
      logger.warn(
          String.format(
              "Could not find a %s entry in the VCF header for the SnpEff input file, "
                  + "which should be added by all supported versions of SnpEff (%s)",
              SNPEFF_VCF_HEADER_COMMAND_LINE_KEY, supportedSnpEffVersionsString()));
      return false;
    }

    String snpEffVersionString = snpEffVersionLine.getValue().replaceAll("\"", "").split(" ")[0];

    if (!isSupportedSnpEffVersion(snpEffVersionString, snpEffCommandLine.getValue())) {
      logger.warn(
          String.format(
              "The version of SnpEff used to generate the SnpEff input file (%s) "
                  + "is not currently supported by the GATK, and was not run in GATK "
                  + "compatibility mode. Supported versions are: %s",
              snpEffVersionString, supportedSnpEffVersionsString()));
      return false;
    }

    return true;
  }