Search in sources :

Example 11 with Isoform

use of org.nextprot.api.core.domain.Isoform 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 12 with Isoform

use of org.nextprot.api.core.domain.Isoform 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 13 with Isoform

use of org.nextprot.api.core.domain.Isoform 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 14 with Isoform

use of org.nextprot.api.core.domain.Isoform 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)

Example 15 with Isoform

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

the class IsoformDAOImpl method findIsoformsByEntryName.

@Override
public List<Isoform> findIsoformsByEntryName(String entryName) {
    String sql = sqlDictionary.getSQLQuery("isoforms-by-entry-name");
    SqlParameterSource namedParameters = new MapSqlParameterSource("unique_name", entryName);
    List<Isoform> isoforms = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sql, namedParameters, new IsoformRowMapper());
    if (isoforms.isEmpty()) {
        // If nothing is found, remove the condition for the synonym type
        isoforms = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sql.replace("and syn.cv_type_id = 1 ", ""), namedParameters, new IsoformRowMapper());
    }
    return isoforms;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) SlimIsoform(org.nextprot.api.core.domain.SlimIsoform) Isoform(org.nextprot.api.core.domain.Isoform)

Aggregations

Isoform (org.nextprot.api.core.domain.Isoform)44 Test (org.junit.Test)19 Annotation (org.nextprot.api.core.domain.annotation.Annotation)17 PepXIsoformMatch (org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch)8 Entry (org.nextprot.api.core.domain.Entry)7 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)7 ArrayList (java.util.ArrayList)6 NextProtException (org.nextprot.api.commons.exception.NextProtException)6 WebUnitBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest)6 AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)4 Ignore (org.junit.Ignore)3 EntityName (org.nextprot.api.core.domain.EntityName)3 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 SequenceVariation (org.nextprot.api.commons.bio.variation.prot.SequenceVariation)2 Interaction (org.nextprot.api.core.domain.Interaction)2 AnnotationVariant (org.nextprot.api.core.domain.annotation.AnnotationVariant)2 IsoformService (org.nextprot.api.core.service.IsoformService)2 BinaryInteraction2Annotation (org.nextprot.api.core.utils.BinaryInteraction2Annotation)2 SingleFeatureQuery (org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery)2