/**
  * Target information string composer for the genomic coordinate part of the target.
  *
  * @param index the index of a target within the collection.
  * @param collection the containing target collection.
  * @return never {@code null}.
  */
 private static String coordinateComposer(
     final int index, final TargetCollection<Target> collection) {
   final SimpleInterval location = collection.location(index);
   if (location == null) {
     return String.join(COLUMN_SEPARATOR, NO_VALUE_STRING, NO_VALUE_STRING, NO_VALUE_STRING);
   } else {
     return String.format(
         String.join(COLUMN_SEPARATOR, "%s", "%d", "%d"),
         location.getContig(),
         location.getStart(),
         location.getEnd());
   }
 }
 @DataProvider(name = "exonLookUpData")
 public Object[][] exonLookUpData() {
   final List<Object[]> result = new ArrayList<>();
   for (int i = 0; i < nonOverlappingExomeIntervals.size(); i++) {
     result.add(
         new Object[] {
           nonOverlappingExomeIntervals.get(i), nonOverlappingExomeIntervals.get(i), i
         });
   }
   for (int i = 0; i < nonOverlappingExomeIntervals.size(); i++) {
     final SimpleInterval interval = nonOverlappingExomeIntervals.get(i);
     result.add(
         new Object[] {
           new SimpleInterval(interval.getContig(), interval.getStart(), interval.getStart()),
           interval,
           i
         });
   }
   for (int i = 0; i < nonOverlappingExomeIntervals.size(); i++) {
     final SimpleInterval interval = nonOverlappingExomeIntervals.get(i);
     result.add(
         new Object[] {
           new SimpleInterval(interval.getContig(), interval.getEnd(), interval.getEnd()),
           interval,
           i
         });
   }
   for (int i = 1; i < nonOverlappingExomeIntervals.size(); i++) {
     final SimpleInterval previous = nonOverlappingExomeIntervals.get(i - 1);
     final SimpleInterval next = nonOverlappingExomeIntervals.get(i);
     final SimpleInterval query =
         previous.getContig().equals(next.getContig())
             ? ExomeToolsTestUtils.createInterval(
                 previous.getContig(), previous.getEnd() + 1, next.getStart() - 1)
             : ExomeToolsTestUtils.createInterval(next.getContig(), 1, next.getStart() - 1);
     result.add(new Object[] {query, null, -i - 1});
   }
   return result.toArray(new Object[result.size()][]);
 }
Пример #3
0
 /**
  * Returns all the intervals that overlap with the query. The query doesn't *have* to be in the
  * same contig as the intervals we hold, but of course if it isn't you'll get an empty result. You
  * may modify the returned list.
  */
 public ArrayList<T> getOverlapping(SimpleInterval query) {
   if (!contig.equals(query.getContig())) {
     // different contig, so we know no one'll overlap.
     return new ArrayList<T>();
   }
   ArrayList<T> ret = new ArrayList<T>();
   // use index to skip early non-overlapping entries.
   int idx = firstPotentiallyReaching(query.getStart());
   if (idx < 0) {
     idx = 0;
   }
   for (; idx < vs.size(); idx++) {
     T v = vs.get(idx);
     // they are sorted by start location, so if this one starts too late
     // then all of the others will, too.
     if (v.getStart() > query.getEnd()) {
       break;
     }
     if (query.overlaps(v)) {
       ret.add(v);
     }
   }
   return ret;
 }
Пример #4
0
 /**
  * Determines the start of the expanded reference window, bounded by 1.
  *
  * @param locus The locus to expand.
  * @param windowLeadingBases number of bases to attempt to expand relative to the locus start (>=
  *     0)
  * @return The start of the expanded window.
  */
 private int calculateWindowStart(final SimpleInterval locus, final int windowLeadingBases) {
   return Math.max(locus.getStart() - windowLeadingBases, 1);
 }
Пример #5
0
 /**
  * Get the number of extra bases of context before the start of our interval, as configured by a
  * call to {@link #setWindow} or at construction time.
  *
  * <p>Actual number of bases may be less than originally requested if the interval is near a
  * contig boundary.
  *
  * @return number of extra bases of context before the start of our interval
  */
 public int numWindowLeadingBases() {
   return window == null ? 0 : interval.getStart() - window.getStart();
 }