diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java index dde647a3bf294e8e2aaeeb1e3744ae451ee458c8..6703789f93909815b9ead7e506c659265d2b3e7e 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java @@ -19,9 +19,9 @@ import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Species; /** - * Interface that allows to annotate {@link BioEntity elements} in the - * system. Different implementation use different resources to perform - * annotation. They can annotate different types of elements. + * Interface that allows to annotate {@link BioEntity elements} in the system. + * Different implementation use different resources to perform annotation. They + * can annotate different types of elements. * * @author Piotr Gawron * @@ -31,7 +31,7 @@ public abstract class ElementAnnotator extends CachableInterface { /** * Default class logger. */ - private final Logger logger = Logger.getLogger(ElementAnnotator.class); + private final Logger logger = Logger.getLogger(ElementAnnotator.class); /** * List of classes that can be annotated by this {@link IElementAnnotator @@ -42,7 +42,7 @@ public abstract class ElementAnnotator extends CachableInterface { /** * Should be this annotator used as a default annotatior. */ - private boolean isDefault = false; + private boolean isDefault = false; /** * Default constructor. @@ -61,8 +61,7 @@ public abstract class ElementAnnotator extends CachableInterface { if (BioEntity.class.isAssignableFrom(validClass)) { addValidClass((Class<? extends BioEntity>) validClass); } else { - throw new InvalidArgumentException( - "Cannot pass class of type: " + validClass + ". Only classes extending " + BioEntity.class + " are accepted."); + throw new InvalidArgumentException("Cannot pass class of type: " + validClass + ". Only classes extending " + BioEntity.class + " are accepted."); } } this.isDefault = isDefault; @@ -193,7 +192,7 @@ public abstract class ElementAnnotator extends CachableInterface { List<String> sortedSynonyms = new ArrayList<>(); sortedSynonyms.addAll(synonyms); Collections.sort(sortedSynonyms); - + element.setSynonyms(sortedSynonyms); } else { logger.warn(prefix + "Synonyms don't match: \"" + synonyms + "\", \"" + element.getSynonyms() + "\""); @@ -227,10 +226,12 @@ public abstract class ElementAnnotator extends CachableInterface { * value to set */ protected void setDescription(BioEntity element, String description) { - if (element.getNotes() == null || element.getNotes().equals("") || element.getNotes().equals(description)) { - element.setNotes(description); - } else if (!element.getNotes().toLowerCase().contains(description.toLowerCase())) { - element.setNotes(element.getNotes() + "\n" + description); + if (description != null) { + if (element.getNotes() == null || element.getNotes().equals("") || element.getNotes().equals(description)) { + element.setNotes(description); + } else if (!element.getNotes().toLowerCase().contains(description.toLowerCase())) { + element.setNotes(element.getNotes() + "\n" + description); + } } } diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java index 4ac8160718ce1fe15a0f85b6cabbaed1ee1351f7..27cd669cc89e4ef80fd72248a15226dfb7a12941 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java @@ -41,7 +41,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi /** * Version of the rest API that is supported by this annotator. */ - static final String SUPPORTED_VERSION = "6.0"; + static final String SUPPORTED_VERSION = "6.1"; /** * Url address of ensembl restfull service. diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java index b68e455da37eb7e0b00243a6afc9858cfb3ea534..98ad19ad4dc01856566b7fefaa0ad30befe659ba 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java @@ -92,7 +92,7 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions { } @Test - public void test3FindDrug() throws Exception { + public void testFindRapamycin() throws Exception { try { // finding synonym Drug rapamycinDrug = drugBankHTMLParser.findDrug("Rapamycin"); @@ -100,8 +100,7 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions { assertEquals("Sirolimus", rapamycinDrug.getName()); assertEquals("DB00877", rapamycinDrug.getSources().get(0).getResource()); assertTrue(rapamycinDrug.getBloodBrainBarrier().equalsIgnoreCase("NO")); - boolean res = rapamycinDrug.getDescription().contains( - "A macrolide compound obtained from Streptomyces hygroscopicus that acts by selectively blocking the transcriptional activation of cytokines thereby inhibiting cytokine production. It is bioactive only when bound to immunophilins. Sirolimus is a potent immunosuppressant and possesses both antifungal and antineoplastic properties. [PubChem]"); + boolean res = rapamycinDrug.getDescription().contains("A macrolide compound obtained from Streptomyces"); assertTrue(res); assertEquals(3, rapamycinDrug.getTargets().size()); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java index a02974da7d865847f035cc1e0541374f4a667b8d..1dac8112d686798431180401071b4f4eb5eefaf0 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java @@ -85,6 +85,14 @@ public class ElementAnnotatorTest extends AnnotationTestFunctions { assertEquals(0, getWarnings().size()); } + @Test + public void testSetEmptyDescription() { + GenericProtein species = new GenericProtein("id"); + species.setNotes("X"); + annotator.setDescription(species, null); + assertEquals("X", species.getNotes()); + } + @Test public void testSetNotMatchingIchi() { Ion species = new Ion("id");