コード例 #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
  @Override
  public Map<String, Object> annotate(
      final RefMetaDataTracker tracker,
      final AnnotatorCompatible walker,
      final ReferenceContext ref,
      final Map<String, AlignmentContext> stratifiedContexts,
      final VariantContext vc,
      final Map<String, PerReadAlleleLikelihoodMap> stratifiedPerReadAlleleLikelihoodMap) {

    // Can not annotate if failed initialization conditions
    if (!canAnnotate) return null;

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

    // Get only SnpEff records that start at this locus, not merely span it:
    List<VariantContext> snpEffRecords = tracker.getValues(snpEffRodBinding, ref.getLocus());

    // Within this set, look for a SnpEff record whose ref/alt alleles match the record to annotate.
    // If there is more than one such record, we only need to pick the first one, since the
    // biological
    // effects will be the same across all such records:
    VariantContext matchingRecord = getMatchingSnpEffRecord(snpEffRecords, vc);
    if (matchingRecord == null) {
      return null;
    }

    // Parse the SnpEff INFO field annotation from the matching record into individual effect
    // objects:
    List<SnpEffEffect> effects = parseSnpEffRecord(matchingRecord);
    if (effects.isEmpty()) {
      return null;
    }

    // Add only annotations for one of the most biologically-significant effects from this set:
    SnpEffEffect mostSignificantEffect = getMostSignificantEffect(effects);
    return mostSignificantEffect.getAnnotations();
  }