private static void computeLofK( final ExactACset set, final List<double[]> genotypeLikelihoods, final double[] log10AlleleFrequencyPriors, final StateTracker stateTracker) { set.getLog10Likelihoods()[0] = 0.0; // the zero case final int totalK = set.getACsum(); // special case for k = 0 over all k if (totalK == 0) { for (int j = 1; j < set.getLog10Likelihoods().length; j++) { set.getLog10Likelihoods()[j] = set.getLog10Likelihoods()[j - 1] + genotypeLikelihoods.get(j)[HOM_REF_INDEX]; } final double log10Lof0 = set.getLog10Likelihoods()[set.getLog10Likelihoods().length - 1]; stateTracker.setLog10LikelihoodOfAFzero(log10Lof0); stateTracker.setLog10PosteriorOfAFzero(log10Lof0 + log10AlleleFrequencyPriors[0]); return; } // if we got here, then k > 0 for at least one k. // the non-AA possible conformations were already dealt with by pushes from dependent sets; // now deal with the AA case (which depends on previous cells in this column) and then update // the L(j,k) value for (int j = 1; j < set.getLog10Likelihoods().length; j++) { if (totalK < 2 * j - 1) { final double[] gl = genotypeLikelihoods.get(j); final double conformationValue = MathUtils.log10(2 * j - totalK) + MathUtils.log10(2 * j - totalK - 1) + set.getLog10Likelihoods()[j - 1] + gl[HOM_REF_INDEX]; set.getLog10Likelihoods()[j] = MathUtils.approximateLog10SumLog10(set.getLog10Likelihoods()[j], conformationValue); } final double logDenominator = MathUtils.log10(2 * j) + MathUtils.log10(2 * j - 1); set.getLog10Likelihoods()[j] = set.getLog10Likelihoods()[j] - logDenominator; } double log10LofK = set.getLog10Likelihoods()[set.getLog10Likelihoods().length - 1]; // update the MLE if necessary stateTracker.updateMLEifNeeded(log10LofK, set.getACcounts().getCounts()); // apply the priors over each alternate allele for (final int ACcount : set.getACcounts().getCounts()) { if (ACcount > 0) { log10LofK += log10AlleleFrequencyPriors[ACcount]; } } stateTracker.updateMAPifNeeded(log10LofK, set.getACcounts().getCounts()); }
public static void glWeightPointerARB(int size, int stride, FloatBuffer pPointer) { ContextCapabilities caps = GLContext.getCapabilities(); long function_pointer = caps.glWeightPointerARB; BufferChecks.checkFunctionAddress(function_pointer); GLChecks.ensureArrayVBOdisabled(caps); BufferChecks.checkDirect(pPointer); if (LWJGLUtil.CHECKS) StateTracker.getReferences(caps).ARB_vertex_blend_glWeightPointerARB_pPointer = pPointer; nglWeightPointerARB( size, GL11.GL_FLOAT, stride, MemoryUtil.getAddress(pPointer), function_pointer); }
public static void glVertexAttribIPointerEXT( int index, int size, int type, int stride, ShortBuffer buffer) { ContextCapabilities caps = GLContext.getCapabilities(); long function_pointer = caps.glVertexAttribIPointerEXT; BufferChecks.checkFunctionAddress(function_pointer); GLChecks.ensureArrayVBOdisabled(caps); BufferChecks.checkDirect(buffer); if (LWJGLUtil.CHECKS) StateTracker.getReferences(caps).EXT_gpu_shader4_glVertexAttribIPointerEXT_buffer = buffer; nglVertexAttribIPointerEXT( index, size, type, stride, buffer, buffer.position() << 1, function_pointer); }
public void stopScrolling(boolean now) { if (now) { DragSortListView.this.removeCallbacks(this); mScrolling = false; } else { mAbort = true; } if (mTrackDragScroll) { mStateTracker.stopTracking(); } // Debug.stopMethodTracing(); }
@Override protected void updateState() { mState = sWifiApState.getTriState(mView.getContext()); switch (mState) { case STATE_DISABLED: mIcon = R.drawable.stat_wifi_ap_off; break; case STATE_ENABLED: mIcon = R.drawable.stat_wifi_ap_on; break; case STATE_INTERMEDIATE: // In the transitional state, the bottom green bar // shows the tri-state (on, off, transitioning), but // the top dark-gray-or-bright-white logo shows the // user's intent. This is much easier to see in // sunlight. if (sWifiApState.isTurningOn()) { mIcon = R.drawable.stat_wifi_ap_on; } else { mIcon = R.drawable.stat_wifi_ap_off; } break; } }
public void startScrolling(int dir) { if (!mScrolling) { // Debug.startMethodTracing("dslv-scroll"); if (mTrackDragScroll) { mStateTracker.startTracking(); Log.d("mobeta", "scroll tracking started"); } mAbort = false; mScrolling = true; tStart = SystemClock.uptimeMillis(); mPrevTime = tStart; mLastHeader = getHeaderViewsCount() - 1; mFirstFooter = getCount() - getFooterViewsCount(); scrollDir = dir; post(this); } }
@Override public void onReceive(Context context, Intent intent) { sWifiApState.onActualStateChange(context, intent); }
@Override protected void toggleState() { sWifiApState.toggleState(mView.getContext()); }
private double calculateAlleleCountConformation( final ExactACset set, final List<double[]> genotypeLikelihoods, final int numChr, final Deque<ExactACset> ACqueue, final Map<ExactACcounts, ExactACset> indexesToACset, final double[] log10AlleleFrequencyPriors, final StateTracker stateTracker) { // compute the log10Likelihoods computeLofK(set, genotypeLikelihoods, log10AlleleFrequencyPriors, stateTracker); final double log10LofK = set.getLog10Likelihoods()[set.getLog10Likelihoods().length - 1]; // can we abort early because the log10Likelihoods are so small? if (stateTracker.abort(log10LofK, set.getACcounts(), true, false)) { return log10LofK; } // iterate over higher frequencies if possible final int ACwiggle = numChr - set.getACsum(); if (ACwiggle == 0) { // all alternate alleles already sum to 2N so we cannot possibly go to higher // frequencies return log10LofK; } final int numAltAlleles = set.getACcounts().getCounts().length; // add conformations for the k+1 case for (int allele = 0; allele < numAltAlleles; allele++) { final int[] ACcountsClone = set.getACcounts().getCounts().clone(); ACcountsClone[allele]++; // to get to this conformation, a sample would need to be AB (remember that ref=0) final int PLindex = GenotypeLikelihoods.calculatePLindex(0, allele + 1); updateACset( ACcountsClone, numChr, set, PLindex, ACqueue, indexesToACset, genotypeLikelihoods); } // add conformations for the k+2 case if it makes sense; note that the 2 new alleles may be the // same or different if (ACwiggle > 1) { final List<DependentSet> differentAlleles = new ArrayList<>(numAltAlleles * numAltAlleles); final List<DependentSet> sameAlleles = new ArrayList<>(numAltAlleles); for (int allele_i = 0; allele_i < numAltAlleles; allele_i++) { for (int allele_j = allele_i; allele_j < numAltAlleles; allele_j++) { final int[] ACcountsClone = set.getACcounts().getCounts().clone(); ACcountsClone[allele_i]++; ACcountsClone[allele_j]++; // to get to this conformation, a sample would need to be BB or BC (remember that ref=0, // so add one to the index) final int PLindex = GenotypeLikelihoods.calculatePLindex(allele_i + 1, allele_j + 1); if (allele_i == allele_j) { sameAlleles.add(new DependentSet(ACcountsClone, PLindex)); } else { differentAlleles.add(new DependentSet(ACcountsClone, PLindex)); } } } // IMPORTANT: we must first add the cases where the 2 new alleles are different so that the // queue maintains its ordering for (final DependentSet dependent : differentAlleles) { updateACset( dependent.ACcounts, numChr, set, dependent.PLindex, ACqueue, indexesToACset, genotypeLikelihoods); } for (final DependentSet dependent : sameAlleles) { updateACset( dependent.ACcounts, numChr, set, dependent.PLindex, ACqueue, indexesToACset, genotypeLikelihoods); } } return log10LofK; }
public void run() { if (mAbort) { mScrolling = false; return; } if (mTrackDragScroll) { mStateTracker.appendState(); } if (scrollDir == UP) { mScrollSpeed = mScrollProfile.getSpeed((mUpScrollStartYF - mLastY) / mDragUpScrollHeight, mPrevTime); } else { mScrollSpeed = -mScrollProfile.getSpeed( (mLastY - mDownScrollStartYF) / mDragDownScrollHeight, mPrevTime); } dt = SystemClock.uptimeMillis() - mPrevTime; // dy is change in View position of a list item; i.e. positive dy // means user is scrolling up (list item moves down the screen, // remember // y=0 is at top of View). dy = (int) Math.round(mScrollSpeed * dt); // Log.d("mobeta", "scrolling by " + dy); // don't bail if dy=0, touch might be at edge of scroll region; but, // don't do any work if (dy == 0) { mPrevTime += dt; post(this); return; } final int first = getFirstVisiblePosition(); final int last = getLastVisiblePosition(); final int count = getCount(); final int padTop = getPaddingTop(); final int listHeight = getHeight() - padTop - getPaddingBottom(); int movePosition; if (dy > 0) { if (first == 0 && getChildAt(0).getTop() == padTop) { mScrolling = false; return; } movePosition = first; dy = Math.min(listHeight, dy); } else { if (last == count - 1 && getChildAt(last - first).getBottom() <= listHeight + padTop) { mScrolling = false; return; } movePosition = last; dy = Math.max(-listHeight, dy); } // what if movePosition is a position to be expanded/collapsed? final int oldTop = getChildAt(movePosition - first).getTop(); int newTop = oldTop + dy; // Log.d("mobeta", // "movePos="+movePosition+" newTop="+newTop+" oldTop="+(newTop-dy)+" lvheight="+getHeight()+" // fvheight="+mFloatViewHeight+" oldBottom="+getChildAt(movePosition-first).getBottom()); // Where will floating view end up given current list state? // newFloatPos is a visual position int newFloatPos = getFloatPosition(mLastY, movePosition, newTop); if (newFloatPos != mExpDragPos) { // scroll induces shuffle; adjust scroll for smoothness if (scrollDir == DOWN && newFloatPos == movePosition) { newTop -= mFloatViewHeight + getDividerHeight(); } else if (newFloatPos < movePosition) { if (scrollDir == UP || (scrollDir == DOWN && movePosition == mExpDragPos)) { newTop += mFloatViewHeight + getDividerHeight(); } } } // Schedule expand/collapse where needed and update list state. // Important that this goes before the following underscroll move. shuffleItems(newFloatPos); // Do underscroll (assumes/uses new list state) // Log.d("mobeta", "viewTop=" + viewTop + " pos=" + pos + // " itemTop=" + itemTop); // Log.d("mobeta", "dy="+(newTop - oldTop)); setSelectionFromTop(movePosition, newTop - getPaddingTop()); DragSortListView.super.layoutChildren(); mPrevTime += dt; post(this); }