Search in sources :

Example 1 with PepXIsoformMatch

use of org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch in project nextprot-api by calipho-sib.

the class PepXServiceTest method shouldBuildAnEntryWithVirtualAnnotations.

@Test
public void shouldBuildAnEntryWithVirtualAnnotations() throws Exception {
    String peptide = "GANAP";
    boolean modeIsoleucine = true;
    PepXIsoformMatch pepXIsoformMatch = new PepXIsoformMatch();
    pepXIsoformMatch.setIsoformAccession(ISO_ACCESSION);
    @SuppressWarnings("unchecked") List<Annotation> annotations = mock(List.class);
    Isoform isoform = mock(Isoform.class);
    when(isoform.getIsoformAccession()).thenReturn(ISO_ACCESSION);
    when(isoform.getSequence()).thenReturn("AGANAPA");
    List<Isoform> isoforms = Arrays.asList(isoform);
    List<Annotation> virtualAnnotations = PepXServiceImpl.buildEntryWithVirtualAnnotations(peptide, modeIsoleucine, Arrays.asList(pepXIsoformMatch), annotations, isoforms);
    Annotation annot = virtualAnnotations.get(0);
    assertTrue(annot.getCategory().equals("pepx-virtual-annotation"));
    assertTrue(annot.getVariant() == null);
    assertTrue(annot.getTargetingIsoformsMap().keySet().contains(ISO_ACCESSION));
}
Also used : PepXIsoformMatch(org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch) Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Example 2 with PepXIsoformMatch

use of org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch in project nextprot-api by calipho-sib.

the class PepXServiceTest method shouldReturnAnEmptyArrayWhenThePeptideIsNotContainedInTheSequence.

@Test
public void shouldReturnAnEmptyArrayWhenThePeptideIsNotContainedInTheSequence() throws Exception {
    String peptide = "GANAP";
    boolean modeIsoleucine = true;
    PepXIsoformMatch pepXIsoformMatch = new PepXIsoformMatch(ISO_ACCESSION);
    @SuppressWarnings("unchecked") List<Annotation> annotations = mock(List.class);
    Isoform isoform = mock(Isoform.class);
    when(isoform.getIsoformAccession()).thenReturn(ISO_ACCESSION);
    // Sequence does not
    when(isoform.getSequence()).thenReturn("AAAAAA");
    // contain the
    // peptide
    List<Isoform> isoforms = Arrays.asList(isoform);
    List<Annotation> result = PepXServiceImpl.buildEntryWithVirtualAnnotations(peptide, modeIsoleucine, Arrays.asList(pepXIsoformMatch), annotations, isoforms);
    assertTrue(result.isEmpty());
}
Also used : PepXIsoformMatch(org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch) Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Example 3 with PepXIsoformMatch

use of org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch in project nextprot-api by calipho-sib.

the class PepXServiceTest method shouldGiveAnAnnotationWithVariantWhenPresent.

/*
	 * Specification have changed now it should be empty look at:
	 * #shouldReturnAnEmptyArrayWhenThePeptideIsNotContainedInTheSequence
	 * 
	 * @Test(expected=NextProtException.class) public void
	 * shouldThrowAnExceptionWhenThePeptideIsNotContainedInTheSequence() throws
	 * Exception {
	 * 
	 * try { String peptide = "GANAP"; boolean modeIsoleucine = true;
	 * 
	 * List<Pair<String, Integer>> isosAndPositions = Arrays.asList(new
	 * Pair<String, Integer>("Iso-1", null)); //not positional since there is no
	 * position
	 * 
	 * @SuppressWarnings("unchecked") List<Annotation> annotations =
	 * mock(List.class); Isoform isoform = mock(Isoform.class);
	 * when(isoform.getIsoformAccession()).thenReturn("Iso-1");
	 * when(isoform.getSequence()).thenReturn("AAAAAA");//Sequence does not
	 * contain the peptide
	 * 
	 * List<Isoform> isoforms = Arrays.asList(isoform);
	 * 
	 * PepXServiceImpl.buildEntryWithVirtualAnnotations(peptide, modeIsoleucine,
	 * isosAndPositions, annotations, isoforms);
	 * 
	 * }catch(NextProtException e){ if(e.getMessage().contains(
	 * "that is not in the current isoform in neXtProt")){ throw e; //success
	 * tests }else fail(); } }
	 */
@Test
public void shouldGiveAnAnnotationWithVariantWhenPresent() throws Exception {
    // Taking example NX_Q9H6T3
    String peptide = "GANAP";
    boolean modeIsoleucine = true;
    String isoName = "NX_Q9H6T3-3";
    Isoform isoform = mock(Isoform.class);
    when(isoform.getIsoformAccession()).thenReturn(isoName);
    // https://cdn.rawgit.com/calipho-sib/sequence-viewer/master/examples/simple.html
    // (check that page to format the sequence)
    // GANAL is present instead of GANAP
    when(isoform.getSequence()).thenReturn("MDADPYNPVLPTNRASAYFRLKKFAVAESDCNLAVALNRSYTKAYSRRGAARFALQKLEEAKKDYERVLELEPNNFEATNELRKISQALASKENSYPKEADIVIKSTEGERKQIEAQQNKQQAISEKDRGNGFFKEGKYERAIECYTRGIAADGANALLPANRAMAYLKIQKYEEAEKDCTQAILLDGSYSKAFARRGTARTFLGKLNEAKQDFETVLLLEPGNKQAVTELSKIKKELIEKGHWDDVFLDSTQRQNVVKPIDNPPHPGSTKPLKKVIIEETGNLIQTIDVPDSTTAAAPENNPINLANVIAATGTTSKKNSSQDDLFPTSDTPRAKVLKIEEVSDTSSLQPQASLKQDVCQSYSEKMPIEIEQKPAQFATTVLPPIPANSFQLESDFRQLKSSPDMLYQYLKQIEPSLYPKLFQKNLDPDVFNQIVKILHDFYIEKEKPLLIFEILQRLSELKRFDMAVMFMSETEKKIARALFNHIDKSGLKDSSVEELKKRYGG");
    PepXIsoformMatch pepXIsoformMatch = new PepXIsoformMatch(isoName, 154);
    List<Annotation> annots = Arrays.asList(getMockedAnnotation("L", "P", 158, isoName, true));
    List<Isoform> isoforms = Arrays.asList(isoform);
    // empty
    List<Annotation> pepxAnnots = PepXServiceImpl.buildEntryWithVirtualAnnotations(peptide, modeIsoleucine, Arrays.asList(pepXIsoformMatch), annots, isoforms);
    // or
    // null
    // annotations
    assertTrue(pepxAnnots.size() == 1);
    assertTrue(pepxAnnots.get(0).getVariant().getOriginal().equals("L"));
    assertTrue(pepxAnnots.get(0).getVariant().getVariant().equals("P"));
    assertTrue(pepxAnnots.get(0).getStartPositionForIsoform(isoName) == 158);
    assertTrue(pepxAnnots.get(0).getEndPositionForIsoform(isoName) == 158);
}
Also used : PepXIsoformMatch(org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch) Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Example 4 with PepXIsoformMatch

use of org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch in project nextprot-api by calipho-sib.

the class PepXServiceTest method shouldReturnAnEmptryListIfTheVariantIsNotConaintedInThePeptide.

