Examples of HierarchyTree


Examples of com.cedarsoft.spring.rcp.hierarchy.HierarchyTree

    detailsModel = hierarchyModelFactory.createDetailsModel( rootObject );

    detailsModel.setContext( getContext() );

    //wire the models
    hierarchyTree = new HierarchyTree( treeModel );
    hierarchyTree.addSelectionListener( detailsModel );

    detailsModel.select( new DetailsTreeSelectionEvent( DetailsTreeSelectionEvent.Type.SELECTED, getEditorObject() ) );
    TreePath initialSelectionPath = getInitialSelectionPath();
    hierarchyTree.getSelectionModel().setSelectionPath( initialSelectionPath );
View Full Code Here

Examples of com.cisco.oss.foundation.configuration.xml.jaxb.HierarchyTree

    protected String marshall(HierarchyTree jaxb) throws XmlException {
        return(parser.marshall(jaxb));
    }

    protected HierarchyTree unmarshall(String xml) throws XmlException {
        HierarchyTree jaxb = null;
        try {
            jaxb = (HierarchyTree)parser.unmarshall(xml);
        } catch(ClassCastException e) {
            throw new XmlException("The given message was not a HierarchyTree Message - ClassCastException: " + e.getMessage(), e);
        }
View Full Code Here

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

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

            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

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

    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

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

        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

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

        //for each sequence with name, and or true path
        List resultList = new ArrayList();

        DecisionMaker dm = new DecisionMaker(factory);
        HierarchyTree root = factory.getRoot();

        HashMap<String, HierarchyTree> genusNodeMap = new HashMap<String, HierarchyTree>();
        factory.getRoot().getNodeMap(testRank, genusNodeMap);

        if (genusNodeMap.isEmpty()) {
            throw new IllegalArgumentException("\nThere is no node in GENUS level!");
        }

        int i = 0;
        Iterator seqIt = seqList.iterator();
        while (seqIt.hasNext()) {
            LineageSequence pSeq = (LineageSequence) seqIt.next();

            GoodWordIterator wordIterator = getPartialSeqIteratorbyWindow(pSeq, window); // full sequence 

            if (wordIterator == null) {
                continue;
            }

            //for leave-one-out testing, we need to remove the word occurrance for
            //the current sequence. This is similiar to hiding a sequence leaf.
            HierarchyTree curTree = genusNodeMap.get((String) pSeq.getAncestors().get(pSeq.getAncestors().size() - 1));


            curTree.hideSeq(wordIterator);
            List result = dm.getBestClasspath( wordIterator, genusNodeMap, false, min_bootstrap_words);

            ValidClassificationResultFacade resultFacade = new ValidClassificationResultFacade(pSeq, result);
            resultFacade.setLabeledNode(curTree);
            compareClassificationResult(resultFacade);

            resultList.add(resultFacade);
            i++;
            // recover the wordOccurrence of the genus node, unhide
            curTree.unhideSeq(wordIterator);

        }

        displayStat();
    }
View Full Code Here

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

    /** Compare the assigned path with the true path for the test getSequence(),
     * counts the number of correct classes and the number of getSequence()s for
     * each path level.
     */
    private void compareClassificationResult(ValidClassificationResultFacade resultFacade) {
        HierarchyTree trueParent = resultFacade.getLabeledNode();
        List hitList = resultFacade.getRankAssignment();

        // compare the true taxon and the hit taxon with same rank.
        while (trueParent != null) {

            if (!trueParent.isSingleton()) {
                ValidationClassificationResult hit = null;
                for (int i = 0; i < hitList.size(); i++) {
                    ValidationClassificationResult tmp = (ValidationClassificationResult) hitList.get(i);
                    if ((trueParent.getTaxonomy().getHierLevel()).equals(tmp.getBestClass().getTaxonomy().getHierLevel())) {
                        hit = tmp;
                        break;
                    }
                }

                if (trueParent.getTaxonomy().getHierLevel().equals(testRank)) {
                    trueParent.incNumTotalTestedseq();
                }
                boolean correct = false;


                if (hit != null && trueParent.getTaxonomy().getTaxID() == hit.getBestClass().getTaxonomy().getTaxID()) {
                    correct = true;
                } else {
                    if (trueParent.getTaxonomy().getHierLevel().equals(testRank)) {
                        trueParent.incMissCount();
                    }
                    resultFacade.setMissedRank(trueParent.getTaxonomy().getHierLevel());
                }
                if (hit != null) {
                    increaseCount(hit, trueParent.getTaxonomy().getHierLevel(), correct, num_hierLevel);
                }

            } else {
                // System.err.println(" singleton: " + trueParent.getName() + " " + trueParent.getTaxonomy().getHierLevel() );
            }

            trueParent = trueParent.getParent();

        }

    }
View Full Code Here

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

        LineageSequenceParser parser = new LineageSequenceParser(source_file);
        HashMap<String, HashSet> genusTrainSeqMap = new HashMap<String, HashSet>(); // keep the seqID for each genus

        while ( parser.hasNext() ){
            LineageSequence pSeq = parser.next();
            HierarchyTree genusNode = factory.addSequence( pSeq);
            HashSet<String> genusSeqSet = genusTrainSeqMap.get(genusNode.getName());
            if ( genusSeqSet == null){
                genusSeqSet = new HashSet<String>();
                genusTrainSeqMap.put(genusNode.getName(), genusSeqSet);
            }
            genusSeqSet.add(pSeq.getSeqName());
        }
        parser.close();


        // random select nodes at the give rank level
        ArrayList<HierarchyTree> nodeList = new ArrayList<HierarchyTree>();
        factory.getRoot().getNodeList(rank, nodeList);      

        Set<HierarchyTree> selectedNodes = new HashSet<HierarchyTree>();

        int testCount = (int) (((float) nodeList.size()) * fraction);
        while (selectedNodes.size() < testCount){
            int rdmIndex = (int) (Math.floor(Math.random()* (double)nodeList.size()));
            selectedNodes.add(nodeList.get(rdmIndex));
            //System.err.println("selected " + nodeList.get( rdmIndex).getName() + "\t" + nodeList.get(rdmIndex).getNumOfLeaves());
            nodeList.remove(rdmIndex);
        }

        // select the seqIDs
        Set<String> selectedSeqIDs = new HashSet<String>();

        for (HierarchyTree node : selectedNodes){
            ArrayList<HierarchyTree> tmp = new ArrayList<HierarchyTree>();
            node.getNodeList(Taxonomy.GENUS, tmp);
            for ( HierarchyTree genusNode: tmp){
                selectedSeqIDs.addAll(genusTrainSeqMap.get(genusNode.getName()));
            }
        }
        return selectedSeqIDs;

    }
View Full Code Here

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

        HashMap<String,HierarchyTree> ancestorNodes = new HashMap<String,HierarchyTree>();
        if ( !ancestors.get(0).equals(root.getName())){
            throw new IllegalArgumentException("Sequence " + seqName + " does not have the same root taxon" + root.getName());
        }
        ancestorNodes.put(root.getTaxonomy().getHierLevel(), root);
        HierarchyTree curParent = root;
        for (int i = 1; i < ancestors.size(); i++){
           
            HierarchyTree  node = curParent.getSubclassbyName(ancestors.get(i));
            if ( node == null){
                throw new IllegalArgumentException("Sequence " + seqName + " cannot find ancestor node: " + ancestors.get(i));
            }
            ancestorNodes.put(node.getTaxonomy().getHierLevel().toLowerCase(), node);
            curParent = node;
        }       
        return ancestorNodes;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.