Exemplo n.º 1
0
  /**
   * Sets the partials from a sequence in an alignment.
   *
   * @param beagle beagle
   * @param patternList patternList
   * @param sequenceIndex sequenceIndex
   * @param nodeIndex nodeIndex
   */
  protected final void setPartials(
      Beagle beagle, PatternList patternList, int sequenceIndex, int nodeIndex) {
    double[] partials = new double[patternCount * stateCount * categoryCount];

    boolean[] stateSet;

    int v = 0;
    for (int i = 0; i < patternCount; i++) {

      int state = patternList.getPatternState(sequenceIndex, i);
      stateSet = dataType.getStateSet(state);

      for (int j = 0; j < stateCount; j++) {
        if (stateSet[j]) {
          partials[v] = 1.0;
        } else {
          partials[v] = 0.0;
        }
        v++;
      }
    }

    // if there is more than one category then replicate the partials for each
    int n = patternCount * stateCount;
    int k = n;
    for (int i = 1; i < categoryCount; i++) {
      System.arraycopy(partials, 0, partials, k, n);
      k += n;
    }

    beagle.setPartials(nodeIndex, partials);
  }
Exemplo n.º 2
0
  /** Stores the additional state other than model components */
  protected void storeState() {
    partialBufferHelper.storeState();
    substitutionModelDelegate.storeState();

    if (useScaleFactors || useAutoScaling) { // Only store when actually used
      scaleBufferHelper.storeState();
      System.arraycopy(
          scaleBufferIndices, 0, storedScaleBufferIndices, 0, scaleBufferIndices.length);
      //            storedRescalingCount = rescalingCount;
    }

    super.storeState();
  }
Exemplo n.º 3
0
  /** Sets the partials from a sequence in an alignment. */
  protected final void setPartials(Beagle beagle, TipStatesModel tipStatesModel, int nodeIndex) {
    double[] partials = new double[patternCount * stateCount * categoryCount];

    tipStatesModel.getTipPartials(nodeIndex, partials);

    // if there is more than one category then replicate the partials for each
    int n = patternCount * stateCount;
    int k = n;
    for (int i = 1; i < categoryCount; i++) {
      System.arraycopy(partials, 0, partials, k, n);
      k += n;
    }

    beagle.setPartials(nodeIndex, partials);
  }