@Test
public void shouldReturnAnEmptryListIfTheVariantIsNotConaintedInThePeptide() throws Exception {
    // Taking example NX_Q9H6T3
    String peptide = "GANAP";
    boolean modeIsoleucine = true;
    String isoName = "NX_Q9H6T3-3";
    Isoform isoform = mock(Isoform.class);
    when(isoform.getIsoformAccession()).thenReturn(isoName);
    // https://cdn.rawgit.com/calipho-sib/sequence-viewer/master/examples/simple.html
    // (check that page to format the sequence)
    // GANAL is present instead of GANAP
    when(isoform.getSequence()).thenReturn("MDADPYNPVLPTNRASAYFRLKKFAVAESDCNLAVALNRSYTKAYSRRGAARFALQKLEEAKKDYERVLELEPNNFEATNELRKISQALASKENSYPKEADIVIKSTEGERKQIEAQQNKQQAISEKDRGNGFFKEGKYERAIECYTRGIAADGANALLPANRAMAYLKIQKYEEAEKDCTQAILLDGSYSKAFARRGTARTFLGKLNEAKQDFETVLLLEPGNKQAVTELSKIKKELIEKGHWDDVFLDSTQRQNVVKPIDNPPHPGSTKPLKKVIIEETGNLIQTIDVPDSTTAAAPENNPINLANVIAATGTTSKKNSSQDDLFPTSDTPRAKVLKIEEVSDTSSLQPQASLKQDVCQSYSEKMPIEIEQKPAQFATTVLPPIPANSFQLESDFRQLKSSPDMLYQYLKQIEPSLYPKLFQKNLDPDVFNQIVKILHDFYIEKEKPLLIFEILQRLSELKRFDMAVMFMSETEKKIARALFNHIDKSGLKDSSVEELKKRYGG");
    PepXIsoformMatch pepXIsoformMatch = new PepXIsoformMatch(isoName, 154);
    List<Annotation> annots = Arrays.asList(getMockedAnnotation("L", "Z", 158, isoName, true));
    List<Isoform> isoforms = Arrays.asList(isoform);
    // empty
    List<Annotation> result = PepXServiceImpl.buildEntryWithVirtualAnnotations(peptide, modeIsoleucine, Arrays.asList(pepXIsoformMatch), annots, isoforms);
    // or
    // null
    // annotations
    assertTrue(result.isEmpty());
}
Also used : PepXIsoformMatch(org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch) Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Example 5 with PepXIsoformMatch

use of org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch in project nextprot-api by calipho-sib.

the class PepXServiceTest method shouldGiveAnExceptionIfTheOriginalIsNotPresentOnTheSequence.

/*
	 * Specification has changed look at:
	 * shouldReturnAnEmptryListIfTheVariantIsNotConaintedInThePeptide
	 * 
	 * @Test(expected=NextProtException.class) public void
	 * shouldGiveAnExceptionIfTheVariantIsNotConaintedInThePeptide() throws
	 * Exception { try {
	 * 
	 * //Taking example NX_Q9H6T3 String peptide = "GANAP"; boolean
	 * modeIsoleucine = true; String isoName = "NX_Q9H6T3-3";
	 * 
	 * Isoform isoform = mock(Isoform.class);
	 * when(isoform.getIsoformAccession()).thenReturn(isoName);
	 * //https://cdn.rawgit.com/calipho-sib/sequence-viewer/master/examples/
	 * simple.html (check that page to format the sequence) //GANAL is present
	 * instead of GANAP when(isoform.getSequence()).thenReturn(
	 * "MDADPYNPVLPTNRASAYFRLKKFAVAESDCNLAVALNRSYTKAYSRRGAARFALQKLEEAKKDYERVLELEPNNFEATNELRKISQALASKENSYPKEADIVIKSTEGERKQIEAQQNKQQAISEKDRGNGFFKEGKYERAIECYTRGIAADGANALLPANRAMAYLKIQKYEEAEKDCTQAILLDGSYSKAFARRGTARTFLGKLNEAKQDFETVLLLEPGNKQAVTELSKIKKELIEKGHWDDVFLDSTQRQNVVKPIDNPPHPGSTKPLKKVIIEETGNLIQTIDVPDSTTAAAPENNPINLANVIAATGTTSKKNSSQDDLFPTSDTPRAKVLKIEEVSDTSSLQPQASLKQDVCQSYSEKMPIEIEQKPAQFATTVLPPIPANSFQLESDFRQLKSSPDMLYQYLKQIEPSLYPKLFQKNLDPDVFNQIVKILHDFYIEKEKPLLIFEILQRLSELKRFDMAVMFMSETEKKIARALFNHIDKSGLKDSSVEELKKRYGG"
	 * );
	 * 
	 * List<Pair<String, Integer>> isosAndPositions = Arrays.asList(new
	 * Pair<String, Integer>(isoName, 154)); //Position of the begin of peptide
	 * List<Annotation> annots = Arrays.asList(getMockedAnnotation("L", "Z",
	 * 158, isoName, true)); List<Isoform> isoforms = Arrays.asList(isoform);
	 * 
	 * PepXServiceImpl.buildEntryWithVirtualAnnotations(peptide, modeIsoleucine,
	 * isosAndPositions, annots, isoforms); //empty or null annotations
	 * }catch(NextProtException e){ if(e.getMessage().contains(
	 * "No valid variants found for isoform ")){ throw e; //success tests }else
	 * fail(); }
	 * 
	 * }
	 */
