Search in sources :

Example 11 with Taxon

use of dr.evolution.util.Taxon in project beast-mcmc by beast-dev.

the class XMLExporter method exportAlignment.

// END: Constructor
public String exportAlignment(SimpleAlignment alignment) throws IOException {
    StringWriter sw = new StringWriter();
    XMLWriter writer = new XMLWriter(sw);
    //		TODO: if we keep the taxa element than lets also write dates		
    //		writer.writeOpenTag(TaxaParser.TAXA, // tagname
    //				new Attribute[] { // attributes[]
    //				new Attribute.Default<String>(XMLParser.ID, TaxaParser.TAXA) });
    //		
    //		for (int i = 0; i < alignment.getTaxonCount(); i++) {
    //
    //			Taxon taxon = alignment.getTaxon(i);
    //
    //			writer.writeTag(
    //					TaxonParser.TAXON, // tagname
    //					new Attribute[] { // attributes[]
    //					new Attribute.Default<String>(XMLParser.ID, taxon.getId()) },
    //					true // close
    //			);
    //
    ////			System.out.println(taxon.getAttribute(Utils.ABSOLUTE_HEIGHT));
    //			
    ////			writer.writeCloseTag(TaxonParser.TAXON);
    //			
    //		}// END: taxon loop
    //		
    //		writer.writeCloseTag(TaxaParser.TAXA);
    //		
    //		writer.writeBlankLine();
    // tagname
    writer.writeOpenTag(// tagname
    AlignmentParser.ALIGNMENT, new Attribute[] { // attributes[]
    new Attribute.Default<String>(XMLParser.ID, AlignmentParser.ALIGNMENT), new Attribute.Default<String>(DataType.DATA_TYPE, alignment.getDataType().getDescription()) });
    for (int i = 0; i < alignment.getSequenceCount(); i++) {
        Taxon taxon = alignment.getTaxon(i);
        writer.writeOpenTag(SequenceParser.SEQUENCE);
        writer.writeIDref(TaxonParser.TAXON, taxon.getId());
        writer.writeText(alignment.getSequence(i).getSequenceString());
        writer.writeCloseTag(SequenceParser.SEQUENCE);
    }
    //END: sequences loop
    writer.writeCloseTag(AlignmentParser.ALIGNMENT);
    writer.close();
    return sw.toString();
}
Also used : StringWriter(java.io.StringWriter) Attribute(dr.util.Attribute) Taxon(dr.evolution.util.Taxon) XMLWriter(dr.app.beauti.util.XMLWriter)

Example 12 with Taxon

use of dr.evolution.util.Taxon in project beast-mcmc by beast-dev.

the class TreesTableModel method applyTaxa.

// END: setRow
public void applyTaxa(Tree tree) {
    // set attributes to be parsed later in Taxa panel
    Taxa taxa = new Taxa();
    for (Taxon taxon : tree.asList()) {
        double absoluteHeight = Utils.getAbsoluteTaxonHeight(taxon, tree);
        taxon.setAttribute(Utils.ABSOLUTE_HEIGHT, absoluteHeight);
        taxon.setAttribute(Utils.TREE_FILENAME, tree.getId());
        taxa.addTaxon(taxon);
        dataList.allTaxa.addTaxon(taxon);
    }
// END: taxon loop
}
Also used : Taxa(dr.evolution.util.Taxa) Taxon(dr.evolution.util.Taxon)

Example 13 with Taxon

use of dr.evolution.util.Taxon in project beast-mcmc by beast-dev.

the class Utils method printTaxaSet.

// END: printDataType
public static void printTaxaSet(Taxa taxa) {
    for (int i = 0; i < taxa.getTaxonCount(); i++) {
        Taxon taxon = taxa.getTaxon(i);
        System.out.print("\t\t " + taxonToString(taxon, false) + ("\n"));
    }
}
Also used : Taxon(dr.evolution.util.Taxon)

Example 14 with Taxon

use of dr.evolution.util.Taxon in project beast-mcmc by beast-dev.

the class Utils method printHashMap.

// END: printMap
public static void printHashMap(ConcurrentHashMap<?, ?> hashMap) {
    Iterator<?> iterator = hashMap.entrySet().iterator();
    while (iterator.hasNext()) {
        Entry<?, ?> pairs = (Entry<?, ?>) iterator.next();
        Taxon taxon = (Taxon) pairs.getKey();
        int[] sequence = (int[]) pairs.getValue();
        System.out.println(taxon.toString());
        Utils.printArray(sequence);
    }
// END: while has next
}
Also used : Entry(java.util.Map.Entry) Taxon(dr.evolution.util.Taxon)

Example 15 with Taxon

use of dr.evolution.util.Taxon in project beast-mcmc by beast-dev.

the class Utils method getAbsoluteTaxonHeight.

// END: taxonExists
// private boolean isFileInList(File file) {
// boolean exists = false;
//
// for (File file2 : dataList.treesList) {
//
// if (file.getName().equalsIgnoreCase(file2.getName())) {
// exists = true;
// break;
// }
//
// }
//
// return exists;
// }// END: isFileInList
public static double getAbsoluteTaxonHeight(Taxon taxon, Tree tree) {
    double height = 0.0;
    for (int i = 0; i < tree.getExternalNodeCount(); i++) {
        NodeRef externalNode = tree.getExternalNode(i);
        Taxon externalNodeTaxon = tree.getNodeTaxon(externalNode);
        if (externalNodeTaxon.equals(taxon)) {
            height = tree.getNodeHeight(externalNode);
        }
    }
    return height;
}
Also used : NodeRef(dr.evolution.tree.NodeRef) Taxon(dr.evolution.util.Taxon)

Aggregations

Taxon (dr.evolution.util.Taxon)151 Taxa (dr.evolution.util.Taxa)31 ArrayList (java.util.ArrayList)24 TaxonList (dr.evolution.util.TaxonList)19 NodeRef (dr.evolution.tree.NodeRef)18 Date (dr.evolution.util.Date)18 Tree (dr.evolution.tree.Tree)15 Sequence (dr.evolution.sequence.Sequence)12 TreeModel (dr.evomodel.tree.TreeModel)12 Parameter (dr.inference.model.Parameter)12 Attribute (dr.util.Attribute)11 SimpleAlignment (dr.evolution.alignment.SimpleAlignment)10 Patterns (dr.evolution.alignment.Patterns)9 NewickImporter (dr.evolution.io.NewickImporter)7 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)7 Microsatellite (dr.evolution.datatype.Microsatellite)6 IOException (java.io.IOException)5 HashSet (java.util.HashSet)5 PatternList (dr.evolution.alignment.PatternList)4 DataType (dr.evolution.datatype.DataType)4