本文整理汇总了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];
}
示例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)
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}