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
bestNode = train.getGenusNodebyIndex(4); //Enterobacter
aClassifier.addConfidence(bestNode, determinedMap);
assertEquals( determinedMap.get(determinedGenusNode).getConfidence(), 1.0f, 0.0001); //Enterobacter
assertEquals( determinedMap.get(Enterobacteriales).getConfidence(), 1.0f, 0.0001); //Enterobacteriales
assertEquals( determinedMap.get(Gammaproteobacteria).getConfidence(), 2.0f, 0.0001); //Gammaproteobacteria
aClassifier.addConfidence(train.getGenusNodebyIndex(4), determinedMap); //Enterobacter
aClassifier.addConfidence(train.getGenusNodebyIndex(0), determinedMap); //Clostridium
assertEquals( determinedMap.get(determinedGenusNode).getConfidence(), 2.0f, 0.0001); //Enterobacter
assertEquals( determinedMap.get(Enterobacteriales).getConfidence(), 2.0f, 0.0001); //Enterobacteriales
assertEquals( determinedMap.get(Gammaproteobacteria).getConfidence(), 3.0f, 0.0001); //Gammaproteobacteria
assertEquals( determinedMap.get(rootTree).getConfidence(), 4.0f, 0.0001); //Bacteria
// end test addConfidence()
// end of
dstream = System.class.getResourceAsStream("/test/classifier/testQuerySeq.fasta");
in = new InputStreamReader( dstream );
BufferedReader infile = new BufferedReader(in);
// test the first sequence
String sequence = "";
infile.readLine();
sequence = infile.readLine();
sequence = sequence.toUpperCase();
ClassifierSequence pSeq = new ClassifierSequence("name", "title", sequence);
ClassificationResult result = aClassifier.classify(pSeq);
Iterator it = result.getAssignments().iterator();
RankAssignment classResult = (RankAssignment) it.next();
assertEquals(classResult.getBestClass().getName() , rootTree.getName());
assertEquals(classResult.getConfidence(), 1.0, 0.1);
classResult = (RankAssignment) it.next();
assertEquals(classResult.getBestClass().getName() , "Proteobacteria");
it.next();
classResult = (RankAssignment) it.next();
assertEquals(classResult.getBestClass().getName() , "Rhizobiales");
it.next();
classResult = (RankAssignment) it.next();
assertEquals(classResult.getBestClass().getName() , "Rhizobium");
//displayResult(result);
// end of test first sequence
// test the second sequence
infile.readLine();
sequence = infile.readLine();
sequence = sequence.toUpperCase();
pSeq = new ClassifierSequence("name", "title", sequence);
result = aClassifier.classify(pSeq);
it = result.getAssignments().iterator();
classResult = (RankAssignment) it.next();
assertEquals(classResult.getBestClass().getName() , rootTree.getName());
assertEquals(classResult.getConfidence(), 1.0, 0.1);
classResult = (RankAssignment) it.next();
assertEquals(classResult.getBestClass().getName() , "Firmicutes");
it.next();
classResult = (RankAssignment) it.next();
assertEquals(classResult.getBestClass().getName() , "Clostridiales");
it.next();
classResult = (RankAssignment) it.next();
assertEquals(classResult.getBestClass().getName() , "Clostridium");
// end of test second sequence
}