// because we have variants in nextprot which do not have original aa is not equal to isoform aa at that variant position (inconsistency)
@Ignore
@Test(expected = NextProtException.class)
public void shouldGiveAnExceptionIfTheOriginalIsNotPresentOnTheSequence() throws Exception {
    try {
        // Taking example NX_Q9H6T3
        String peptide = "GANAP";
        boolean modeIsoleucine = true;
        String isoName = "NX_Q9H6T3-3";
        Isoform isoform = mock(Isoform.class);
        when(isoform.getIsoformAccession()).thenReturn(isoName);
        // https://cdn.rawgit.com/calipho-sib/sequence-viewer/master/examples/simple.html
        // (check that page to format the sequence)
        // GANAL is present instead of GANAP
        when(isoform.getSequence()).thenReturn("MDADPYNPVLPTNRASAYFRLKKFAVAESDCNLAVALNRSYTKAYSRRGAARFALQKLEEAKKDYERVLELEPNNFEATNELRKISQALASKENSYPKEADIVIKSTEGERKQIEAQQNKQQAISEKDRGNGFFKEGKYERAIECYTRGIAADGANALLPANRAMAYLKIQKYEEAEKDCTQAILLDGSYSKAFARRGTARTFLGKLNEAKQDFETVLLLEPGNKQAVTELSKIKKELIEKGHWDDVFLDSTQRQNVVKPIDNPPHPGSTKPLKKVIIEETGNLIQTIDVPDSTTAAAPENNPINLANVIAATGTTSKKNSSQDDLFPTSDTPRAKVLKIEEVSDTSSLQPQASLKQDVCQSYSEKMPIEIEQKPAQFATTVLPPIPANSFQLESDFRQLKSSPDMLYQYLKQIEPSLYPKLFQKNLDPDVFNQIVKILHDFYIEKEKPLLIFEILQRLSELKRFDMAVMFMSETEKKIARALFNHIDKSGLKDSSVEELKKRYGG");
        PepXIsoformMatch pepXIsoformMatch = new PepXIsoformMatch(isoName, 154);
        // Original is not contained in the sequence, should be a L L->P
        // (GANAL)
        List<Annotation> annots = Arrays.asList(getMockedAnnotation("O", "P", 158, isoName, true));
        List<Isoform> isoforms = Arrays.asList(isoform);
        // empty
        PepXServiceImpl.buildEntryWithVirtualAnnotations(peptide, modeIsoleucine, Arrays.asList(pepXIsoformMatch), annots, isoforms);
    // or
    // null
    // annotations
    } catch (NextProtException e) {
        if (e.getMessage().contains("The amino acid")) {
            // success tests
            throw e;
        } else
            fail();
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) PepXIsoformMatch(org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch) Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Ignore(org.junit.Ignore) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Aggregations

Isoform (org.nextprot.api.core.domain.Isoform)7 Annotation (org.nextprot.api.core.domain.annotation.Annotation)7 PepXIsoformMatch (org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch)7 Test (org.junit.Test)6 WebUnitBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest)6 NextProtException (org.nextprot.api.commons.exception.NextProtException)3 Ignore (org.junit.Ignore)1 AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)1 AnnotationVariant (org.nextprot.api.core.domain.annotation.AnnotationVariant)1