本文整理汇总了Java中dr.evolution.util.Taxa.getTaxon方法的典型用法代码示例。如果您正苦于以下问题:Java Taxa.getTaxon方法的具体用法?Java Taxa.getTaxon怎么用?Java Taxa.getTaxon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dr.evolution.util.Taxa
的用法示例。
在下文中一共展示了Taxa.getTaxon方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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);
}
}
}
示例4: 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);
}
示例5: writeTaxonSets
import dr.evolution.util.Taxa; //导入方法依赖的package包/类
/**
* Generate additional taxon sets
*
* @param writer the writer
*/
public void writeTaxonSets(XMLWriter writer) {
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++) {
Taxon taxon = taxa.getTaxon(j);
writer.writeTag(TaxonParser.TAXON, new Attribute[]{new Attribute.Default<String>(XMLParser.IDREF, taxon.getId())}, true);
}
writer.writeCloseTag(TaxaParser.TAXA);
}
}
示例6: isCompatible
import dr.evolution.util.Taxa; //导入方法依赖的package包/类
/**
* Returns true if taxa are all found in availableTaxa
*
* @param taxa a set of taxa
* @param availableTaxa a potential superset of taxa
* @return true if the taxa are all found in availableTaxa
*/
protected boolean isCompatible(Taxa taxa, List<Taxon> availableTaxa) {
for (int i = 0; i < taxa.getTaxonCount(); i++) {
Taxon taxon = taxa.getTaxon(i);
if (!availableTaxa.contains(taxon)) {
return false;
}
}
return true;
}
示例7: isCompatible
import dr.evolution.util.Taxa; //导入方法依赖的package包/类
/**
* Returns true if taxa are all found in availableTaxa
* @param taxa
* @param availableTaxa
* @return true if the taxa are all found in availableTaxa
*/
private boolean isCompatible(Taxa taxa, List availableTaxa) {
for (int i = 0; i < taxa.getTaxonCount(); i++) {
Taxon taxon = taxa.getTaxon(i);
if (!availableTaxa.contains(taxon)) {
return false;
}
}
return true;
}
示例8: parseXMLObject
import dr.evolution.util.Taxa; //导入方法依赖的package包/类
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Taxa population = (Taxa) xo.getChild(Taxa.class);
int n = xo.getIntegerAttribute(SAMPLE);
int N = population.getTaxonCount();
if (n <= 0 || n > N) {
throw new XMLParseException("sample must be greater than 0 and less than or equal to the population size");
}
Taxa sample = new Taxa();
ArrayList<Integer> indexes = new ArrayList<Integer>(N);
for (int i = 0; i < N; i++)
indexes.add(i);
Logger.getLogger("dr.evolution").info("Generating a random taxa sample of size: " + n);
for (int i = 0; i < n; i++) {
int randomIndex = MathUtils.nextInt(indexes.size());
Taxon selectedTaxon = population.getTaxon(indexes.get(randomIndex));
sample.addTaxon(selectedTaxon);
indexes.remove(randomIndex);
}
if (xo.hasAttribute(PRINT_TAXA) && xo.getBooleanAttribute(PRINT_TAXA)) {
String fileName = null;
if (xo.hasAttribute(FILE_NAME)) {
fileName = xo.getStringAttribute(FILE_NAME);
}
if (fileName != null) {
try {
Writer write;
File file = new File(fileName);
String name = file.getName();
String parent = file.getParent();
if (!file.isAbsolute()) {
parent = System.getProperty("user.dir");
}
write = new FileWriter(new File(parent, name));
write.write("<taxa id=\"randomTaxaSample\">\n");
for (int i = 0; i < n; i++) {
write.write("\t<taxon idref=\"" + sample.getTaxonId(i) + "\"/>\n");
}
write.write("</taxa id=\"randomTaxaSample\">\n");
write.flush();
} catch (IOException fnfe) {
throw new XMLParseException("File '" + fileName + "' can not be opened for " + getParserName() + " element.");
}
} else {
Logger.getLogger("dr.evomodel").info("<taxa id=\"randomTaxaSample\">");
for (int i = 0; i < n; i++) {
Logger.getLogger("dr.evomodel").info("\t<taxon idref=\" " + sample.getTaxonId(i) + " \"> ");
}
Logger.getLogger("dr.evomodel").info("</taxa id=\"randomTaxaSample\">");
}
}
return sample;
}
示例9: printTaxaSet
import dr.evolution.util.Taxa; //导入方法依赖的package包/类
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"));
}
}
示例10: taxaToString
import dr.evolution.util.Taxa; //导入方法依赖的package包/类
public static String taxaToString(Taxa taxa, boolean printNames) {
String string = "";
for (int i = 0; i < taxa.getTaxonCount(); i++) {
Taxon taxon = taxa.getTaxon(i);
string += taxonToString(taxon, printNames) + ("\n");
}
return string;
}