Skip to content
Snippets Groups Projects
Commit 2d519068 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '201-exception-when-running-annotations' into 'master'

Resolve "exception when running annotations"

Closes #201

See merge request !108
parents fa6c1b1f 5fb2961f
No related branches found
No related tags found
1 merge request!108Resolve "exception when running annotations"
......@@ -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);
}
}
}
......
......@@ -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.
......
......@@ -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());
......
......@@ -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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment