示例#1
0
  @Override
  protected void doWork(String inputSource, VcfIterator r, VariantContextWriter w)
      throws IOException {
    VCFHeader header = r.getHeader();

    VCFHeader h2 = new VCFHeader(header.getMetaDataInInputOrder(), header.getSampleNamesInOrder());
    h2.addMetaDataLine(
        new VCFInfoHeaderLine(
            TAG,
            VCFHeaderLineCount.UNBOUNDED,
            VCFHeaderLineType.String,
            "metadata added from " + TABIX + " . Format was " + FORMAT));
    h2.addMetaDataLine(
        new VCFHeaderLine(
            getClass().getSimpleName() + "CmdLine", String.valueOf(getProgramCommandLine())));
    h2.addMetaDataLine(
        new VCFHeaderLine(getClass().getSimpleName() + "Version", String.valueOf(getVersion())));
    h2.addMetaDataLine(
        new VCFHeaderLine(
            getClass().getSimpleName() + "HtsJdkVersion", HtsjdkVersion.getVersion()));
    h2.addMetaDataLine(
        new VCFHeaderLine(getClass().getSimpleName() + "HtsJdkHome", HtsjdkVersion.getHome()));

    SAMSequenceDictionaryProgress progress = new SAMSequenceDictionaryProgress(header);
    w.writeHeader(h2);
    while (r.hasNext()) {
      VariantContext ctx = progress.watch(r.next());
      Set<String> annotations = new HashSet<String>();

      CloseableIterator<BedLine> iter =
          this.bedReader.iterator(ctx.getContig(), ctx.getStart() - 1, ctx.getEnd() + 1);
      while (iter.hasNext()) {
        BedLine bedLine = iter.next();

        if (!ctx.getContig().equals(bedLine.getContig())) continue;
        if (ctx.getStart() - 1 >= bedLine.getEnd()) continue;
        if (ctx.getEnd() - 1 < bedLine.getStart()) continue;

        String newannot = this.parsedFormat.toString(bedLine);
        if (!newannot.isEmpty()) annotations.add(VCFUtils.escapeInfoField(newannot));
      }
      CloserUtil.close(iter);

      if (annotations.isEmpty()) {
        w.add(ctx);
        continue;
      }
      VariantContextBuilder vcb = new VariantContextBuilder(ctx);
      vcb.attribute(TAG, annotations.toArray());
      w.add(vcb.make());
      incrVariantCount();
      if (checkOutputError()) break;
    }
    progress.finish();
  }
  @Override
  protected void doWork(String source, VcfIterator in, VariantContextWriter out)
      throws IOException {
    try {
      VCFHeader header = in.getHeader();
      VCFHeader h2 = new VCFHeader(header);
      h2.addMetaDataLine(
          new VCFHeaderLine(
              getClass().getSimpleName() + "CmdLine", String.valueOf(getProgramCommandLine())));
      h2.addMetaDataLine(
          new VCFHeaderLine(getClass().getSimpleName() + "Version", String.valueOf(getVersion())));
      h2.addMetaDataLine(
          new VCFHeaderLine(
              getClass().getSimpleName() + "HtsJdkVersion", HtsjdkVersion.getVersion()));
      h2.addMetaDataLine(
          new VCFHeaderLine(getClass().getSimpleName() + "HtsJdkHome", HtsjdkVersion.getHome()));

      out.writeHeader(h2);

      final VepPredictionParser vepParser = new VepPredictionParser(header);
      final SnpEffPredictionParser snpEffparser = new SnpEffPredictionParser(header);
      final MyPredictionParser myPredParser = new MyPredictionParser(header);
      SAMSequenceDictionaryProgress progress =
          new SAMSequenceDictionaryProgress(header.getSequenceDictionary());
      while (in.hasNext()) {
        this.checkKnimeCancelled();

        VariantContext ctx = progress.watch(in.next());
        boolean keep = false;

        for (SnpEffPredictionParser.SnpEffPrediction pred : snpEffparser.getPredictions(ctx)) {
          if (hasUserTem(pred.getSOTerms())) {
            keep = true;
            break;
          }
        }
        if (!keep) {
          for (VepPredictionParser.VepPrediction pred : vepParser.getPredictions(ctx)) {
            if (hasUserTem(pred.getSOTerms())) {
              keep = true;
              break;
            }
          }
        }
        if (!keep) {
          for (MyPredictionParser.MyPrediction pred : myPredParser.getPredictions(ctx)) {
            if (hasUserTem(pred.getSOTerms())) {
              keep = true;
              break;
            }
          }
        }
        if (isInverseResult()) keep = !keep;
        if (keep) {
          incrVariantCount();
          out.add(ctx);
        }
        if (checkOutputError()) break;
      }
      progress.finish();
    } finally {
    }
  }