Commit a4fe92c1 authored by David Hoksza's avatar David Hoksza
Browse files

Added associated annotator class to miriam data including hibernate mapping +...

Added associated annotator class to miriam data including hibernate mapping + createMiriamData in element annotator. without unit tests
parent d6608847
......@@ -12,6 +12,7 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerChemical;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamRelationType;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Chemical;
......@@ -473,5 +474,34 @@ public abstract class ElementAnnotator extends CachableInterface {
logger.warn(prefix + "MCS in db different: \"" + element.getMechanicalConfidenceScore() + "\", \"" + value + "\"");
}
}
private void setAnnotator(MiriamData md){
md.setAnnotator(this.getClass());
}
protected MiriamData createMiriamData(){
MiriamData md = new MiriamData();
setAnnotator(md);
return md;
}
protected MiriamData createMiriamData(MiriamData _md){
MiriamData md = new MiriamData(_md);
setAnnotator(md);
return md;
}
protected MiriamData createMiriamData(MiriamType mt, String resource){
MiriamData md = new MiriamData(mt, resource);
setAnnotator(md);
return md;
}
protected MiriamData createMiriamData(MiriamRelationType relationType, MiriamType mt, String resource){
MiriamData md = new MiriamData(relationType, mt, resource);
setAnnotator(md);
return md;
}
}
......@@ -58,7 +58,7 @@ public class TairAnnotator extends ElementAnnotator implements IExternalService
this.setCache(null);
try {
MiriamData md = tairToUniprot(new MiriamData(MiriamType.TAIR_LOCUS, "AT1G01030"));
MiriamData md = tairToUniprot(createMiriamData(MiriamType.TAIR_LOCUS, "AT1G01030"));
status.setStatus(ExternalServiceStatusType.OK);
if (md == null || !md.getResource().equalsIgnoreCase("Q9MAN1")) {
......@@ -122,7 +122,7 @@ public class TairAnnotator extends ElementAnnotator implements IExternalService
Collection<MiriamData> result = new HashSet<MiriamData>();
Matcher m = tairToUniprot.matcher(pageContent);
if (m.find()) {
result.add(new MiriamData(MiriamType.UNIPROT, m.group(1)));
result.add(createMiriamData(MiriamType.UNIPROT, m.group(1)));
}
return result;
}
......
......@@ -2,6 +2,7 @@ package lcsb.mapviewer.annotation.services.annotators;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import org.junit.After;
import org.junit.AfterClass;
......@@ -12,6 +13,9 @@ import lcsb.mapviewer.annotation.AnnotationTestFunctions;
import lcsb.mapviewer.annotation.cache.CachableInterface;
import lcsb.mapviewer.annotation.cache.SourceNotAvailable;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamRelationType;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Ion;
......@@ -193,5 +197,34 @@ public class ElementAnnotatorTest extends AnnotationTestFunctions {
assertEquals(1, getWarnings().size());
}
@Test
public void createMiriamData1() {
MiriamData md = annotator.createMiriamData();
assertEquals(md.getAnnotator(), annotator.getClass());
}
@Test
public void createMiriamData2() {
MiriamData md = annotator.createMiriamData(MiriamType.UNIPROT, "XXX");
assertEquals(md.getAnnotator(), annotator.getClass());
}
@Test
public void createMiriamData3() {
MiriamData md = annotator.createMiriamData(MiriamRelationType.BQ_BIOL_ENCODES, MiriamType.UNIPROT, "XXX");
assertEquals(md.getAnnotator(), annotator.getClass());
}
@Test
public void createMiriamData4() {
MiriamData md1 = new MiriamData(MiriamType.UNIPROT, "XXX");
assertNull(md1.getAnnotator());
MiriamData md2 = annotator.createMiriamData(md1);
assertEquals(md2.getAnnotator(), annotator.getClass());
}
}
......@@ -64,6 +64,13 @@ public class MiriamData implements Comparable<MiriamData>, Serializable {
*/
@Column(name = "resource")
private String resource = "";
/**
* The annotator which created the miriam data or which
* should be associated with it.
*/
@Column(name = "annotator")
private Class<?> annotator = null;
/**
* Default constructor.
......@@ -82,8 +89,9 @@ public class MiriamData implements Comparable<MiriamData>, Serializable {
setRelationType(md.relationType);
setDataType(md.dataType);
setResource(md.resource);
setAnnotator(md.annotator);
}
/**
* Constructor that initialize the data by information from params.
*
......@@ -93,8 +101,11 @@ public class MiriamData implements Comparable<MiriamData>, Serializable {
* type of the miriam data (see: {@link MiriamType})
* @param resource
* {@link #resource}
* @param annotator
* {@link #annotator}
*
*/
public MiriamData(MiriamRelationType relationType, MiriamType mt, String resource) {
public MiriamData(MiriamRelationType relationType, MiriamType mt, String resource, Class<?> annotator) {
if (mt == null) {
throw new InvalidArgumentException("MiriamType cannot be null");
}
......@@ -104,8 +115,36 @@ public class MiriamData implements Comparable<MiriamData>, Serializable {
setRelationType(relationType);
setDataType(mt);
setResource(resource);
setAnnotator(annotator);
}
/**
* Constructor that initialize the data by information from params.
*
* @param relationType
* {@link #relationType}
* @param mt
* type of the miriam data (see: {@link MiriamType})
* @param resource
* {@link #resource}
*/
public MiriamData(MiriamRelationType relationType, MiriamType mt, String resource) {
this(relationType, mt, resource, null);
}
/**
* Constructor that initialize the data by information from params.
*
* @param mt
* type of the miriam data (see: {@link MiriamType})
* @param resource
* {@link #resource}
*/
public MiriamData(MiriamType mt, String resource, Class<?> annotator) {
this(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, mt, resource, annotator);
}
/**
* Constructor that initialize the data by information from params.
*
......@@ -115,7 +154,7 @@ public class MiriamData implements Comparable<MiriamData>, Serializable {
* {@link #resource}
*/
public MiriamData(MiriamType mt, String resource) {
this(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, mt, resource);
this(mt, resource, null);
}
/**
......@@ -250,4 +289,20 @@ public class MiriamData implements Comparable<MiriamData>, Serializable {
}
}
/**
*
* @return {@link #annotator}
*/
public Class<?> getAnnotator() {
return annotator;
}
/**
*
* @param {@link #annotator}
*/
public void setAnnotator(Class<?> annotator) {
this.annotator = annotator;
}
}
-- column to store which annotator is responsible for given miriam data
alter table miriam_data_table add column annotator varchar(256) default null;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment