当前位置: 首页>>代码示例>>Java>>正文


Java Alignment.getPatternCount方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:35,代码来源:WVLikelihoodCoreTest.java

示例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);
    }
}
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:38,代码来源:WVLikelihoodCoreTest.java

示例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);
    }
}
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:37,代码来源:WVLikelihoodCoreTest.java

示例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);
    }
}
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:38,代码来源:WVLikelihoodCoreTest.java

示例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;
}
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:79,代码来源:SepTempWVTreeLikelihood.java

示例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);
    }
}
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:63,代码来源:WVLikelihoodCoreTest.java


注:本文中的beast.evolution.alignment.Alignment.getPatternCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。