Search in sources :

Example 1 with GlobalHit

use of org.nextprot.api.blast.domain.GlobalHit in project nextprot-api by calipho-sib.

the class BlastResultUpdaterServiceImplTest method updateShouldDefineNewFields.

@Test
public void updateShouldDefineNewFields() throws Exception {
    Report blastResult = runBlast();
    Assert.assertNull(blastResult.getResults().getSearch().getHits().get(0).getHsps().get(0).getIdentityPercent());
    updater.update(blastResult, "GTTYVTDKSEEDNEIESEEEVQPKTQGSRR");
    Assert.assertNotNull(blastResult.getResults().getSearch().getHits().get(0).getHsps().get(0).getIdentityPercent());
    GlobalHit globalHit = blastResult.getResults().getSearch().getHits().get(0).getGlobalHit();
    Assert.assertEquals(100, globalHit.getIdentityPercent(), 0.01);
    Assert.assertEquals(148, globalHit.getTotalScore(), 0.01);
    Assert.assertEquals(1.45816e-12, globalHit.getMinEvalue(), 0.01);
    Assert.assertEquals(148, globalHit.getMaxScore(), 0.01);
}
Also used : GlobalHit(org.nextprot.api.blast.domain.GlobalHit) Report(org.nextprot.api.blast.domain.gen.Report) Test(org.junit.Test)

Example 2 with GlobalHit

use of org.nextprot.api.blast.domain.GlobalHit in project nextprot-api by calipho-sib.

the class BlastResultUpdaterServiceImpl method buildGlobalHit.

private GlobalHit buildGlobalHit(List<Hsp> hsps, int queryLen) {
    int totalIdentityCount = 0;
    int totalScore = 0;
    int maxScore = Integer.MIN_VALUE;
    double minEvalue = Double.MAX_VALUE;
    for (Hsp hsp : hsps) {
        int currentScore = hsp.getScore();
        double currentEvalue = hsp.getEvalue();
        totalIdentityCount += hsp.getIdentity();
        totalScore += currentScore;
        maxScore = (currentScore > maxScore) ? currentScore : maxScore;
        minEvalue = (currentEvalue < minEvalue) ? currentEvalue : minEvalue;
    }
    float identityPercent = (float) totalIdentityCount / queryLen * 100;
    GlobalHit globalHit = new GlobalHit();
    globalHit.setIdentityPercent(Float.parseFloat(PERCENT_FORMAT.format(identityPercent)));
    globalHit.setMaxScore(maxScore);
    globalHit.setMinEvalue(minEvalue);
    globalHit.setTotalScore(totalScore);
    return globalHit;
}
Also used : GlobalHit(org.nextprot.api.blast.domain.GlobalHit)

Aggregations

GlobalHit (org.nextprot.api.blast.domain.GlobalHit)2 Test (org.junit.Test)1 Report (org.nextprot.api.blast.domain.gen.Report)1