本文整理汇总了Java中dr.evolution.util.Taxa类的典型用法代码示例。如果您正苦于以下问题:Java Taxa类的具体用法?Java Taxa怎么用?Java Taxa使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Taxa类属于dr.evolution.util包,在下文中一共展示了Taxa类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStatesListOfTrait
import dr.evolution.util.Taxa; //导入依赖的package包/类
public static Set<String> getStatesListOfTrait(Taxa taxonList, String traitName) {
Set<String> states = new TreeSet<String>();
if (taxonList == null) {
throw new IllegalArgumentException("taxon list is null");
}
for (int i = 0; i < taxonList.getTaxonCount(); i++) {
Taxon taxon = taxonList.getTaxon(i);
String attr = (String) taxon.getAttribute(traitName);
// ? is used to denote missing data so is not a state...
if (attr != null && !attr.equals("?")) {
states.add(attr);
}
}
return states;
}
示例2: writeTaxaRef
import dr.evolution.util.Taxa; //导入依赖的package包/类
private void writeTaxaRef(String taxaId, PartitionTreeModel model, XMLWriter writer) {
Attribute[] taxaAttribute = {new Attribute.Default<String>(XMLParser.IDREF, taxaId)};
if (options.taxonSets != null && options.taxonSets.size() > 0 && !options.useStarBEAST) { // need !options.useStarBEAST,
// *BEAST case is in STARBEASTGenerator.writeStartingTreeForCalibration(XMLWriter writer)
writer.writeOpenTag(OldCoalescentSimulatorParser.CONSTRAINED_TAXA);
writer.writeTag(TaxaParser.TAXA, taxaAttribute, true);
for (Taxa taxa : options.taxonSets) {
if (options.taxonSetsTreeModel.get(taxa).equals(model)) {
Parameter statistic = options.getStatistic(taxa);
Attribute mono = new Attribute.Default<Boolean>(
OldCoalescentSimulatorParser.IS_MONOPHYLETIC, options.taxonSetsMono.get(taxa));
writer.writeOpenTag(OldCoalescentSimulatorParser.TMRCA_CONSTRAINT, mono);
writer.writeIDref(TaxaParser.TAXA, taxa.getId());
if (model.getPartitionTreePrior().getNodeHeightPrior() == TreePriorType.YULE_CALIBRATION
&& statistic.priorType == PriorType.UNIFORM_PRIOR) {
writeDistribution(statistic, false, writer);
}
writer.writeCloseTag(OldCoalescentSimulatorParser.TMRCA_CONSTRAINT);
}
}
writer.writeCloseTag(OldCoalescentSimulatorParser.CONSTRAINED_TAXA);
} else {
writer.writeTag(TaxaParser.TAXA, taxaAttribute, true);
}
}
示例3: getEmptyStateIndex
import dr.evolution.util.Taxa; //导入依赖的package包/类
public static int getEmptyStateIndex(Taxa taxonList, String traitName) {
if (taxonList == null) {
throw new IllegalArgumentException("taxon list is null");
}
for (int i = 0; i < taxonList.getTaxonCount(); i++) {
Taxon taxon = taxonList.getTaxon(i);
String attr = (String) taxon.getAttribute(traitName);
// ? is used to denote missing data so is not a state...
if (attr == null || attr.equals("?")) {
return i;
}
}
return -1;
}
示例4: getTaxonSet
import dr.evolution.util.Taxa; //导入依赖的package包/类
public TaxonList getTaxonSet() {
TaxonList taxa = options.taxonList;
if (tipDateSamplingTaxonSet != null) {
taxa = tipDateSamplingTaxonSet;
}
if (tipDateSamplingType == TipDateSamplingType.SAMPLE_PRECISION) {
Taxa precisionTaxonList = new Taxa();
for (int i = 0; i < taxa.getTaxonCount(); i++) {
Taxon taxon = taxa.getTaxon(i);
Date date = taxon.getDate();
if (date.getUncertainty() > 0.0) {
precisionTaxonList.addTaxon(taxon);
}
}
taxa = precisionTaxonList;
}
return taxa;
}
示例5: addTaxonAttribute
import dr.evolution.util.Taxa; //导入依赖的package包/类
public void addTaxonAttribute(TaxonList inTaxonList, String traitName) {
taxonList = new Taxa();
for (Taxon taxon : inTaxonList) {
List<Double> valueList = taxonHash.get(taxon.getId());
if (valueList == null) {
Logger.getLogger("dr.evolution").warning("Taxon " + taxon.getId() + " not found in PLINK data");
} else {
String string = makeStringAttribute(valueList);
((Taxa)taxonList).addTaxon(taxon);
taxon.setAttribute(traitName, string);
}
if (DEBUG) {
System.err.println("Added trait for " + taxon.getId());
}
}
}
示例6: createTreeModel
import dr.evolution.util.Taxa; //导入依赖的package包/类
protected TreeModel createTreeModel(int treeSize) throws Exception {
taxa = new Taxa();
for (int i = 0; i < treeSize; i++) {
taxa.addTaxon(new Taxon("T" + Integer.toString(i)));
}
//System.out.println("taxaSubSet_size = " + taxaSubSet.getTaxonCount());
Parameter popSize = new Parameter.Default(treeSize);
popSize.setId(ConstantPopulationModelParser.POPULATION_SIZE);
ConstantPopulationModel startingTree = new ConstantPopulationModel(popSize, Units.Type.YEARS);
Tree tree = calibration(taxa, startingTree);
return new TreeModel(tree);//treeModel
}
示例7: checkCompatibility
import dr.evolution.util.Taxa; //导入依赖的package包/类
protected boolean checkCompatibility(Taxa taxa) {
for (Taxa taxa2 : options.taxonSets) {
if (taxa2 != taxa && options.taxonSetsMono.get(taxa2)
&& options.taxonSetsTreeModel.get(taxa) == options.taxonSetsTreeModel.get(taxa2)) { // no matter if diff tree
if (taxa.containsAny(taxa2) && !taxa.containsAll(taxa2) && !taxa2.containsAll(taxa)) {
JOptionPane.showMessageDialog(frame,
"You cannot enforce monophyly on this " + TAXON.toLowerCase() + " \n" +
"because it is not compatible with another " + TAXON.toLowerCase() + ",\n" +
taxa2.getId() + ", for which monophyly is\n" + "enforced.",
"Warning",
JOptionPane.WARNING_MESSAGE);
return false;
}
}
}
return true;
}
示例8: GreatCircleDistances
import dr.evolution.util.Taxa; //导入依赖的package包/类
public GreatCircleDistances(Taxa taxa, String attributeName) {
distances = new double[taxa.getTaxonCount()][taxa.getTaxonCount()];
for (int i = 0; i < taxa.getTaxonCount(); i++) {
Taxon taxon = taxa.getTaxon(i);
String attr = (String)taxon.getAttribute(attributeName);
String[] loc = attr.split(" ");
double latitude = Double.parseDouble(loc[0]);
double longitude = Double.parseDouble(loc[1]);
SphericalPolarCoordinates coord = new SphericalPolarCoordinates(latitude, longitude);
//System.out.println(coord);
for (int j = i+1; j < taxa.getTaxonCount(); j++) {
Taxon taxon2 = taxa.getTaxon(j);
attr = (String)taxon2.getAttribute(attributeName);
String[] loc2 = attr.split(" ");
latitude = Double.parseDouble(loc2[0]);
longitude = Double.parseDouble(loc2[1]);
SphericalPolarCoordinates coord2 = new SphericalPolarCoordinates(latitude, longitude);
distances[i][j] = distances[j][i] = coord.distance(coord2);
}
}
}
示例9: MetagenomeData
import dr.evolution.util.Taxa; //导入依赖的package包/类
public MetagenomeData(TaxonList taxa, Alignment alignment, LinkageConstraints constraints, boolean fixedReferenceTree)
{
this.alignment = alignment;
this.constraints = constraints;
this.fixedReferenceTree = fixedReferenceTree;
referenceTaxa = new Taxa(taxa.asList());
if(fixedReferenceTree == true && !(taxa instanceof Tree)){
throw new RuntimeException("Error, a tree must be provided in order to fix the topology of reference taxa");
}
reads = new Taxa();
List<Taxon> alltaxa = alignment.asList();
for(int i=0; i<alltaxa.size(); i++)
{
if(!referenceTaxa.contains(alltaxa.get(i)))
reads.addTaxon(alltaxa.get(i));
}
if(constraints==null){
this.constraints = new LinkageConstraints(new ArrayList<LinkedGroup>());
}
}
示例10: parseXMLObject
import dr.evolution.util.Taxa; //导入依赖的package包/类
/** @return an instance of Node created from a DOM element */
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Taxa taxonList = new Taxa();
for (Taxon taxon : xo.getAllChildren(Taxon.class)) {
taxonList.addTaxon(taxon);
}
for (Taxa taxa : xo.getAllChildren(Taxa.class)) {
taxonList.addTaxa(taxa);
}
for (XMLObject cxo : xo.getAllChildren(EXCLUDE)) {
for (Taxa exclude : cxo.getAllChildren(Taxa.class)) {
taxonList.removeTaxa(exclude);
}
}
return taxonList;
}
示例11: GeoDiffusionSimulator
import dr.evolution.util.Taxa; //导入依赖的package包/类
public GeoDiffusionSimulator(
Microsatellite dataType,
Taxa taxa,
Tree tree,
SiteModel siteModel,
BranchRateModel branchRateModel,
double maxLat,
double minLat,
double maxLong,
double minLong) {
super(tree, siteModel, branchRateModel, 1);
this.dataType = dataType;
this.taxa = taxa;
this.maxLat = maxLat;
this.minLat = minLat;
this.maxLong = maxLong;
this.minLong = minLong;
}
示例12: readSampleFile
import dr.evolution.util.Taxa; //导入依赖的package包/类
private static Taxa readSampleFile(String fileName, double generationTime) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
String line = reader.readLine();
Taxa taxa = new Taxa();
int id = 0;
while (line != null) {
if (!line.startsWith("#")) {
String[] tokens = line.split("[\t ]+");
// sample times are in the same units as simulation
double sampleTime = Double.parseDouble(tokens[0]) / generationTime;
int count = Integer.parseInt(tokens[1]);
for (int i = 0; i < count; i++) {
Taxon taxon = new Taxon(id + "");
taxon.setAttribute(dr.evolution.util.Date.DATE, new Date(sampleTime, Units.Type.GENERATIONS, true));
taxa.addTaxon(taxon);
id += 1;
}
}
line = reader.readLine();
}
return taxa;
}
示例13: writeTaxa
import dr.evolution.util.Taxa; //导入依赖的package包/类
private void writeTaxa(Taxa taxa, XMLWriter writer, String suffix) {
writer.writeOpenTag(TaxaParser.TAXA, // tagname
new Attribute[] { // attributes[]
new Attribute.Default<String>(XMLParser.ID, TaxaParser.TAXA + suffix) });
for (int i = 0; i < taxa.getTaxonCount(); i++) {
Taxon taxon = taxa.getTaxon(i);
writer.writeTag(
TaxonParser.TAXON, // tagname
new Attribute[] { // attributes[]
new Attribute.Default<String>(XMLParser.ID, taxon.getId()) },
true // close
);
}// END: i loop
writer.writeCloseTag(TaxaParser.TAXA);
}
示例14: applyTaxa
import dr.evolution.util.Taxa; //导入依赖的package包/类
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
}
示例15: writeTaxonSets
import dr.evolution.util.Taxa; //导入依赖的package包/类
/**
* Generate additional taxon sets
*
* @param writer the writer
* @param taxonSets a list of taxa to write
*/
public void writeTaxonSets(XMLWriter writer, List<Taxa> taxonSets) {
writer.writeText("");
for (Taxa taxa : taxonSets) {
writer.writeOpenTag(
TaxaParser.TAXA,
new Attribute[]{
new Attribute.Default<String>(XMLParser.ID, taxa.getId())
}
);
for (int j = 0; j < taxa.getTaxonCount(); j++) {
writer.writeIDref(TaxonParser.TAXON, taxa.getTaxon(j).getId());
}
writer.writeCloseTag(TaxaParser.TAXA);
}
}