本文整理汇总了Java中dr.evolution.alignment.Alignment.getState方法的典型用法代码示例。如果您正苦于以下问题:Java Alignment.getState方法的具体用法?Java Alignment.getState怎么用?Java Alignment.getState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dr.evolution.alignment.Alignment
的用法示例。
在下文中一共展示了Alignment.getState方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: isSegregating
import dr.evolution.alignment.Alignment; //导入方法依赖的package包/类
public static boolean isSegregating(Alignment a, int j, int[] counts) {
for (int i = 0; i < counts.length; i++) {
counts[i] = 0;
}
int seqCount = a.getSequenceCount();
for (int i = 0; i < seqCount; i++) {
int state = a.getState(i, j);
if (state >= 0 && state < counts.length) {
counts[a.getState(i, j)] += 1;
}
}
for(int count : counts) {
if( count > 0 && count < seqCount ) return true;
}
return false;
}
示例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 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);
}
}
示例5: 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);
}
}
}
示例6: 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;
}
}
示例7: isSingleton
import dr.evolution.alignment.Alignment; //导入方法依赖的package包/类
public static boolean isSingleton(Alignment a, int j, int[] counts) {
for (int i = 0; i < counts.length; i++) {
counts[i] = 0;
}
for (int i = 0; i < a.getSequenceCount(); i++) {
int state = a.getState(i, j);
if (state >= 0 && state < counts.length) {
counts[a.getState(i, j)] += 1;
}
}
for(int count : counts) {
if( count == 1 ) return true;
}
return false;
}
示例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);
}
}