本文整理汇总了Java中beast.evolution.alignment.Alignment类的典型用法代码示例。如果您正苦于以下问题:Java Alignment类的具体用法?Java Alignment怎么用?Java Alignment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Alignment类属于beast.evolution.alignment包,在下文中一共展示了Alignment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testHKY85Likelihood
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
@Test
public void testHKY85Likelihood() throws Exception {
// Set up HKY85 model: estimated freqs, kappa = 29.739445, 0 gamma categories
Alignment data = BEASTTestCase.getAlignment();
Tree tree = BEASTTestCase.getTree(data);
Frequencies freqs = new Frequencies();
freqs.initByName("data", data);
HKY hky = new HKY();
hky.initByName("kappa", "29.739445", "frequencies", freqs);
SiteModel siteModel = new SiteModel();
siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "substModel", hky);
TreeLikelihood likelihood = newTreeLikelihood();
likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
double logP = 0;
logP = likelihood.calculateLogP();
assertEquals(logP, -1825.2131708068507, BEASTTestCase.PRECISION);
likelihood.initByName("useAmbiguities", true, "data", data, "tree", tree, "siteModel", siteModel);
logP = likelihood.calculateLogP();
assertEquals(logP, -1825.2131708068507, BEASTTestCase.PRECISION);
}
示例2: testCompoundAlignment
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
public void testCompoundAlignment() {
// Test whether basic functionality (data type size, manual recovery of
// component-wise values) is guaranteed.
Alignment a0 = alignment0();
CompoundDataType c = datatype0();
CompoundAlignment compound = new CompoundAlignment();
compound.initByName("alignment", a0, "dataType", "userDataType", "userDataType", c);
assertEquals("The compound alignment should have one column", compound.getSiteCount(), 1);
Integer expectedStateCount = 1;
for (int stateCount : c.getStateCounts()) {
expectedStateCount *= stateCount;
}
assertEquals("The state count of the only column should be the product of all `alignment` state counts",
compound.getStateCounts().get(0), expectedStateCount);
}
示例3: testCompoundAlignmentWithoutDataType
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
public void testCompoundAlignmentWithoutDataType() {
// Test whether basic functionality (data type size, manual recovery of
// component-wise values) is guaranteed.
Alignment a0 = alignment0();
CompoundDataType c = datatype0();
CompoundAlignment compound = new CompoundAlignment();
compound.initByName("alignment", a0);
assertEquals("The compound alignment should have one column", 1, compound.getSiteCount());
Integer expectedStateCount = 1;
for (int stateCount : c.getStateCounts()) {
expectedStateCount *= stateCount;
}
assertEquals("The state count of the only column should be the product of all `alignment` state counts",
expectedStateCount, compound.getStateCounts().get(0));
}
示例4: testRecoverCompoundAlignment
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
public void testRecoverCompoundAlignment() {
// Test whether CompoundDataType.compoundState2componentState can
// recover the patterns from individual alignments.
CompoundAlignment compound = null;
compound = new CompoundAlignment();
Alignment a0 = alignment0();
CompoundDataType c = datatype0();
compound.initByName("alignment", a0, "dataType", "userDataType", "userDataType", c);
for (int taxon = 0; taxon < compound.getTaxonCount(); ++taxon) {
int p = compound.getPattern(taxon, 0);
for (int component = 0; component < c.getComponentCount(); ++component) {
assertEquals(
String.format("In taxon %s: Site %d incorrectly reconstructed from %d.",
compound.getTaxaNames().get(taxon), component, p),
a0.getPattern(taxon, component), c.compoundState2componentState(p, component));
}
}
}
示例5: randomTreeTest
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
private static void randomTreeTest() throws Exception {
StringBuilder traitSB = new StringBuilder();
List<Sequence> seqList = new ArrayList<Sequence>();
for (int i = 0; i < 10; i++) {
String taxonID = "t " + i;
seqList.add(new Sequence(taxonID, "?"));
if (i > 0)
traitSB.append(",");
traitSB.append(taxonID).append("=").append(i);
}
Alignment alignment = new Alignment(seqList, "nucleotide");
ConstantPopulation popFunc = new ConstantPopulation();
popFunc.initByName("popSize", new RealParameter("1.0"));
RandomTree t = new RandomTree();
t.initByName("taxa", alignment, "populationModel", popFunc);
Sequence l = new Sequence("", "");
System.out.println("Tree GTR Borrowing Test");
Tree tree = randomYuleTree(2, 0.01);
tree.getRoot().setMetaData("lang", l);
System.out.println(TreeUtils.getTreeLength(tree, tree.getRoot()));
}
示例6: setStates
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
/**
* Sets the partials from a sequence in an alignment.
*
* @param beagle beagle
* @param nodeIndex nodeIndex
* @param taxon the taxon
*/
protected final void setStates(Beagle beagle,
int nodeIndex, int taxon) {
Alignment data = dataInput.get();
int i;
int[] states = new int[patternCount];
for (i = 0; i < patternCount; i++) {
int code = data.getPattern(taxon, i);
int[] statesForCode = data.getDataType().getStatesForCode(code);
if (statesForCode.length==1)
states[i] = statesForCode[0];
else
states[i] = code; // Causes ambiguous states to be ignored.
}
beagle.setTipStates(nodeIndex, states);
}
示例7: getAscertainmentCorrectedLogLikelihood
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
private double getAscertainmentCorrectedLogLikelihood(Alignment patternList,
double[] patternLogLikelihoods,
int[] patternWeights,
double [] frequencies) {
if (constantPattern != null) {
proportionInvariant = m_siteModel.getProportionInvariant();
for (int k : constantPattern) {
int i = k / m_nStateCount;
int j = k % m_nStateCount;
patternLogLikelihoods[i] = (Math.log(Math.exp(patternLogLikelihoods[i]) + proportionInvariant * frequencies[j]));
}
}
double logL = 0.0;
double ascertainmentCorrection = patternList.getAscertainmentCorrection(patternLogLikelihoods);
for (int i = 0; i < patternCount; i++) {
logL += (patternLogLikelihoods[i] - ascertainmentCorrection) * patternWeights[i];
}
return logL;
}
示例8: NewWVTreeLikelihood
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
public NewWVTreeLikelihood(int[] patternWeights,
Alignment data,
Tree tree,
boolean useAmbiguities,
SiteModel siteModel,
BranchRateModel.Base branchRateModel){
this.patternWeights = patternWeights;
storedPatternWeights = new int[patternWeights.length];
this.data = data;
this.tree = tree;
this.useAmbiguities = useAmbiguities;
m_siteModel = siteModel;
this.branchRateModel = branchRateModel;
this.substitutionModel = (SubstitutionModel.Base)m_siteModel.getSubstitutionModel();
setup();
}
示例9: run
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
@Override
public void run() throws IllegalArgumentException, IllegalAccessException, IOException, XMLParserException {
for (int i = 0; i < iterationsInput.get(); i++) {
Alignment alignment = simulate();
// Write output to stdout or file
PrintStream pstream;
if (m_outputFileName == null)
pstream = System.out;
else
pstream = new PrintStream(m_outputFileName);
pstream.println(new XMLProducer().toRawXML(alignment));
for (MergeDataWith merge : mergeListInput.get()) {
merge.process(alignment, i);
}
}
}
示例10: traverse
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
/**
* recursively walk through the tree top down, and add sequence to alignment whenever
* a leave node is reached.
*
* @param node reference to the current node, for which we visit all children
* @param parentSequence randomly generated sequence of the parent node
* @param category array of categories for each of the sites
* @param alignment
* @
*/
void traverse(Node node, int[] parentSequence, int[] category, Alignment alignment) {
for (int childIndex = 0; childIndex < 2; childIndex++) {
Node child = (childIndex == 0 ? node.getLeft() : node.getRight());
for (int i = 0; i < m_categoryCount; i++) {
getTransitionProbabilities(m_tree, child, i, m_probabilities[i]);
}
int[] seq = new int[m_sequenceLength];
double[] cProb = new double[m_stateCount];
for (int i = 0; i < m_sequenceLength; i++) {
System.arraycopy(m_probabilities[category[i]], parentSequence[i] * m_stateCount, cProb, 0, m_stateCount);
seq[i] = Randomizer.randomChoicePDF(cProb);
}
if (child.isLeaf()) {
alignment.sequenceInput.setValue(intArray2Sequence(seq, child), alignment);
} else {
traverse(child, seq, category, alignment);
}
}
}
示例11: readDataBlock
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
/**
* Reads a 'DATA' block.
*/
private Alignment readDataBlock(/*TaxonList taxonList*/) throws ImportException, IOException {
taxonCount = 0;
siteCount = 0;
dataType = null;
readDataBlockHeader("MATRIX", DATA_BLOCK);
SimpleAlignment alignment = new SimpleAlignment();
readSequenceData(alignment, null);
alignment.updateSiteCount();
findEndBlock();
return alignment;
}
示例12: mergeSequences
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
/**
* Merge sequence data with xml specification.
* @throws ParserConfigurationException
* @throws IOException
* @throws SAXException
* @throws XMLParserException
*/
void mergeSequences(String xml) throws XMLParserException, SAXException, IOException, ParserConfigurationException {
if (xml == null) {
xml = processTemplate(STANDARD_TEMPLATE);
}
loadTemplate(xml);
// create XML for alignments
if (beautiConfig != null) {
for (Alignment alignment : alignments) {
beautiConfig.partitionTemplate.get().createSubNet(alignment, this, true);
}
} else {
// replace alignment
for (BEASTInterface beastObject : pluginmap.values()) {
if (beastObject instanceof Alignment) {
// use toArray to prevent ConcurrentModificationException
for (Object output : beastObject.getOutputs().toArray()) {
replaceInputs((BEASTInterface) output, beastObject, alignments.get(0));
}
}
}
return;
}
determinePartitions();
}
示例13: loadExternalJars
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
/**
* load external jars in beast directories *
*/
public static void loadExternalJars() throws IOException {
processDeleteList();
addInstalledPackages(packages);
processInstallList(packages);
checkInstalledDependencies(packages);
for (String jarDirName : getBeastDirectories()) {
loadPacakge(jarDirName);
}
externalJarsLoaded = true;
Alignment.findDataTypes();
}
示例14: testNarrowExchange4Taxa
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
@Test
public void testNarrowExchange4Taxa() throws Exception {
int runs = 10000;
Randomizer.setSeed(666);
// test that going from source tree to target tree
// is as likely as going the other way around
// taking the HR in account.
Sequence A = new Sequence("A", "A");
Sequence B = new Sequence("B", "A");
Sequence C = new Sequence("C", "A");
Sequence D = new Sequence("D", "A");
Alignment data = new Alignment();
data.initByName("sequence", A, "sequence", B, "sequence", C, "sequence", D,
"dataType", "nucleotide"
);
String sourceTree = "((A:2.0,B:2.0):1.0,(C:1.0,D:1.0):2.0):0.0"; // ((A,B),(C,D))
String targetTree = "((A:2.0,(C:1.0,D:1.0):1.0):1.0,B:3.0):0.0"; // ((A,(C,D)),B)
testNarrowExchange(sourceTree, targetTree, runs, data);
}
示例15: testNarrowExchange6Taxa
import beast.evolution.alignment.Alignment; //导入依赖的package包/类
@Test
public void testNarrowExchange6Taxa() throws Exception {
int runs = 10000;
Randomizer.setSeed(666);
Sequence A = new Sequence("A", "A");
Sequence B = new Sequence("B", "A");
Sequence C = new Sequence("C", "A");
Sequence D = new Sequence("D", "A");
Sequence E = new Sequence("E", "A");
Sequence F = new Sequence("F", "A");
Alignment data = new Alignment();
data.initByName("sequence", A, "sequence", B, "sequence", C, "sequence", D, "sequence", E, "sequence", F,
"dataType", "nucleotide"
);
//String sourceTree = "((((A:2.0,B:2.0):1.0,(C:1.0,D:1.0):2.0):1.0,E:4.0):1.0,F:5.0):0.0"; // ((((A,B),(C,D)),E),F)
//String targetTree = "((((A:2.0,(C:1.0,D:1.0):1.0):1.0,B:3.0):1.0,E:4.0):1.0,F:5.0):0.0"; // ((((A,(C,D)),B),E),F)
String sourceTree = "(((A:5.0,B:5.0):2.0,((C:5.0,D:5.0):1.0,E:6.0):1.0):1.0,F:8.0):0.0";
String targetTree = "(((A:5.0,B:5.0):2.0,F:7.0):1.0,((C:5.0,D:5.0):1.0,E:6.0):2.0):0.0";
testNarrowExchange(sourceTree, targetTree, runs, data);
}