Search in sources :

Example 51 with Annotation

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

the class AnnotationConverter method marshal.

public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
    Annotation annotation = (Annotation) value;
    writer.startNode("unique-name");
    writer.setValue(annotation.getUniqueName());
    writer.endNode();
    if (annotation.getCvTermAccessionCode() != null) {
        writer.startNode("cvterm-accession-code");
        writer.setValue(annotation.getCvTermAccessionCode());
        writer.endNode();
    }
    writer.startNode("category");
    writer.setValue(annotation.getCategory());
    writer.endNode();
    writer.startNode("target-isoform-list");
    context.convertAnother(annotation.getTargetingIsoformsMap());
    writer.endNode();
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 52 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation 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 53 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation 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 54 with Annotation

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

the class PepXServiceTest method getMockedAnnotation.

private Annotation getMockedAnnotation(String original, String variant, int position, String isoName, boolean isAnnotationPositionalForIso) {
    Annotation a1 = mock(Annotation.class, Mockito.RETURNS_DEEP_STUBS);
    when(a1.getVariant().getOriginal()).thenReturn(original);
    when(a1.getVariant().getVariant()).thenReturn(variant);
    when(a1.getStartPositionForIsoform(isoName)).thenReturn(position);
    when(a1.getEndPositionForIsoform(isoName)).thenReturn(position);
    when(a1.isAnnotationPositionalForIsoform(isoName)).thenReturn(isAnnotationPositionalForIso);
    return a1;
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 55 with Annotation

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

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