use of beast.evolution.alignment.Taxon in project beast2 by CompEvol.
the class MRCAPriorInputEditor method getTaxonCandidates.
Set<Taxon> getTaxonCandidates(MRCAPrior prior) {
Set<Taxon> candidates = new HashSet<>();
Tree tree = prior.treeInput.get();
String[] taxa = null;
if (tree.m_taxonset.get() != null) {
try {
TaxonSet set = tree.m_taxonset.get();
set.initAndValidate();
taxa = set.asStringList().toArray(new String[0]);
} catch (Exception e) {
taxa = prior.treeInput.get().getTaxaNames();
}
} else {
taxa = prior.treeInput.get().getTaxaNames();
}
for (String taxon : taxa) {
candidates.add(doc.getTaxon(taxon));
}
return candidates;
}
use of beast.evolution.alignment.Taxon in project beast2 by CompEvol.
the class TaxonSetDialog method processEntry.
private void processEntry() {
String filter = ".*" + filterEntry.getText() + ".*";
listModel1.clear();
for (Taxon taxon : _candidates) {
if (taxon.getID().matches(filter)) {
listModel1.addElement(taxon);
}
}
for (int i = 0; i < listModel2.size(); i++) {
listModel1.removeElement(listModel2.get(i));
}
}
use of beast.evolution.alignment.Taxon in project bacter by tgvaughan.
the class TestBase method getTaxonSet.
public TaxonSet getTaxonSet(int nTaxa) {
List<Taxon> taxonList = new ArrayList<>();
for (int i = 0; i < nTaxa; i++) {
try {
taxonList.add(new Taxon("t" + i));
} catch (Exception e) {
System.out.println("Error creating test taxon.");
System.exit(1);
}
}
TaxonSet taxonSet = null;
try {
taxonSet = new TaxonSet(taxonList);
} catch (Exception e) {
System.out.println("Error creating test taxon set.");
System.exit(1);
}
return taxonSet;
}
use of beast.evolution.alignment.Taxon in project bacter by tgvaughan.
the class AddRemoveConversion method main.
public static void main(String[] args) throws Exception {
ConversionGraph acg = new ConversionGraph();
ConstantPopulation popFunc = new ConstantPopulation();
AddRemoveConversion operator = new AddRemoveConversion();
operator.initByName("weight", 1.0, "acg", acg, "populationModel", popFunc, "rho", new RealParameter(Double.toString(1.0 / 10000.0)), "delta", new RealParameter("50.0"));
popFunc.initByName("popSize", new RealParameter("1.0"));
TaxonSet taxonSet = new TaxonSet();
taxonSet.taxonsetInput.setValue(new Taxon("t1"), taxonSet);
taxonSet.taxonsetInput.setValue(new Taxon("t2"), taxonSet);
Locus locus = new Locus("locus", 10000);
try (PrintStream ps = new PrintStream("out.txt")) {
for (int i = 0; i < 100000; i++) {
acg.initByName("locus", locus, "taxonset", taxonSet, "fromString", "(0:1.0,1:1.0)2:0.0;");
operator.drawNewConversion();
ps.println(acg.getConversions(locus).get(0).getStartSite() + " " + acg.getConversions(locus).get(0).getEndSite());
}
}
}
use of beast.evolution.alignment.Taxon in project beast2 by CompEvol.
the class FilteredAlignmentTest method testWeightedSitesReordered.
public void testWeightedSitesReordered() throws Exception {
// reorder taxa
Alignment data = getAlignmentNoTInHuman();
data.setID("data");
List<Taxon> taxa = new ArrayList<>();
taxa.add(new Taxon("1chimp"));
taxa.add(new Taxon("0human"));
TaxonSet set = new TaxonSet(taxa);
data.taxonSetInput.setValue(set, data);
data.siteWeightsInput.setValue("11232, 2, 3, 4 ,1123,2,3,4,112,2,3,4,11,2,3, 4 ", data);
data.initAndValidate();
String weights = Arrays.toString(data.getWeights());
System.out.println(weights + "\n0human\t" + alignmentToString(data, data.getTaxonIndex("0human")) + "\n1chimp\t" + alignmentToString(data, data.getTaxonIndex("1chimp")));
assertEquals("[11243, 1123, 112, 4, 2, 2, 6, 3, 3, 8, 4, 4]", weights);
}
Aggregations