本文整理汇总了Java中beast.evolution.alignment.Alignment.getPatternCount方法的典型用法代码示例。如果您正苦于以下问题:Java Alignment.getPatternCount方法的具体用法?Java Alignment.getPatternCount怎么用?Java Alignment.getPatternCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beast.evolution.alignment.Alignment
的用法示例。
在下文中一共展示了Alignment.getPatternCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWVLikelihoodCore1
import beast.evolution.alignment.Alignment; //导入方法依赖的package包/类
public void testWVLikelihoodCore1(){
try{
Alignment data = getAlignment();
Tree tree = getTree(data);
SiteModel siteModel = getDefaultSiteModel();
int[] weights1 = new int[data.getPatternCount()];
weights1[0] = 1;
weights1[1] = 1;
NewWVTreeLikelihood newTreeLik = new NewWVTreeLikelihood(weights1);
newTreeLik.initByName(
"data", data,
"tree", tree,
"siteModel", siteModel
);
assertEquals(newTreeLik.calculateLogP(),-6.532640634254436,1e-10);
newTreeLik.store();
newTreeLik.addWeight(2, 1);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-11.97936011489545,1e-10);
tree.setEverythingDirty(true);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-11.97936011489545,1e-10);
}catch(Exception e){
throw new RuntimeException(e);
}
}
示例2: testWVLikelihoodCore2
import beast.evolution.alignment.Alignment; //导入方法依赖的package包/类
public void testWVLikelihoodCore2(){
try{
Alignment data = getAlignment();
Tree tree = getTree(data);
SiteModel siteModel = getDefaultSiteModel();
int[] weights1 = new int[data.getPatternCount()];
weights1[0] = 1;
weights1[1] = 1;
NewWVTreeLikelihood newTreeLik = new NewWVTreeLikelihood(weights1);
newTreeLik.initByName(
"data", data,
"tree", tree,
"siteModel", siteModel
);
assertEquals(newTreeLik.calculateLogP(),-6.532640634254436,1e-10);
newTreeLik.store();
newTreeLik.addWeight(2, 1);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-11.97936011489545,1e-10);
newTreeLik.restore();
tree.setEverythingDirty(true);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-6.532640634254436,1e-10);
System.out.println(newTreeLik.calculateLogP());
}catch(Exception e){
throw new RuntimeException(e);
}
}
示例3: testWVLikelihoodCore3
import beast.evolution.alignment.Alignment; //导入方法依赖的package包/类
public void testWVLikelihoodCore3(){
try{
Alignment data = getAlignment();
Tree tree = getTree(data);
SiteModel siteModel = getDefaultSiteModel();
int[] weights1 = new int[data.getPatternCount()];
weights1[0] = 1;
weights1[1] = 1;
weights1[2] = 1;
NewWVTreeLikelihood newTreeLik = new NewWVTreeLikelihood(weights1);
newTreeLik.initByName(
"data", data,
"tree", tree,
"siteModel", siteModel
);
assertEquals(newTreeLik.calculateLogP(),-11.97936011489545,1e-10);
newTreeLik.store();
newTreeLik.removeWeight(1, 1);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-7.167779745726355,1e-10);
tree.setEverythingDirty(true);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-7.167779745726355,1e-10);
System.out.println(newTreeLik.calculateLogP());
}catch(Exception e){
throw new RuntimeException(e);
}
}
示例4: testWVLikelihoodCore4
import beast.evolution.alignment.Alignment; //导入方法依赖的package包/类
public void testWVLikelihoodCore4(){
try{
Alignment data = getAlignment();
Tree tree = getTree(data);
SiteModel siteModel = getDefaultSiteModel();
int[] weights1 = new int[data.getPatternCount()];
weights1[0] = 1;
weights1[1] = 1;
weights1[2] = 1;
NewWVTreeLikelihood newTreeLik = new NewWVTreeLikelihood(weights1);
newTreeLik.initByName(
"data", data,
"tree", tree,
"siteModel", siteModel
);
assertEquals(newTreeLik.calculateLogP(),-11.97936011489545,1e-10);
newTreeLik.store();
newTreeLik.removeWeight(1, 1);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-7.167779745726355,1e-10);
newTreeLik.restore();
tree.setEverythingDirty(true);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-11.97936011489545,1e-10);
System.out.println(newTreeLik.calculateLogP());
}catch(Exception e){
throw new RuntimeException(e);
}
}
示例5: calculateLogP
import beast.evolution.alignment.Alignment; //导入方法依赖的package包/类
public double[] calculateLogP(
RealParameter modelParameters,
RealParameter modelCode,
RealParameter freqs,
int[] siteIndex){
Alignment alignment = dataInput.get();
double[] logPs = new double[siteIndex.length];
setModelParameterVals(modelParameters,modelCode,freqs);
try{
//Stores a list of rates
ArrayList<QuietRealParameter> rates = new ArrayList<QuietRealParameter>();
//Stores the ID number of the substModel and pattern weights
HashMap<Integer,int[]> clusterWeightsMap = new HashMap<Integer,int[]>();
//Stores the ID number of the substModel and the sites with that model
HashMap<Integer, ArrayList<Integer>> clusterSitesMap = new HashMap<Integer, ArrayList<Integer>>();
int patternIndex;
int rateID;
for(int i = 0; i < siteIndex.length;i++){
patternIndex = alignment.getPatternIndex(siteIndex[i]);
QuietRealParameter rate = dpNtdRateSepSiteModel.getRate(siteIndex[i]);
rateID = rate.getIDNumber();
if(clusterWeightsMap.containsKey(rateID)){
//increment the weight of the pattern at site siteIndex[i] by 1
clusterWeightsMap.get(rateID)[patternIndex]++;
//add the site to the cluster
clusterSitesMap.get(rateID).add(i);
}else{
//Create a new pattern weights vector
int[] patternWeights = new int[alignment.getPatternCount()];
//Increment the weight of the pattern at site siteIndex[i]
patternWeights[patternIndex]++;
//Add the new pattern weight vector to the HashMap
clusterWeightsMap.put(rateID,patternWeights);
//Add the new substModel to the array list
rates.add(rate);
//Create a new array list to store sites
ArrayList<Integer> clusterSites = new ArrayList<Integer>();
//Add site index to the corresponding list
clusterSites.add(i);
//Put the list in the HashMap
clusterSitesMap.put(rateID,clusterSites);
}
}
int rateCount = rates.size();
int site;
for(int i = 0; i < rateCount;i++){
m_siteModel.substModelInput.setValue(substModel, m_siteModel);
((DummySiteModel)m_siteModel).getRateParameter().setValueQuietly(0,rates.get(i).getValue());
rateID = rates.get(i).getIDNumber();
setPatternWeights(clusterWeightsMap.get(rateID));
calculateLogP();
ArrayList<Integer> arrayIndex = clusterSitesMap.get(rateID);
for(Integer index:arrayIndex){
site = siteIndex[index];
logPs[index] = patternLogLikelihoods[dataInput.get().getPatternIndex(site)] ;
}
}
}catch(Exception e){
throw new RuntimeException(e);
}
return logPs;
}
示例6: testWVLikelihoodCore5
import beast.evolution.alignment.Alignment; //导入方法依赖的package包/类
public void testWVLikelihoodCore5(){
try{
Alignment data = getAlignment();
Tree tree = getTree(data);
SiteModel siteModel = getDefaultSiteModel();
int[] weights1 = new int[data.getPatternCount()];
weights1[0] = 1;
weights1[1] = 1;
weights1[2] = 1;
NewWVTreeLikelihood newTreeLik = new NewWVTreeLikelihood(weights1);
newTreeLik.initByName(
"data", data,
"tree", tree,
"siteModel", siteModel
);
assertEquals(newTreeLik.calculateLogP(),-11.97936011489545,1e-10);
newTreeLik.store();
newTreeLik.removeWeight(1, 1);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-7.167779745726355,1e-10);
newTreeLik.restore();
assertEquals(newTreeLik.calculateLogP(),-11.97936011489545,1e-10);
newTreeLik.store();
newTreeLik.removeWeight(2, 1);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-6.532640634254436,1e-10);
newTreeLik.store();
newTreeLik.addWeight(0, 2);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-9.974761164425125,1e-10);
newTreeLik.store();
newTreeLik.addWeight(1, 1);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-14.78634153359422,1e-10);
newTreeLik.restore();
assertEquals(newTreeLik.calculateLogP(),-9.974761164425125,1e-10);
newTreeLik.addWeight(1, 0);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-9.974761164425125,1e-10);
newTreeLik.addWeight(2, 0);
MCMCNodeFactory.checkDirtiness(newTreeLik);
assertEquals(newTreeLik.calculateLogP(),-9.974761164425125,1e-10);
}catch(Exception e){
throw new RuntimeException(e);
}
}