Search in sources :

Example 11 with Taxon

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;
}
Also used : Taxon(beast.evolution.alignment.Taxon) Tree(beast.evolution.tree.Tree) TaxonSet(beast.evolution.alignment.TaxonSet) InvocationTargetException(java.lang.reflect.InvocationTargetException) HashSet(java.util.HashSet)

Example 12 with Taxon

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));
    }
}
Also used : Taxon(beast.evolution.alignment.Taxon)

Example 13 with Taxon

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;
}
Also used : Taxon(beast.evolution.alignment.Taxon) TaxonSet(beast.evolution.alignment.TaxonSet)

Example 14 with Taxon

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());
        }
    }
}
Also used : PrintStream(java.io.PrintStream) ConstantPopulation(beast.evolution.tree.coalescent.ConstantPopulation) Taxon(beast.evolution.alignment.Taxon) RealParameter(beast.core.parameter.RealParameter) TaxonSet(beast.evolution.alignment.TaxonSet) Locus(bacter.Locus) ConversionGraph(bacter.ConversionGraph)

Example 15 with Taxon

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);
}
Also used : Alignment(beast.evolution.alignment.Alignment) FilteredAlignment(beast.evolution.alignment.FilteredAlignment) Taxon(beast.evolution.alignment.Taxon) ArrayList(java.util.ArrayList) TaxonSet(beast.evolution.alignment.TaxonSet)

Aggregations

Taxon (beast.evolution.alignment.Taxon)26 TaxonSet (beast.evolution.alignment.TaxonSet)18 ArrayList (java.util.ArrayList)7 Alignment (beast.evolution.alignment.Alignment)6 Tree (beast.evolution.tree.Tree)5 PatternSyntaxException (java.util.regex.PatternSyntaxException)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Test (org.junit.Test)4 FilteredAlignment (beast.evolution.alignment.FilteredAlignment)3 MRCAPrior (beast.math.distributions.MRCAPrior)3 Box (javax.swing.Box)3 BEASTInterface (beast.core.BEASTInterface)2 RealParameter (beast.core.parameter.RealParameter)2 TreeParser (beast.util.TreeParser)2 File (java.io.File)2 FileWriter (java.io.FileWriter)2 PrintStream (java.io.PrintStream)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 JButton (javax.swing.JButton)2