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


Java Alignment.getSiteCount方法代码示例

本文整理汇总了Java中dr.evolution.alignment.Alignment.getSiteCount方法的典型用法代码示例。如果您正苦于以下问题:Java Alignment.getSiteCount方法的具体用法?Java Alignment.getSiteCount怎么用?Java Alignment.getSiteCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dr.evolution.alignment.Alignment的用法示例。


在下文中一共展示了Alignment.getSiteCount方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: BasicColourSampler

import dr.evolution.alignment.Alignment; //导入方法依赖的package包/类
public BasicColourSampler(Alignment tipColours, Tree tree) {

        if (tipColours.getSiteCount() != 1) {
            throw new IllegalArgumentException("Tip colour alignment must consist of a single column!");
        }

        nodeColours = new int[tree.getNodeCount()];
        colourCount = tipColours.getDataType().getStateCount();

        leafColourCounts = new int[colourCount];

        // initialize external node colours
        for (int i = 0; i < tree.getExternalNodeCount(); i++) {
            NodeRef node = tree.getExternalNode(i);
            int colour = tipColours.getState(tipColours.getTaxonIndex(tree.getTaxonId(i)), 0);
            nodeColours[node.getNumber()] = colour;
            leafColourCounts[colour]++;
        }

        nodePartials = new double[tree.getNodeCount()][colourCount];
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:22,代码来源:BasicColourSampler.java

示例2: StructuredColourSampler

import dr.evolution.alignment.Alignment; //导入方法依赖的package包/类
public StructuredColourSampler(Alignment tipColours, Tree tree, boolean nodeBias, boolean branchBias, boolean secondIteration) {

        if (tipColours.getSiteCount() != 1) {
            throw new IllegalArgumentException("Tip colour alignment must consist of a single column!");
        }

        nodeColours = new int[tree.getNodeCount()];
        colourCount = tipColours.getDataType().getStateCount();

        leafColourCounts = new int[colourCount];
        // initialize external node colours
        for (int i = 0; i < tree.getExternalNodeCount(); i++) {
            NodeRef node = tree.getExternalNode(i);
            int colour = tipColours.getState(tipColours.getTaxonIndex(tree.getTaxonId(i)), 0);
            nodeColours[node.getNumber()] = colour;
            leafColourCounts[colour]++;
        }

        useNodeBias = nodeBias;
        useBranchBias = branchBias;
        useSecondColourIteration = secondIteration;

        initialize(tree);     // uses only tree constants (number of tips, etc)

    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:26,代码来源:StructuredColourSampler.java

示例3: initAlignment

import dr.evolution.alignment.Alignment; //导入方法依赖的package包/类
/**
 * Initializes the iAlignment array from the given alignment.
 */
private void initAlignment(Alignment alignment, int[] treeIndex) {
	
	int numSeqs = alignment.getSequenceCount();
	int numSites = alignment.getSiteCount();
	DataType dataType = alignment.getDataType();
	int numStates = dataType.getStateCount();
	
	iAlignment = new IntMathVec[numSites];
	
	int[] column = new int[numSeqs];
	for (int i =0; i < numSites; i++) {
		for (int j = 0; j < numSeqs; j++) {
			column[treeIndex[j]] = ((alignment.getState(j, i) >= numStates) ? 0 : 1);	
		}
		iAlignment[i] = new IntMathVec(column);
	}
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:21,代码来源:HomologyRecursion.java

示例4: initAlignment

import dr.evolution.alignment.Alignment; //导入方法依赖的package包/类
/**
 * Initializes the iAlignment array from the given alignment.
 */
private void initAlignment(Alignment alignment, int[] treeIndex) {

    int numSeqs = alignment.getSequenceCount();
    int numSites = alignment.getSiteCount();
    DataType dataType = alignment.getDataType();
    int numStates = dataType.getStateCount();

    iAlignment = new int[numSeqs][numSites];

    // populate alignment in order of tree
    for (int i = 0; i < numSeqs; i++) {
        for (int j = 0; j < numSites; j++) {
            iAlignment[treeIndex[i]][j] = alignment.getState(i, j);
        }
    }
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:20,代码来源:IstvanOperator.java

示例5: getPartialsForGroupSizeOne

import dr.evolution.alignment.Alignment; //导入方法依赖的package包/类
private void getPartialsForGroupSizeOne(Taxon tax, double[] tipPartials)
{
	Alignment aln = data.getAlignment();
	int sc = aln.getStateCount();
	int index = aln.getTaxonIndex(tax);
	int j=0;
	for(int i=0; i<aln.getSiteCount(); i++){
		int s = aln.getState(index, i);
		if(s>=sc){
			for(int k=0; k<sc; k++)
				tipPartials[j + k] = 1.0;
		}else
			System.arraycopy(internalMatrix, s*sc, tipPartials, j, sc);
		j += sc;
	}
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:17,代码来源:HiddenLinkageModel.java

示例6: countSingletons

import dr.evolution.alignment.Alignment; //导入方法依赖的package包/类
public static int countSingletons(Alignment a) {

		int count = 0;
		int[] counts = new int[a.getDataType().getStateCount()];
		for (int i = 0; i < a.getSiteCount(); i++) {
			count += (isSingleton(a, i, counts)?1:0);
		}

		return count;
	}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:11,代码来源:SelectionMapping.java

示例7: countSegregating

import dr.evolution.alignment.Alignment; //导入方法依赖的package包/类
public static int countSegregating(Alignment a) {

		int count = 0;
		int[] counts = new int[a.getDataType().getStateCount()];
		for (int i = 0; i < a.getSiteCount(); i++) {
			count += (isSegregating(a, i, counts)?1:0);
		}

		return count;
	}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:11,代码来源:SelectionMapping.java

示例8: computeTipPartials

import dr.evolution.alignment.Alignment; //导入方法依赖的package包/类
private void computeTipPartials(int nodeIndex){
	if(!dirtyTipPartials[nodeIndex]){
		swapTipPartials(nodeIndex);
		dirtyTipPartials[nodeIndex]=true;
	}
	double[] tipPartials = this.tipPartials[nodeIndex];

	// if this is one of the reference organisms, then return the resolved partials
	// if this is a linkage group, return partials that correspond to probabilities of each nucleotide.
	Alignment aln = data.getAlignment();
	int sc = aln.getStateCount();
	for(int i=0; i<tipPartials.length; i++){
		tipPartials[i]=0.0;
	}
	if(nodeIndex < data.getReferenceTaxa().getTaxonCount()){			
		int j=0;
		for(int i=0; i<aln.getSiteCount(); i++){
			int s = aln.getState(nodeIndex, i);
			if(s>=sc){
				for(int k=0; k<sc; k++)
					tipPartials[j + k] = 1.0;
			}else
				tipPartials[j + s] = 1.0;
			j += sc;
		}
	}else{
		int gI = nodeIndex - data.getReferenceTaxa().getTaxonCount();
		HashSet<Taxon> group = groups.get(gI);
		int internalNum = data.getReadsTaxa().getTaxonCount();
		Taxon firstTax=null;
		boolean peeled = false;
		for(Taxon tax : group){
			if(firstTax==null)
			{
				firstTax = tax;
				continue;
			}
			int c2 = data.getReadsTaxa().getTaxonIndex(tax);
			if(!peeled){
				int c1 = data.getReadsTaxa().getTaxonIndex(firstTax);
				core.setNodePartialsForUpdate(internalNum);
                core.calculatePartials(c1, c2, internalNum);
			}else{
				core.setNodePartialsForUpdate(internalNum);
                core.calculatePartials(internalNum-1, c2, internalNum);
			}
			internalNum++;
			peeled = true;
		}
		if(group.size()==0)
		{
			for(int i=0; i<tipPartials.length; i++)
				tipPartials[i]=1.0;
		}else if(!peeled)
			getPartialsForGroupSizeOne(firstTax, tipPartials);
		else
			core.getPartials(internalNum-1, tipPartials);
	}
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:60,代码来源:HiddenLinkageModel.java

示例9: parseXMLObject

import dr.evolution.alignment.Alignment; //导入方法依赖的package包/类
public Object parseXMLObject(XMLObject xo) throws XMLParseException {

            Parameter catParam = (Parameter) xo.getChild(Parameter.class);
            CategorySampleModel siteModel = (CategorySampleModel) xo.getChild(CategorySampleModel.class);
            Alignment alignment = (Alignment) xo.getChild(Alignment.class);

            double weight = xo.getDoubleAttribute(WEIGHT);

            return new CategoryOperator(siteModel, alignment.getSiteCount(),
                    catParam, weight);
        }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:12,代码来源:CategoryOperator.java

示例10: parseXMLObject

import dr.evolution.alignment.Alignment; //导入方法依赖的package包/类
public Object parseXMLObject(XMLObject xo) throws XMLParseException {

        Alignment alignment = (Alignment) xo.getChild(Alignment.class);
        TaxonList taxa = null;

        int from = 0;
        int to = -1;
        int every = xo.getAttribute(EVERY, 1);

        boolean strip = xo.getAttribute(STRIP, true);

        boolean unique = xo.getAttribute(UNIQUE, true);

        if (xo.hasAttribute(FROM)) {
            from = xo.getIntegerAttribute(FROM) - 1;
            if (from < 0)
                throw new XMLParseException("illegal 'from' attribute in patterns element");
        }

        if (xo.hasAttribute(TO)) {
            to = xo.getIntegerAttribute(TO) - 1;
            if (to < 0 || to < from)
                throw new XMLParseException("illegal 'to' attribute in patterns element");
        }

        if (every <= 0) throw new XMLParseException("illegal 'every' attribute in patterns element");

        if (xo.hasChildNamed(TAXON_LIST)) {
            taxa = (TaxonList) xo.getElementFirstChild(TAXON_LIST);
        }

        if (from > alignment.getSiteCount())
            throw new XMLParseException("illegal 'from' attribute in patterns element");

        if (to > alignment.getSiteCount())
            throw new XMLParseException("illegal 'to' attribute in patterns element");

        SitePatterns patterns = new SitePatterns(alignment, taxa, from, to, every, strip, unique);

        int f = from + 1;
        int t = to + 1; // fixed a *display* error by adding + 1 for consistency with f = from + 1
        if (to == -1) t = alignment.getSiteCount();

        if (xo.hasAttribute(XMLParser.ID)) {
            final Logger logger = Logger.getLogger("dr.evoxml");
            logger.info("Site patterns '" + xo.getId() + "' created from positions " +
                    Integer.toString(f) + "-" + Integer.toString(t) +
                    " of alignment '" + alignment.getId() + "'");

            if (every > 1) {
                logger.info("  only using every " + every + " site");
            }
            logger.info("  pattern count = " + patterns.getPatternCount());
        }

        return patterns;
    }
 
开发者ID:whdc,项目名称:ieo-beast,代码行数:58,代码来源:SitePatternsParser.java


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