Package edu.msu.cme.rdp.taxatree

Examples of edu.msu.cme.rdp.taxatree.UnifracTree$UnifracResult


    private static void printUsage() {
        new HelpFormatter().printHelp("Unifrac", options, true);
    }

    private static UnifracTree parseNewickTree(String treeFile, Map<String, UnifracSample> sampleMap) throws IOException {
        UnifracTree unifracTree = new UnifracTree();

        NewickTreeBuilder builder = new NewickTreeBuilder(unifracTree, new FileInputStream(treeFile),
                new NewickTaxonFactory<MCTaxon>() {

                    public MCTaxon buildTaxon(int taxid, String name, float distance) {
                        return new UnifracTaxon(taxid, name, "", distance);
                    }
                });


        for (String seqName : sampleMap.keySet()) {
            UnifracSample sample = sampleMap.get(seqName);
            Integer taxid = builder.getTaxidByName(seqName);
            if (taxid == null) {
                System.err.println("Couldn't find " + seqName + " in the tree");
                continue;
            }

            unifracTree.getChildTaxon(taxid).addSampleCount(sample.sample, sample.count);
        }

        unifracTree.refreshInnerTaxa();

        return unifracTree;
    }
View Full Code Here


        } catch(UnrecognizedOptionException e) {
            System.err.println(e.getMessage());
            printUsage();
            return;
        }
        UnifracTree unifracTree = null;
        PrintStream out = System.out;

        if (line.hasOption("tree") && line.hasOption("sequence-files")) {
            printUsage();
        } else if (!(line.hasOption("weighted") || line.hasOption("unweighted") || line.hasOption("significance"))) {
            System.err.println("Must specify at least one calculation option");
            printUsage();
        } else if (line.hasOption("sample-mapping")) {
            Map<String, UnifracSample> sampleMap = readSampleMap(line.getOptionValue("sample-mapping"));

            if (line.hasOption("tree")) {
                unifracTree = parseNewickTree(line.getOptionValue("tree"), sampleMap);
            }
        } else {
            if (!line.hasOption("sample-mapping")) {
                System.err.println("A sample mapping file must be provided");
            }
            printUsage();
        }

        if (line.hasOption("outfile")) {
            out = new PrintStream(line.getOptionValue("outfile"));
        }

        if (unifracTree != null) {
            if (line.hasOption("unweighted")) {
                printResults(out, unifracTree.computeUnifrac(), "Unweighted Unifrac");
                if (line.hasOption("significance")) {
                    printResults(out, unifracTree.computeUnifracSig(1000, false), "Unweighted Unifrac Significance");
                }
            }

            if (line.hasOption("weighted")) {
                printResults(out, unifracTree.computeWeightedUnifrac(), "Weighted Unifrac");
                if (line.hasOption("significance")) {
                    printResults(out, unifracTree.computeUnifracSig(1000, true), "Weighted Unifrac Significance");
                }
            }
        }
    }
View Full Code Here

    public UnifracTreeBuilder(List<ClassificationResult> classifications, final Map<String, UnifracSample> sampleMap) {
        this(classifications, sampleMap, 0.0f);
    }

    public UnifracTreeBuilder(List<ClassificationResult> classifications, final Map<String, UnifracSample> sampleMap, float cutoff) {
        builder = new ClassifierTreeBuilder(new UnifracTree(), classifications, cutoff, new ClassifierTaxonFactory<UnifracTaxon>() {
            public UnifracTaxon buildTaxon(int taxid, String name, String rank, float conf, boolean unclassified) {
                float dist = 1f;
                if(rank.equals("sequence"))
                    dist = 0.0f;
                return new UnifracTaxon(taxid, name, rank, dist, unclassified);
View Full Code Here

TOP

Related Classes of edu.msu.cme.rdp.taxatree.UnifracTree$UnifracResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.