コード例 #1
0
ファイル: CountRODs.java プロジェクト: mlovci/gatk
  public Datum map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
    GenomeLoc cur = context.getLocation();

    if (verbose && showSkipped) {
      for (long i = context.getSkippedBases(); i >= 0; i--) {
        SAMSequenceDictionary dictionary =
            getToolkit().getReferenceDataSource().getReference().getSequenceDictionary();
        SAMSequenceRecord contig = dictionary.getSequence(cur.getContig());
        if (cur.getStop() < contig.getSequenceLength())
          cur = getToolkit().getGenomeLocParser().incPos(cur, 1);
        else
          cur =
              getToolkit()
                  .getGenomeLocParser()
                  .createGenomeLoc(
                      dictionary.getSequence(contig.getSequenceIndex() + 1).getSequenceName(),
                      1,
                      1);
        out.printf("%s: skipped%n", cur);
      }
    }

    long nRodsHere = 0;
    long nTotalBases = 0;

    if (ref == null) {
      // we're getting the last skipped update
      if (verbose)
        out.printf(
            "Last position was %s: skipping %d bases%n",
            context.getLocation(), context.getSkippedBases());
      nRodsHere = -1; // don't update this
      nTotalBases = context.getSkippedBases();
    } else {
      Collection<RODRecordList> rods = new LinkedList<RODRecordList>();
      for (RODRecordList rod : tracker.getBoundRodTracks()) {
        // System.out.printf("Considering rod %s%n", rod);
        if (rod.getLocation().getStart() == context.getLocation().getStart()
            && !rod.getName().equals("interval")) {
          // only consider the first element
          // System.out.printf("adding it%n");
          rods.add(rod);
        }
      }

      nRodsHere = rods.size();

      if (nRodsHere > 0) {
        if (verbose) {
          List<String> names = new ArrayList<String>();
          for (RODRecordList rod : rods) {
            names.add(rod.getName());
          }

          // System.out.printf("context is %s", context.getSkippedBases());
          out.printf(
              "At %s: found %d rod(s) [%s] after skipping %d bases%n",
              context.getLocation(), nRodsHere, Utils.join(",", names), context.getSkippedBases());
        }
      }

      nTotalBases = context.getSkippedBases() + 1;
    }

    return new Datum(nRodsHere, context.getSkippedBases(), nTotalBases);
  }
コード例 #2
0
ファイル: RODRecordListImpl.java プロジェクト: mlovci/gatk
 /**
  * Compares this object with the specified object for order. Returns a negative integer, zero, or
  * a positive integer as this object is less than, equal to, or greater than the specified object.
  *
  * @param that the object to be compared.
  * @return a negative integer, zero, or a positive integer as this object is less than, equal to,
  *     or greater than the specified object.
  * @throws ClassCastException if the specified object's type prevents it from being compared to
  *     this object.
  */
 public int compareTo(RODRecordList that) {
   return getLocation()
       .compareTo(
           that.getLocation()); // To change body of implemented methods use File | Settings | File
   // Templates.
 }