Search in sources :

Example 86 with Annotation

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

the class PeptideMappingServiceIntegrationTest method computeCoverage.

private String computeCoverage(Isoform iso, List<Annotation> annotations, boolean proteotypic, boolean sysout) {
    String name = iso.getUniqueName();
    int isoLength = iso.getSequenceLength();
    int[] coverage = new int[isoLength];
    for (Annotation annot : annotations) {
        if (proteotypic && !isAboutProteotypicPeptide(annot))
            continue;
        if (!annot.isAnnotationPositionalForIsoform(name))
            continue;
        int start = annot.getStartPositionForIsoform(name);
        int end = annot.getEndPositionForIsoform(name);
        for (int i = start; i <= end; i++) coverage[i - 1] = 1;
    }
    int covered = getCoverageCount(coverage);
    float rate = (float) 100.0 * (float) covered / (float) isoLength;
    float rateRounded = Math.round(rate * 100.0f) / 100.0f;
    String sep = "\t";
    String title = proteotypic ? "proteotypic coverage" : "peptide coverage";
    if (sysout)
        System.out.println(name + sep + title + sep + isoLength + sep + covered + sep + rateRounded);
    return (name + " " + title + " iso-length = " + isoLength + " covered = " + covered + " % : " + rateRounded);
// System.out.println(getCoverageString(coverage) + "\n");
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 87 with Annotation

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

the class PeptideMappingServiceIntegrationTest method getHighlightCoverage.

private int[] getHighlightCoverage(Isoform iso, List<Annotation> annotations) {
    String name = iso.getUniqueName();
    int isoLength = iso.getSequenceLength();
    int[] coverage = new int[isoLength];
    // first loop sets aa coverage to 1 if there is a natural peptide on it
    for (Annotation annot : annotations) {
        if (!annot.isAnnotationPositionalForIsoform(name))
            continue;
        int start = annot.getStartPositionForIsoform(name);
        int end = annot.getEndPositionForIsoform(name);
        // System.out.println("first loop: " + start + " " + end);
        for (int i = start; i <= end; i++) coverage[i - 1] = 1;
    }
    // second loop  increments aa coverage if peptide is natural and proteotypic
    for (Annotation annot : annotations) {
        if (!annot.isAnnotationPositionalForIsoform(name))
            continue;
        if (isAboutProteotypicPeptide(annot)) {
            int start = annot.getStartPositionForIsoform(name);
            int end = annot.getEndPositionForIsoform(name);
            // System.out.println("second loop: " + start + " " + end);
            for (int i = start; i <= end; i++) coverage[i - 1] = coverage[i - 1] + 1;
        }
    }
    return coverage;
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 88 with Annotation

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

the class ByAnnotationVariantComparatorTest method compareVariantsSamePositionDiffVariant.

@Test
public void compareVariantsSamePositionDiffVariant() throws Exception {
    ByAnnotationVariantComparator comparator = new ByAnnotationVariantComparator();
    Annotation variant1 = mockAnnotationVariant(AnnotationCategory.VARIANT, "A", "W", new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-1", 14, 14), new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-4", 12, 12));
    Annotation variant2 = mockAnnotationVariant(AnnotationCategory.VARIANT, "A", "L", new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-1", 14, 14), new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-4", 12, 12));
    int cmp = comparator.compare(variant1, variant2);
    Assert.assertTrue(cmp > 0);
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 89 with Annotation

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

the class ByAnnotationVariantComparatorTest method comparePositionOfLowestLocatedFeature.

@Test
public void comparePositionOfLowestLocatedFeature() throws Exception {
    ByAnnotationVariantComparator comparator = new ByAnnotationVariantComparator();
    Annotation variant1 = mockAnnotationVariant(AnnotationCategory.VARIANT, "A", "V", new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-1", 1489, 1489), new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-4", 12, 36));
    Annotation variant2 = mockAnnotationVariant(AnnotationCategory.VARIANT, "A", "V", new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-1", 17378, 18000), new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-4", 12, 36));
    int cmp = comparator.compare(variant1, variant2);
    Assert.assertEquals(0, cmp);
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 90 with Annotation

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

the class ByIsoformPositionComparatorTest method mockAnnotation.

private static Annotation mockAnnotation(long id, AnnotationCategory cat, TargetIsoform... targets) {
    Annotation mock = Mockito.mock(Annotation.class);
    when(mock.getAnnotationId()).thenReturn(id);
    when(mock.getAPICategory()).thenReturn(cat);
    Map<String, AnnotationIsoformSpecificity> map = new HashMap<>();
    for (TargetIsoform target : targets) {
        AnnotationIsoformSpecificity specificity = Mockito.mock(AnnotationIsoformSpecificity.class);
        when(specificity.getFirstPosition()).thenReturn(target.getStart());
        when(specificity.getLastPosition()).thenReturn(target.getEnd());
        when(specificity.getIsoformAccession()).thenReturn(target.getIsoformAccession());
        when(specificity.getAnnotationId()).thenReturn(id);
        when(mock.getStartPositionForIsoform(target.getIsoformAccession())).thenReturn(target.getStart());
        when(mock.getEndPositionForIsoform(target.getIsoformAccession())).thenReturn(target.getEnd());
        map.put(target.getIsoformAccession(), specificity);
    }
    when(mock.getTargetingIsoformsMap()).thenReturn(map);
    return mock;
}
Also used : AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) 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