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();
}
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));
}
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());
}
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;
}
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);
}
Aggregations