当前位置: 首页>>代码示例>>Java>>正文


Java Taxa类代码示例

本文整理汇总了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;
}
 
开发者ID:whdc,项目名称:ieo-beast,代码行数:21,代码来源:TraitData.java

示例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);
        }
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:33,代码来源:InitialTreeGenerator.java

示例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;
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:18,代码来源:TraitData.java

示例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;
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:23,代码来源:TipDateSamplingComponentOptions.java

示例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());
            }
        }
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:19,代码来源:PlinkImporter.java

示例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
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:17,代码来源:TestCalibratedYuleModel.java

示例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;
}
 
开发者ID:whdc,项目名称:ieo-beast,代码行数:18,代码来源:TaxonSetPanel.java

示例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);
            }
        }
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:31,代码来源:GreatCircleDistances.java

示例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>());
	}
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:21,代码来源:MetagenomeData.java

示例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;
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:22,代码来源:TaxaParser.java

示例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;

}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:21,代码来源:GeoDiffusionSimulator.java

示例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;
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:30,代码来源:VariableCoalescentSimulator.java

示例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);
	}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:22,代码来源:XMLGenerator.java

示例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

	}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:16,代码来源:TreesTableModel.java

示例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);
    }
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:24,代码来源:TMRCAStatisticsGenerator.java


注:本文中的dr.evolution.util.Taxa类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。