Examples of HierarchyTree


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

                if ( match.getBestMatch().getSeqName().equals(seq.getSeqName())) continue;
                short sab = (short)(Math.round(100*match.getSab()));
                HashMap<String,HierarchyTree> matchAncestorNodes = getAncestorNodes(factory.getRoot(), match.getBestMatch().getSeqName(), lineageMap.get(match.getBestMatch().getSeqName()));
                boolean withinTaxon = false;
                for (int i = ranks.size() -1; i >=0; i--){                   
                    HierarchyTree queryTaxon = queryAncestorNodes.get( ranks.get(i));
                    HierarchyTree matchTaxon = matchAncestorNodes.get( ranks.get(i));
                    if ( queryTaxon != null && matchTaxon != null){
                        if ( queryTaxon.getName().equals(matchTaxon.getName())){
                            if ( !withinTaxon){  // if the query and match are not in the same child taxon, add sab to the current taxon
                                (sabCoutMap.get(ranks.get(i)))[sab]++;
                            }
                            withinTaxon = true;                           
                        }else {
                            withinTaxon = false;
                        }
                    }
                   
                } 
               
                // find within or different lowest level rank sab score, be either species or genus or any rank
                HierarchyTree speciesQueryTaxon = queryAncestorNodes.get( ranks.get(ranks.size()-1));   
                HierarchyTree speciesMatchTaxon = matchAncestorNodes.get( ranks.get(ranks.size()-1));
               
                if ( speciesQueryTaxon != null && speciesMatchTaxon != null && speciesQueryTaxon.getName().equals(speciesMatchTaxon.getName())){
                    withinLowestRankSab = sab >= withinLowestRankSab ? sab: withinLowestRankSab;
                }else {
                   
                    if ( sab >= diffLowestRankSab ){
                        bestDiffLowestRankMatch = match.getBestMatch().getSeqName();
View Full Code Here

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

               
                HashMap<String,HierarchyTree> matchAncestorNodes = getAncestorNodes(factory.getRoot(), trainSeq.getSeqName(), trainSeq.getAncestors());
                boolean withinTaxon = false;
                String lowestCommonRank = null;
                for (int i = ranks.size() -1; i >=0; i--){                   
                    HierarchyTree queryTaxon = queryAncestorNodes.get( ranks.get(i));
                    HierarchyTree matchTaxon = matchAncestorNodes.get( ranks.get(i));
                    if ( queryTaxon != null && matchTaxon != null){
                        if ( queryTaxon.getName().equals(matchTaxon.getName())){
                            if ( !withinTaxon){  // if the query and match are not in the same child taxon, add sab to the current taxon
                                lowestCommonRank = ranks.get(i);
                                //(sabCoutMap.get(ranks.get(i)))[sab]++;
                            }
                            withinTaxon = true;                           
View Full Code Here

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

        }
        outStream.println();
        for ( int i = 0; i < ranks.size(); i++){
            outStream.print(ranks.get(i));
            for ( int t = 0; t < this.trainsets.size(); t++){                  
                HierarchyTree root = trainsets.get(t).getRoot();
                HashMap<String, HierarchyTree> nodeMap = new HashMap<String, HierarchyTree>();
                root.getNodeMap(ranks.get(i), nodeMap);
                outStream.print("\t" + nodeMap.size());
            }
            outStream.println();
        }
        outStream.print("All Seqs");
        for ( HierarchyTreeExtend factory: this.trainsets ){
            HierarchyTree root = factory.getRoot();
            outStream.print("\t" + root.getTotalSeqs());
        }
        outStream.println();
       
        // data for Venn Diagram if less than 3 sets      
        if ( this.trainsets.size() == 2 || this.trainsets.size() == 3){
            outStream.println("\n## data for Venn Diagram");
            for ( int i = 0; i < ranks.size(); i++){
                outStream.println("\n## Rank " + ranks.get(i));
                ArrayList<Set<String>> taxaList = new ArrayList<Set<String>>();
                for ( int t = 0; t < this.trainsets.size(); t++){                  
                    HierarchyTree root = trainsets.get(t).getRoot();
                    HashMap<String, HierarchyTree> nodeMap = new HashMap<String, HierarchyTree>();
                    root.getNodeMap(ranks.get(i), nodeMap);
                    taxaList.add(nodeMap.keySet());
                }
               
                Set<String> tempSet = new HashSet<String>();
                tempSet.addAll(taxaList.get(0));
View Full Code Here

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

        calDist();
    }
  
    private void calDist() throws OverlapCheckFailedException{
        HashMap<String, HierarchyTree> nodeMap = new HashMap<String, HierarchyTree>();
        HierarchyTree root = factory.getRoot();
        root.getNodeMap(factory.getLowestRank(), nodeMap);
       
        for ( int i= 0; i < seqList.size(); i++){
            LineageSequence seqx = seqList.get(i);
            HierarchyTree treex = nodeMap.get((String) seqx.getAncestors().get(seqx.getAncestors().size() - 1));
            for ( int j = i+1; j < seqList.size(); j++){
                LineageSequence seqy = seqList.get(j);
                HierarchyTree treey = nodeMap.get((String) seqy.getAncestors().get(seqy.getAncestors().size() - 1));
               
                Taxonomy lowestCommonAnc = findLowestCommonAncestor(treex, treey);              
                PairwiseAlignment result = PairwiseAligner.align(seqx.getSeqString().replaceAll("U", "T"), seqy.getSeqString().replaceAll("U", "T"), scoringMatrix, mode);
                double distance = dist.getDistance(result.getAlignedSeqj().getBytes(), result.getAlignedSeqi().getBytes(), 0);
View Full Code Here

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

    }
       
    private static Taxonomy findLowestCommonAncestor(HierarchyTree treex, HierarchyTree treey){
        ArrayList<HierarchyTree> ancestorx = new ArrayList<HierarchyTree>();
        ArrayList<HierarchyTree> ancestory = new ArrayList<HierarchyTree>();
        HierarchyTree parent = treex.getParent();
        ancestorx.add(treex);
        while(parent != null) {
            ancestorx.add(parent);
            parent = parent.getParent();
        }
        ancestory.add(treey);
        parent = treey.getParent();
        while(parent != null) {
            ancestory.add(parent);
            parent = parent.getParent();
        }
       
        Taxonomy lowestCommonAnc = ancestorx.get(ancestorx.size() -1).getTaxonomy();
        for ( int i = 2; i <= ancestorx.size() ; i++){
            if (  (ancestory.size() -i ) >= 0 ){
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.