Beispiel #1
0
 public SeqSymmetry optimizeRequest(final SeqSpan span) {
   final MutableSeqSymmetry query_sym = new SimpleMutableSeqSymmetry();
   query_sym.addSpan(span);
   SeqSymmetry optimized_sym = SeqUtils.exclusive(query_sym, this.requestSym, span.getBioSeq());
   optimized_sym = SeqUtils.exclusive(optimized_sym, this.currentRequestSym, span.getBioSeq());
   if (SeqUtils.hasSpan(optimized_sym)) {
     return optimized_sym;
   }
   return null;
 }
Beispiel #2
0
 public boolean isLoaded(final SeqSpan span) {
   final MutableSeqSymmetry query_sym = new SimpleMutableSeqSymmetry();
   query_sym.addSpan(span);
   final SeqSymmetry optimized_sym =
       SeqUtils.exclusive(query_sym, this.requestSym, span.getBioSeq());
   return !SeqUtils.hasSpan(optimized_sym);
 }
Beispiel #3
0
 public final void removeCurrentRequest(final SeqSpan span) {
   for (int i = 0; i < this.currentRequestSym.getChildCount(); ++i) {
     final SeqSymmetry sym = this.currentRequestSym.getChild(i);
     if (span == sym.getSpan(span.getBioSeq())) {
       this.currentRequestSym.removeChild(sym);
     }
   }
 }
Beispiel #4
0
 private static void writeOutChildren(
     final DataOutputStream out,
     final SymWithProps propsym,
     final int min,
     final int max,
     final int childcount,
     final SeqSymmetry sym,
     final BioSeq seq)
     throws IOException {
   out.write(9);
   if (propsym != null && propsym.getProperty("cds min") != null) {
     out.write(propsym.getProperty("cds min").toString().getBytes());
   } else {
     out.write(Integer.toString(min).getBytes());
   }
   out.write(9);
   if (propsym != null && propsym.getProperty("cds max") != null) {
     out.write(propsym.getProperty("cds max").toString().getBytes());
   } else {
     out.write(Integer.toString(max).getBytes());
   }
   out.write(9);
   out.write(48);
   out.write(9);
   out.write(Integer.toString(childcount).getBytes());
   out.write(9);
   final int[] blockSizes = new int[childcount];
   final int[] blockStarts = new int[childcount];
   for (int i = 0; i < childcount; ++i) {
     final SeqSymmetry csym = sym.getChild(i);
     final SeqSpan cspan = csym.getSpan(seq);
     blockSizes[i] = cspan.getLength();
     blockStarts[i] = cspan.getMin() - min;
   }
   for (int i = 0; i < childcount; ++i) {
     out.write(Integer.toString(blockSizes[i]).getBytes());
     out.write(44);
   }
   out.write(9);
   for (int i = 0; i < childcount; ++i) {
     out.write(Integer.toString(blockStarts[i]).getBytes());
     out.write(44);
   }
 }
Beispiel #5
0
 private static void writeOutFile(
     final DataOutputStream out,
     final BioSeq seq,
     final SeqSpan span,
     final SeqSymmetry sym,
     final SymWithProps propsym)
     throws IOException {
   out.write(seq.getID().getBytes());
   out.write(9);
   final int min = span.getMin();
   final int max = span.getMax();
   out.write(Integer.toString(min).getBytes());
   out.write(9);
   out.write(Integer.toString(max).getBytes());
   final int childcount = sym.getChildCount();
   if (!span.isForward() || childcount > 0 || propsym != null) {
     out.write(9);
     if (propsym != null) {
       if (propsym.getProperty("name") != null) {
         out.write(((String) propsym.getProperty("name")).getBytes());
       } else if (propsym.getProperty("id") != null) {
         out.write(((String) propsym.getProperty("id")).getBytes());
       }
     }
     out.write(9);
     if (propsym != null && propsym.getProperty("score") != null) {
       out.write(propsym.getProperty("score").toString().getBytes());
     } else if (sym instanceof Scored) {
       out.write(Float.toString(((Scored) sym).getScore()).getBytes());
     } else {
       out.write(48);
     }
     out.write(9);
     if (span.isForward()) {
       out.write(43);
     } else {
       out.write(45);
     }
     if (childcount > 0) {
       writeOutChildren(out, propsym, min, max, childcount, sym, seq);
     }
   }
   out.write(10);
 }
Beispiel #6
0
 @Override
 public int getMax(final SeqSymmetry sym, final BioSeq seq) {
   final SeqSpan span = sym.getSpan(seq);
   return span.getMax();
 }
 @Override
 public List<? extends SeqSymmetry> getRegion(final SeqSpan overlapSpan) throws Exception {
   this.init();
   final BioSeq seq = overlapSpan.getBioSeq();
   if (!seq.equals(this.saveSeq) || this.saveSym == null) {
     final Iterator<Map<Integer, List<List<Long>>>> binIter = this.getBinIter(seq.toString());
     if (binIter == null) {
       this.saveSym = new GraphSym(new int[0], new int[0], new float[0], this.featureName, seq);
     } else {
       final int[] xList = new int[32768];
       for (int i = 0; i < 32768; ++i) {
         xList[i] = i * 16384;
       }
       final int[] wList = new int[32768];
       Arrays.fill(wList, 16384);
       final float[] yList = new float[32768];
       Arrays.fill(yList, 0.0f);
       float largestY = Float.MIN_VALUE;
       int indexLargest = -1;
       while (binIter.hasNext()) {
         final Map<Integer, List<List<Long>>> binWrapper = binIter.next();
         final int binNo = binWrapper.keySet().iterator().next();
         final int[] region = getRegion(binNo);
         int yValue = 0;
         for (final List<Long> chunkWrapper : binWrapper.get(binNo)) {
           if (chunkWrapper != null) {
             yValue +=
                 (int)
                     (getUncompressedLength(chunkWrapper.get(0), chunkWrapper.get(1))
                         * 16384L
                         / (region[1] - region[0]));
           }
         }
         if (1 + region[1] - region[0] == 16384
             && yValue > 0.0f
             && (yValue > largestY || indexLargest == -1)) {
           indexLargest = region[0] / 16384;
           largestY = yValue;
         }
         for (int j = region[0] / 16384; j < (region[1] + 1) / 16384; ++j) {
           final float[] array = yList;
           final int n = j;
           array[n] += yValue;
         }
       }
       indexLargest = -1;
       if (indexLargest != -1) {
         try {
           final float realAvg =
               this.getRealAvg(
                   new SimpleSeqSpan(indexLargest * 16384, (indexLargest + 1) * 16384, seq));
           if (realAvg > 0.0f) {
             final float ratio = realAvg / yList[indexLargest];
             for (int k = 0; k < yList.length; ++k) {
               final float[] array2 = yList;
               final int n2 = k;
               array2[n2] *= ratio;
             }
           }
         } catch (Exception x) {
           Logger.getLogger(this.getClass().getName())
               .log(Level.SEVERE, "fail loading BAM segment " + this.uri, x);
         }
       }
       this.saveSym = new GraphSym(xList, wList, yList, this.featureName, seq);
     }
     this.saveSeq = seq;
   }
   final List<SeqSymmetry> symList = new ArrayList<SeqSymmetry>();
   symList.add(this.saveSym);
   return symList;
 }