Exemplo n.º 1
0
  // compute scale factor
  private void computeFactor() {

    // scale mean rate to 1.0 or separate parameter

    double treeRate = 0.0;
    double treeTime = 0.0;

    // normalizeBranchRateTo = 1.0;
    for (int i = 0; i < treeModel.getNodeCount(); i++) {
      NodeRef node = treeModel.getNode(i);
      if (!treeModel.isRoot(node)) {
        // d                int rateCategory = (int)
        // Math.round(rateCategories.getNodeValue(treeModel, node));
        // d                 treeRate += rates[rateCategory] * treeModel.getBranchLength(node);
        treeTime += treeModel.getBranchLength(node);

        // d              System.out.println("rates and time\t" + rates[rateCategory] + "\t" +
        // treeModel.getBranchLength(node));
      }
    }
    // treeRate /= treeTime;

    scaleFactor = normalizeBranchRateTo / (treeRate / treeTime);
    System.out.println("scaleFactor\t\t\t\t\t" + scaleFactor);
  }
Exemplo n.º 2
0
  private void setup() {

    DataType dataType = baseSubstitutionModel.getDataType();
    FrequencyModel freqModel = baseSubstitutionModel.getFrequencyModel();
    Parameter kappaParameter = new Parameter.Default("kappa", 1, baseSubstitutionModel.getKappa());

    substitutionModels = new LinkedList<SubstitutionModel>();
    branchAssignmentMap = new LinkedHashMap<NodeRef, Integer>();

    int branchClass = 0;
    for (NodeRef node : treeModel.getNodes()) {
      if (!treeModel.isRoot(node)) {

        double nodeHeight = treeModel.getNodeHeight(node);
        double parentHeight = treeModel.getNodeHeight(treeModel.getParent(node));

        double time = 0.5 * (parentHeight + nodeHeight);

        double baseOmega = baseSubstitutionModel.getOmega();

        double fixed = baseOmega * time;

        double epsilon =
            (Math.log(1 - random.nextDouble())
                / (-rate)); // Math.exp((random.nextGaussian() * stdev + mean));

        double value = fixed + epsilon;

        Parameter omegaParameter = new Parameter.Default("omega", 1, value);

        GY94CodonModel gy94 =
            new GY94CodonModel((Codons) dataType, omegaParameter, kappaParameter, freqModel);

        substitutionModels.add(gy94);
        branchAssignmentMap.put(node, branchClass);
        branchClass++;
      } // END: root check
    } // END: nodes loop
  } // END: setup