Package edu.msu.cme.rdp.classifier

Examples of edu.msu.cme.rdp.classifier.HierarchyTree


        if ( !root.getName().equalsIgnoreCase(tokens[2].trim()) || !root.getRank().equalsIgnoreCase(tokens[3].trim())) {
            throw new IllegalArgumentException("Root of \"" + line + "\" does not match the Root node in the original Classifier training data: " + root.getName() + "\t" + root.getRank());
        }
       
        HierarchyTree currRoot = root;

        assignments.add(new RankAssignment(currRoot, Float.valueOf(tokens[4].trim())));

        for(int index = 5;index < tokens.length;index += 3) {
            String nextName = tokens[index].trim();
            boolean found = false;
            for(HierarchyTree tree : (List<HierarchyTree>)currRoot.getSubclasses()) {
                if(tree.getName().equals(nextName)) {
                    currRoot = tree;
                    assignments.add(new RankAssignment(currRoot, Float.valueOf(tokens[index + 2].trim())));
                    found = true;
                    break;
View Full Code Here


            double copyNumber = 0.0f
            if ( attrs.getLength() > 6){
                copyNumber = Double.parseDouble(attrs.getValue(6));
            }

            HierarchyTree aTree = new HierarchyTree(attrs.getValue(0), taxid, attrs.getValue(2), leaveCount, genusIndex, copyNumber);
            // The first TreeNode is the root
            if (root == null) {
                aTree.addParent(null);
                root = aTree;
            } else {
                HierarchyTree parent = null;
                while (!treeNodeStack.empty()) {
                    HierarchyTree topNode = (HierarchyTree) treeNodeStack.peek();
                    if (topNode.getTaxid() == parentTaxid) {
                        parent = topNode;
                        break;
                    }
                    treeNodeStack.pop();
                }
View Full Code Here

    TreeFileParser parser = new TreeFileParser();
    InputStream dstream = System.class.getResourceAsStream("/test/classifier/testTreeFile.xml");
    HierarchyVersion hVersion = null;
   
    Reader in =  new InputStreamReader( dstream );
    HierarchyTree root = parser.createTree(in, null);
    assertEquals(root.getName(), "BACTERIA");
    assertEquals(root.getLeaveCount(), 4123);
    assertEquals(root.getSizeofSubclasses(), 3);
    //displayTrainingTree(root);
   
    Iterator i = root.getSubclasses().iterator();
   
    while (i.hasNext()){
      HierarchyTree child = (HierarchyTree)i.next();
      if (child.getTaxid() == 1247){  //PLANCTOMYCETES
         assertEquals(child.getName(), "PLANCTOMYCETES");
         assertEquals(child.getRank(), "PHYLUM");
         assertEquals(child.getLeaveCount(), 11);
         assertEquals(child.getSizeofSubclasses(), 1);
      }
    }
  }
View Full Code Here

        train.createLogWordPriorArr(in);
       
        int genusNodeListSize = train.getGenusNodeListSize();
        assertEquals(genusNodeListSize, 6);
       
        HierarchyTree genusNode = train.getGenusNodebyIndex(3);
        assertEquals(genusNode.getGenusIndex(), 3);
        assertEquals(genusNode.getName(), "Pseudomonas");
        int leaveCount = genusNode.getLeaveCount();
        float logLeaveCount = train.getLogLeaveCount(1);
        assertEquals((double)leaveCount, Math.exp(logLeaveCount) -1, 0.1);
       
        HierarchyTree rootTree = train.getRootTree();
        assertEquals(rootTree.getName(), "Bacteria");
        assertNotNull( rootTree.getSubclasses());
       
        Classifier aClassifier = train.createClassifier();
       
        //test addConfidence()
       
        HashMap<HierarchyTree, RankAssignment> determinedMap = new HashMap <HierarchyTree, RankAssignment>();
    HierarchyTree determinedGenusNode = train.getGenusNodebyIndex(4);
    HierarchyTree Enterobacteriales = determinedGenusNode.getParent().getParent();
    HierarchyTree Gammaproteobacteria = Enterobacteriales.getParent();
   
    HierarchyTree aNode = determinedGenusNode;
    while (aNode != null){     
      determinedMap.put(aNode, new RankAssignment(aNode, 0));
      aNode = aNode.getParent();
    }
   
    HierarchyTree bestNode = train.getGenusNodebyIndex(1)// Vibrio
    aClassifier.addConfidence(bestNode, determinedMap);
    assertEquals( determinedMap.get(determinedGenusNode).getConfidence(), 0.0f, 0.0001)//Enterobacter
    assertEquals( determinedMap.get(Enterobacteriales).getConfidence(), 0.0f, 0.0001)//Enterobacteriales
    assertEquals( determinedMap.get(Gammaproteobacteria).getConfidence(), 1.0f, 0.0001)//Gammaproteobacteria
       
View Full Code Here

TOP

Related Classes of edu.msu.cme.rdp.classifier.HierarchyTree

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.