Search in sources :

Example 1 with Annotation

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

the class AnnotationUtils method filterAnnotationsBetweenPositions.

public static List<Annotation> filterAnnotationsBetweenPositions(int start, int end, List<Annotation> annotations, String isoform) {
    if (annotations == null)
        return null;
    List<Annotation> finalAnnotations = new ArrayList<>();
    for (Annotation annot : annotations) {
        if (annot.isAnnotationPositionalForIsoform(isoform)) {
            int isoStartPosition, isoEndPosition;
            isoStartPosition = annot.getStartPositionForIsoform(isoform);
            isoEndPosition = annot.getEndPositionForIsoform(isoform);
            if ((isoStartPosition >= start) && (isoEndPosition <= end)) {
                finalAnnotations.add(annot);
            }
        }
    }
    return finalAnnotations;
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 2 with Annotation

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

the class AnnotationUtils method containsAtLeast2NonInclusivePeptides.

// related to  rule to PE1 upgrade
private static boolean containsAtLeast2NonInclusivePeptides(List<Annotation> list, int peptideMinSize, int minCoverage, boolean debug) {
    if (list == null)
        return false;
    for (Annotation a : list) {
        if (a.getAPICategory() != AnnotationCategory.PEPTIDE_MAPPING)
            continue;
        Map<String, AnnotationIsoformSpecificity> timA = a.getTargetingIsoformsMap();
        for (String aIsoAC : timA.keySet()) {
            AnnotationIsoformSpecificity aSpec = timA.get(aIsoAC);
            String aName = getPeptideName(a);
            if (aName == null)
                continue;
            int aP1 = aSpec.getFirstPosition();
            int aP2 = aSpec.getLastPosition();
            int aPepSize = aP2 - aP1 + 1;
            // if < min size => ignore
            if (aPepSize < peptideMinSize)
                continue;
            for (Annotation b : list) {
                if (b.getAPICategory() != AnnotationCategory.PEPTIDE_MAPPING)
                    continue;
                Map<String, AnnotationIsoformSpecificity> timB = b.getTargetingIsoformsMap();
                if (timB.containsKey(aIsoAC)) {
                    AnnotationIsoformSpecificity bSpec = timB.get(aIsoAC);
                    String bName = getPeptideName(b);
                    if (bName == null || aName.equals(bName))
                        continue;
                    int bP1 = bSpec.getFirstPosition();
                    int bP2 = bSpec.getLastPosition();
                    int bPepSize = bP2 - bP1 + 1;
                    // if < min size => ignore
                    if (bPepSize < peptideMinSize)
                        continue;
                    // if b is on the left side of a with or without overlap
                    if (aP1 > bP1 && aP2 > bP2) {
                        int overlap = bP2 - aP1 + 1;
                        if (overlap < 0)
                            overlap = 0;
                        if (aPepSize + bPepSize - overlap >= minCoverage) {
                            if (debug == true) {
                                System.out.println("Found 2 non inclusive peptides on " + aIsoAC + ":" + aName + " at " + aP1 + "-" + aP2 + " and " + bName + " at " + bP1 + "-" + bP2 + " with overlap " + overlap + " and coverage " + (aPepSize + bPepSize - overlap));
                            }
                            return true;
                        }
                    }
                // we get here in the following cases:
                // 1) a includes b or a is included in b => ignore
                // or
                // 2) b is on the right side of a with or without overlap
                // this case is met later on going iterating until a and b are swapped
                // (symmetric situation for a and b)
                }
            }
        }
    }
    return false;
}
Also used : AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 3 with Annotation

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

the class HashableAnnotationComparator method compare.

@Override
public int compare(final Annotation a1, final Annotation a2) {
    if (getReferencedAnnotationContainer(a1) == null || getReferencedAnnotationContainer(a2) == null) {
        if (getReferencedAnnotationContainer(a1) == getReferencedAnnotationContainer(a2))
            return 0;
        else if (getReferencedAnnotationContainer(a1) == null)
            return 1;
        else
            return -1;
    }
    Annotation refAnnot1 = getReferencedAnnotation(getAnnotationHash(a1));
    Annotation refAnnot2 = getReferencedAnnotation(getAnnotationHash(a2));
    return referencedAnnotationComparator.compare(refAnnot1, refAnnot2);
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 4 with Annotation

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

the class AnnotationUtilsTest method shouldcomputeIsoformsDisplayedAsSpecificForNonBinaryInteractionCase3.

@Test
public void shouldcomputeIsoformsDisplayedAsSpecificForNonBinaryInteractionCase3() {
    // BinaryInteraction with 1 isoform, 1 targetingIsoform record => should return 0 isoformDiplayed as specific
    int isoCount = 1;
    Map<String, AnnotationIsoformSpecificity> targetIsoformMap = new HashMap<>();
    AnnotationIsoformSpecificity spec1 = new AnnotationIsoformSpecificity();
    spec1.setIsoformAccession("iso1");
    spec1.setSpecificity("SPECIFIC");
    targetIsoformMap.put("iso1", spec1);
    Annotation annot = mock(Annotation.class);
    when(annot.getAPICategory()).thenReturn(AnnotationCategory.GO_MOLECULAR_FUNCTION);
    when(annot.getTargetingIsoformsMap()).thenReturn(targetIsoformMap);
    List<String> result = AnnotationUtils.computeIsoformsDisplayedAsSpecific(annot, isoCount);
    assertEquals(0, result.size());
}
Also used : AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 5 with Annotation

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

the class AnnotationUtilsTest method shouldNotReturnAnnotationIfOusideTheRange.

@Test
public void shouldNotReturnAnnotationIfOusideTheRange() {
    String isoName = "iso-1";
    Annotation a1 = mock(Annotation.class);
    when(a1.isAnnotationPositionalForIsoform(isoName)).thenReturn(true);
    when(a1.getStartPositionForIsoform(isoName)).thenReturn(5);
    when(a1.getEndPositionForIsoform(isoName)).thenReturn(9);
    assertTrue(AnnotationUtils.filterAnnotationsBetweenPositions(10, 20, Arrays.asList(a1), isoName).isEmpty());
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

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