/*.................................................................................................................*/ public void calculateNumber( Tree tree1, Tree tree2, MesquiteNumber result, MesquiteString resultString) { if (result == null) return; clearResultAndLastResult(result); if (tree1 == null) return; if (tree2 == null) return; int numTaxa = tree1.getTaxa().getNumTaxa(); double[][] patristic1 = null; patristic1 = p1.calculatePatristic( tree1, numTaxa, patristic1); // for this tree calculate patristic distances (number of nodes separating // terminals; no branch lengths) double[][] patristic2 = null; patristic2 = p2.calculatePatristic( tree2, numTaxa, patristic2); // for this tree calculate patristic distances (number of nodes separating // terminals; no branch lengths) double correl = offDiagonalPMCorrelationFILTERED(patristic1, patristic2); if (isDistance && (MesquiteDouble.isCombinable(correl))) correl = -correl + 1.0; // shifting 1 to -1 to be 0 to 2 to act as distance result.setValue(correl); if (resultString != null) { if (isDistance) resultString.setValue( "Patristic correlation (converted to distance): " + result.toString()); else resultString.setValue("Patristic correlation: " + result.toString()); } saveLastResult(result); saveLastResultString(resultString); }
public void calculateNumber(Taxon taxon, MesquiteNumber result, MesquiteString resultString) { if (result == null) return; clearResultAndLastResult(result); Taxa taxa = taxon.getTaxa(); int it = taxa.whichTaxonNumber(taxon); if (taxa != currentTaxa || observedStates == null) { observedStates = matrixSourceTask.getCurrentMatrix(taxa); currentTaxa = taxa; } if (observedStates == null || !(observedStates.getParentData() instanceof DNAData)) return; DNAData data = (DNAData) observedStates.getParentData(); int count = data.getAminoAcidNumbers(it, ProteinData.TER, countEvenIfOthers.getValue()); if (result != null) result.setValue(count); if (resultString != null) resultString.setValue( "Number of stop codons in taxon " + observedStates.getName() + ": " + count); saveLastResult(result); saveLastResultString(resultString); }