Search in sources :

Example 46 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.

the class AnnotationTest method testHighAndLow.

@Test
public void testHighAndLow() {
    Annotation a = new Annotation();
    List<AnnotationEvidence> evidences = new ArrayList<>();
    evidences.add(buildEvidence("high"));
    evidences.add(buildEvidence("low"));
    a.setEvidences(evidences);
    Assert.assertTrue(a.isExpressionLevelDetected().isPresent());
    Assert.assertTrue(a.isExpressionLevelDetected().get());
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) ArrayList(java.util.ArrayList) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 47 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.

the class AnnotationTest method testEmptyExpressionLevel.

@Test
public void testEmptyExpressionLevel() {
    Annotation a = new Annotation();
    List<AnnotationEvidence> evidences = new ArrayList<>();
    evidences.add(buildEvidence(""));
    a.setEvidences(evidences);
    Assert.assertTrue(a.isExpressionLevelDetected().isPresent());
    Assert.assertTrue(!a.isExpressionLevelDetected().get());
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) ArrayList(java.util.ArrayList) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 48 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.

the class AnnotationTest method testOneHigh.

@Test
public void testOneHigh() {
    Annotation a = new Annotation();
    List<AnnotationEvidence> evidences = new ArrayList<>();
    evidences.add(buildEvidence("high"));
    a.setEvidences(evidences);
    Assert.assertTrue(a.isExpressionLevelDetected().isPresent());
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) ArrayList(java.util.ArrayList) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 49 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.

the class EntryUtils method getFunctionInfoWithCanonicalFirst.

public static List<String> getFunctionInfoWithCanonicalFirst(Entry entry) {
    List<String> fInfoCanonical = new ArrayList<String>();
    List<String> fInfoNonCanonical = new ArrayList<String>();
    List<Isoform> isos = entry.getIsoforms();
    String canonicalIso = "";
    // Get Id of the canonical (swissprotdisplayed) isoform
    for (Isoform curriso : isos) if (curriso.isCanonicalIsoform()) {
        canonicalIso = curriso.getUniqueName();
        break;
    }
    // Get the function annotation and put it in the right basket
    for (Annotation currannot : entry.getAnnotations()) {
        if (currannot.getAPICategory().equals(AnnotationCategory.FUNCTION_INFO))
            if (currannot.isSpecificForIsoform(canonicalIso))
                fInfoCanonical.add(currannot.getDescription());
            else
                fInfoNonCanonical.add(currannot.getDescription());
    }
    // Merge the lists in a final unique list with canonical function first
    // System.err.println("before: " + fInfoCanonical);
    fInfoCanonical.addAll(fInfoNonCanonical);
    // System.err.println("after: " + fInfoCanonical);
    if (fInfoCanonical.size() == 0) {
        Set<Annotation> goFuncSet = new TreeSet<>((e1, e2) -> {
            // GOLD over SILVER, then GO_BP over GO_MF, then Alphabetic in term name cf: jira NEXTPROT-1238
            int c;
            c = e1.getQualityQualifier().compareTo(e2.getQualityQualifier());
            if (c == 0)
                c = e1.getCategory().compareTo(e2.getCategory());
            if (c == 0)
                c = e1.getCvTermName().compareTo(e2.getCvTermName());
            return c;
        });
        List<Annotation> annots = entry.getAnnotations();
        for (Annotation currannot : annots) {
            String category = currannot.getCategory();
            if (category.equals("go biological process") || category.equals("go molecular function")) {
                goFuncSet.add(currannot);
            }
        }
        int rescnt = 0;
        for (Annotation resannot : goFuncSet) {
            // Stick term's name in the returned list
            if (// avoid unsignificant function if possible
            resannot.getCvTermName().equals("protein binding") && goFuncSet.size() > 3)
                continue;
            if (// return max 3 first annotation descriptions
            rescnt++ < 3)
                fInfoCanonical.add(resannot.getCvTermName());
            else
                break;
        }
    }
    return fInfoCanonical;
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 50 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.

the class PepXServiceImpl method findEntriesWithPeptides.

@Override
public List<Entry> findEntriesWithPeptides(String peptides, boolean modeIsoleucine) {
    List<Entry> entries = new ArrayList<>();
    PepXResponse pepXResponse = getPepXResponse(peptides, modeIsoleucine);
    Set<String> entriesNames = pepXResponse.getEntriesNames();
    for (String entryName : entriesNames) {
        EntryConfig targetIsoconf = EntryConfig.newConfig(entryName).withTargetIsoforms().with("variant").withOverview().withoutAdditionalReferences().withoutProperties();
        Entry entry = entryBuilderService.build(targetIsoconf);
        List<Annotation> virtualAnnotations = new ArrayList<>();
        Set<String> peptidesForEntry = pepXResponse.getPeptidesForEntry(entryName);
        for (String peptide : peptidesForEntry) {
            PepXEntryMatch pepxEntryMatch = pepXResponse.getPeptideMatch(peptide).getPepxMatchesForEntry(entryName);
            if (pepxEntryMatch != null && pepxEntryMatch.getIsoforms() != null && pepxEntryMatch.getIsoforms().size() > 0) {
                virtualAnnotations.addAll(buildEntryWithVirtualAnnotations(peptide, modeIsoleucine, pepxEntryMatch.getIsoforms(), entry.getAnnotations(), entry.getIsoforms()));
            }
        }
        if ((virtualAnnotations != null) && (!virtualAnnotations.isEmpty())) {
            Entry resultEntry = new Entry(entry.getUniqueName());
            // Adds the overview as well
            resultEntry.setOverview(entry.getOverview());
            resultEntry.setAnnotations(virtualAnnotations);
            entries.add(resultEntry);
        }
    }
    // add peptide unicity extra info required to unicity checker and peptide viewer
    updateAnnotationsWithPeptideProperties(entries);
    return entries;
}
Also used : Entry(org.nextprot.api.core.domain.Entry) EntryConfig(org.nextprot.api.core.service.fluent.EntryConfig) PepXResponse(org.nextprot.api.web.domain.PepXResponse) PepXEntryMatch(org.nextprot.api.web.domain.PepXResponse.PepXEntryMatch) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Aggregations

Annotation (org.nextprot.api.core.domain.annotation.Annotation)120 Test (org.junit.Test)79 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)32 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)28 AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)22 ArrayList (java.util.ArrayList)19 Isoform (org.nextprot.api.core.domain.Isoform)17 Entry (org.nextprot.api.core.domain.Entry)9 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)7 BioObject (org.nextprot.api.core.domain.BioObject)7 PepXIsoformMatch (org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch)7 AnnotationProperty (org.nextprot.api.core.domain.annotation.AnnotationProperty)6 AnnotationSimilarityPredicate (org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate)6 Collectors (java.util.stream.Collectors)5 NextProtException (org.nextprot.api.commons.exception.NextProtException)5 WebUnitBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest)5 Assert (org.junit.Assert)4 CvTerm (org.nextprot.api.core.domain.CvTerm)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 java.util (java.util)3