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


Java Taxa.addTaxon方法代码示例

本文整理汇总了Java中dr.evolution.util.Taxa.addTaxon方法的典型用法代码示例。如果您正苦于以下问题:Java Taxa.addTaxon方法的具体用法?Java Taxa.addTaxon怎么用?Java Taxa.addTaxon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dr.evolution.util.Taxa的用法示例。


在下文中一共展示了Taxa.addTaxon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

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

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

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

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

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

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

示例7: addTaxonSets

import dr.evolution.util.Taxa; //导入方法依赖的package包/类
private void addTaxonSets(TaxonList taxonList, List<NexusApplicationImporter.TaxSet> taxSets) throws ImportException {
    if (taxSets != null) {
        for (NexusApplicationImporter.TaxSet taxSet : taxSets) {
            Taxa taxa = new Taxa(taxSet.getName());
            for (NexusApplicationImporter.CharSetBlock block : taxSet.getBlocks()) {
                for (int i = block.getFromSite(); i <= block.getToSite(); i++) {
                    taxa.addTaxon(taxonList.getTaxon(i - 1));
                }
            }
            options.taxonSets.add(taxa);
            options.taxonSetsTreeModel.put(taxa, options.getPartitionTreeModels().get(0));
            options.taxonSetsMono.put(taxa, false);
            options.taxonSetsIncludeStem.put(taxa, false);
            options.taxonSetsHeights.put(taxa, 0.0);
        }
    }
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:18,代码来源:BEAUTiImporter.java

示例8: parseXMLObject

import dr.evolution.util.Taxa; //导入方法依赖的package包/类
public Object parseXMLObject(XMLObject xo) throws XMLParseException {

            FileReader fileReader = XMLParser.getFileReader(xo, INPUT_FILE_NAME);
            Logger.getLogger("dr.evomodel.continuous").info("Attempting to read PLINK file...\n");
            PlinkImporter importer;
            try {
                importer = new PlinkImporter(fileReader);
                Logger.getLogger("dr.evomodel.continuous").info(importer.toStatisticsString());
            } catch (IOException e) {
                throw new XMLParseException("Unable to read plink data from file, " + fileReader.getEncoding());
            }


            Taxa taxonList = new Taxa();

            for (int i = 0; i < xo.getChildCount(); i++) {
                Object child = xo.getChild(i);
                if (child instanceof Taxon) {
                    Taxon taxon = (Taxon) child;
                    taxonList.addTaxon(taxon);
                } else if (child instanceof TaxonList) {
                    TaxonList taxonList1 = (TaxonList) child;
                    for (int j = 0; j < taxonList1.getTaxonCount(); j++) {
                        taxonList.addTaxon(taxonList1.getTaxon(j));
                    }
                } else {
                    throwUnrecognizedElement(xo);
                }
            }

            importer.addTaxonAttribute(taxonList, xo.getAttribute(TRAIT_NAME, "null"));
            return importer;
        }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:34,代码来源:PlinkImporter.java

示例9: 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 (int i = 0; i < xo.getChildCount(); i++) {
        Object child = xo.getChild(i);
        if (child instanceof Taxon) {
            Taxon taxon = (Taxon)child;
            taxonList.addTaxon(taxon);
        } else if (child instanceof TaxonList) {
            TaxonList taxonList1 = (TaxonList)child;
            for (int j = 0; j < taxonList1.getTaxonCount(); j++) {
                taxonList.addTaxon(taxonList1.getTaxon(j));
            }
        } else {
            throwUnrecognizedElement(xo);
        }
    }
    return taxonList;
}
 
开发者ID:whdc,项目名称:ieo-beast,代码行数:22,代码来源:TaxaParser.java

示例10: parseXMLObject

import dr.evolution.util.Taxa; //导入方法依赖的package包/类
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    String farmID = (String) xo.getAttribute(CASE_ID);
    final Date cullDate = (Date) xo.getElementFirstChild(CULL_DAY);
    final Date examinationDate = (Date) xo.getElementFirstChild(EXAMINATION_DAY);
    final Parameter oldestLesionAgeParameter = (Parameter) xo.getElementFirstChild(OLDEST_LESION_AGE);
    Taxa tempTaxa = new Taxa();
    for(int i=0; i<xo.getChildCount(); i++){
        if(xo.getChild(i) instanceof Taxon){
            tempTaxa.addTaxon((Taxon)xo.getChild(i));
        }
    }
    final Taxa associatedTaxa = tempTaxa;
    final ParametricDistributionModel incubationPeriodDistribution =
            (ParametricDistributionModel) xo.getElementFirstChild(INCUBATION_PERIOD_DISTRIBUTION);
    final ParametricDistributionModel infectiousDateDistribution =
            (ParametricDistributionModel) xo.getElementFirstChild(INFECTIOUS_DATE_DISTRIBUTION);
    return new LesionDatedFarmCase(farmID, examinationDate, cullDate, infectiousDateDistribution,
            oldestLesionAgeParameter.getParameterValue(0), incubationPeriodDistribution, associatedTaxa);
}
 
