@Test public void testAnnotator() throws Exception { final JCas jCas = JCasFactory.createJCas("de.julielab.jcore.types.jcore-semantics-biology-types"); final AnalysisEngine annotator = AnalysisEngineFactory.createEngine(MutationAnnotator.class); jCas.setDocumentText("A covalently bound catalytic intermediate in Escherichia coli asparaginase: crystal structure of a Thr-89-Val mutant."); annotator.process(jCas); final Collection<PointMutation> mutations = JCasUtil.select(jCas, PointMutation.class); Assert.assertThat(mutations.size(), CoreMatchers.is(1)); Assert.assertThat(mutations.stream().findAny().get().getCoveredText(), CoreMatchers.equalTo("Thr-89-Val")); Assert.assertThat(mutations.stream().findAny().get().getSpecificType(), CoreMatchers.equalTo("T89V")); }
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { try { final Map<Mutation, Set<int[]>> mutations = mf.extractMutations(jCas.getDocumentText()); for (Mutation mutation : mutations.keySet()) { final Set<int[]> locations = mutations.get(mutation); locations.forEach(location -> { final de.julielab.jcore.types.PointMutation pmAnnotation = new de.julielab.jcore.types.PointMutation(jCas, location[0], location[1]); pmAnnotation.setSpecificType(mutation.toString()); pmAnnotation.setComponentId(MutationAnnotator.class.getCanonicalName()); pmAnnotation.addToIndexes(); }); } } catch (MutationException e) { throw new AnalysisEngineProcessException(e); } catch (NumberFormatException e) { String docId = "<unkown>"; final Collection<Header> header = JCasUtil.select(jCas, Header.class); if (header.size() > 0) { docId = header.iterator().next().getDocId(); } log.debug("NumberFormatException occurred while extracting mutations with MutationFinder on document {}. This document is skipped.", docId, e); } }
MutationAnnotator extends JCasAnnotator_ImplBase { @Override public void process(JCas jCas) throws AnalysisEngineProcessException { try { final Map<Mutation, Set<int[]>> mutations = mf.extractMutations(jCas.getDocumentText()); for (Mutation mutation : mutations.keySet()) { final Set<int[]> locations = mutations.get(mutation); locations.forEach(location -> { final de.julielab.jcore.types.PointMutation pmAnnotation = new de.julielab.jcore.types.PointMutation(jCas, location[0], location[1]); pmAnnotation.setSpecificType(mutation.toString()); pmAnnotation.setComponentId(MutationAnnotator.class.getCanonicalName()); pmAnnotation.addToIndexes(); }); } } catch (MutationException e) { throw new AnalysisEngineProcessException(e); } catch (NumberFormatException e) { String docId = "<unkown>"; final Collection<Header> header = JCasUtil.select(jCas, Header.class); if (header.size() > 0) { docId = header.iterator().next().getDocId(); } log.debug("NumberFormatException occurred while extracting mutations with MutationFinder on document {}. This document is skipped.", docId, e); } } }
MutationAnnotator extends JCasAnnotator_ImplBase { @Override public void process(JCas jCas) throws AnalysisEngineProcessException { try { final Map<Mutation, Set<int[]>> mutations = mf.extractMutations(jCas.getDocumentText()); for (Mutation mutation : mutations.keySet()) { final Set<int[]> locations = mutations.get(mutation); locations.forEach(location -> { final de.julielab.jcore.types.PointMutation pmAnnotation = new de.julielab.jcore.types.PointMutation(jCas, location[0], location[1]); pmAnnotation.setSpecificType(mutation.toString()); pmAnnotation.setComponentId(MutationAnnotator.class.getCanonicalName()); pmAnnotation.addToIndexes(); }); } } catch (MutationException e) { throw new AnalysisEngineProcessException(e); } catch (NumberFormatException e) { String docId = "<unkown>"; final Collection<Header> header = JCasUtil.select(jCas, Header.class); if (header.size() > 0) { docId = header.iterator().next().getDocId(); } log.debug("NumberFormatException occurred while extracting mutations with MutationFinder on document {}. This document is skipped.", docId, e); } }  }
MutationAnnotator extends JCasAnnotator_ImplBase { @Override public void process(JCas jCas) throws AnalysisEngineProcessException { try { final Map<Mutation, Set<int[]>> mutations = mf.extractMutations(jCas.getDocumentText()); for (Mutation mutation : mutations.keySet()) { final Set<int[]> locations = mutations.get(mutation); locations.forEach(location -> { final de.julielab.jcore.types.PointMutation pmAnnotation = new de.julielab.jcore.types.PointMutation(jCas, location[0], location[1]); pmAnnotation.setSpecificType(mutation.toString()); pmAnnotation.setComponentId(MutationAnnotator.class.getCanonicalName()); pmAnnotation.addToIndexes(); }); } } catch (MutationException e) { throw new AnalysisEngineProcessException(e); } catch (NumberFormatException e) { String docId = "<unkown>"; final Collection<Header> header = JCasUtil.select(jCas, Header.class); if (header.size() > 0) { docId = header.iterator().next().getDocId(); } log.debug("NumberFormatException occurred while extracting mutations with MutationFinder on document {}. This document is skipped.", docId, e); } }  @Override void initialize(UimaContext aContext); @Override void process(JCas jCas); }
MutationAnnotator extends JCasAnnotator_ImplBase { @Override public void process(JCas jCas) throws AnalysisEngineProcessException { try { final Map<Mutation, Set<int[]>> mutations = mf.extractMutations(jCas.getDocumentText()); for (Mutation mutation : mutations.keySet()) { final Set<int[]> locations = mutations.get(mutation); locations.forEach(location -> { final de.julielab.jcore.types.PointMutation pmAnnotation = new de.julielab.jcore.types.PointMutation(jCas, location[0], location[1]); pmAnnotation.setSpecificType(mutation.toString()); pmAnnotation.setComponentId(MutationAnnotator.class.getCanonicalName()); pmAnnotation.addToIndexes(); }); } } catch (MutationException e) { throw new AnalysisEngineProcessException(e); } catch (NumberFormatException e) { String docId = "<unkown>"; final Collection<Header> header = JCasUtil.select(jCas, Header.class); if (header.size() > 0) { docId = header.iterator().next().getDocId(); } log.debug("NumberFormatException occurred while extracting mutations with MutationFinder on document {}. This document is skipped.", docId, e); } }  @Override void initialize(UimaContext aContext); @Override void process(JCas jCas);  }