开发者ID:whdc,项目名称:ieo-beast,代码行数:21,代码来源:LesionDatedFarmCase.java

示例11: parseXMLObject

import dr.evolution.util.Taxa; //导入方法依赖的package包/类
public Object parseXMLObject(XMLObject xo) throws XMLParseException {

        Taxa originalTaxa = new Taxa();

        for (int i = 0; i < xo.getChildCount(); i++) {
            Object child = xo.getChild(i);
            if (child instanceof Taxon) {
                Taxon taxon = (Taxon)child;
                originalTaxa.addTaxon(taxon);
            } else if (child instanceof TaxonList) {
                TaxonList taxonList1 = (TaxonList)child;
                for (int j = 0; j < taxonList1.getTaxonCount(); j++) {
                    originalTaxa.addTaxon(taxonList1.getTaxon(j));
                }
            } else {
                throwUnrecognizedElement(xo);
            }
        }

        List<Taxon> originalTaxonList = originalTaxa.asList();

        int sampleTotal = xo.getAttribute(COUNT, originalTaxonList.size());
        if (sampleTotal < 2) {
            throw new XMLParseException("Must sample atleast two taxa");
        }

        boolean withReplacement = xo.getAttribute(WITH_REPLACEMENT, false);

        Taxa sampledTaxa = new Taxa();
        for (int i = 0; i < sampleTotal; i++) {
            int choice = MathUtils.nextInt(originalTaxonList.size());
            Taxon taxonToAdd = originalTaxonList.get(choice);
            sampledTaxa.addTaxon(taxonToAdd);

            if (!withReplacement) {
                originalTaxonList.remove(choice);
            }
        }

        return sampledTaxa;
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:42,代码来源:RandomSubsetTaxaParser.java

示例12: parseTaxonListOrTaxa

import dr.evolution.util.Taxa; //导入方法依赖的package包/类
public static TaxonList parseTaxonListOrTaxa(XMLObject cxo) {
    TaxonList taxa = (TaxonList) cxo.getChild(TaxonList.class);
    if (taxa == null) {
        Taxa taxa1 = new Taxa();
        for (int i = 0; i < cxo.getChildCount(); i++) {
            Object ccxo = cxo.getChild(i);
            if (ccxo instanceof Taxon) {
                taxa1.addTaxon((Taxon) ccxo);
            }
        }
        taxa = taxa1;
    }
    return taxa;
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:15,代码来源:MonophylyStatisticParser.java

示例13: testBackboneFilter

import dr.evolution.util.Taxa; //导入方法依赖的package包/类
public void testBackboneFilter() {

        Taxa taxonList = new Taxa();
        taxonList.addTaxon(taxa[0]);
        taxonList.addTaxon(taxa[1]);

        TreeTrait backboneFilter = new TreeTrait.FilteredD(dummyTrait,
                new BackboneNodeFilter("backbone", tree, taxonList, true, true));
        treeTraitProvider.addTrait(backboneFilter);
        TreeTrait sumTrait = new TreeTrait.SumOverTreeD(backboneFilter);
        treeTraitProvider.addTrait(sumTrait);

        System.out.println("BackboneFilter Test");

        StringBuffer buffer = new StringBuffer();

        TreeUtils.newick(tree, tree.getRoot(), false, TreeUtils.BranchLengthType.LENGTHS_AS_TIME,
                null, // format
                null, // branchRates,
                new TreeTraitProvider[]{treeTraitProvider},
                null, //idMap,
                buffer);

        System.out.println("Tree: " + buffer.toString());
        double traitValue = (Double) sumTrait.getTrait(tree, null);
        System.out.println("Trait: " + traitValue);
        assertEquals(traitValue, 7.0); // TODO Get real result
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:29,代码来源:FilteredTreeTraitTest.java

示例14: testBackboneFilter

import dr.evolution.util.Taxa; //导入方法依赖的package包/类
public void testBackboneFilter() {

        Taxa taxonList = new Taxa();
        taxonList.addTaxon(taxa[0]);
        taxonList.addTaxon(taxa[1]);

        TreeTrait backboneFilter = new TreeTrait.FilteredD(dummyTrait,
                new BackboneNodeFilter("backbone", tree, taxonList, true, true));
        treeTraitProvider.addTrait(backboneFilter);
        TreeTrait sumTrait = new TreeTrait.SumOverTreeD(backboneFilter);
        treeTraitProvider.addTrait(sumTrait);

        System.out.println("BackboneFilter Test");

        StringBuffer buffer = new StringBuffer();

        Tree.Utils.newick(tree, tree.getRoot(), false, Tree.BranchLengthType.LENGTHS_AS_TIME,
                null, // format
                null, // branchRates,
                new TreeTraitProvider[]{treeTraitProvider},
                null, //idMap,
                buffer);

        System.out.println("Tree: " + buffer.toString());
        double traitValue = (Double) sumTrait.getTrait(tree, null);
        System.out.println("Trait: " + traitValue);
        assertEquals(traitValue, 7.0); // TODO Get real result
    }
 
开发者ID:whdc,项目名称:ieo-beast,代码行数:29,代码来源:FilteredTreeTraitTest.java

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


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