Commit ade63912 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

brenda and cazy annotator provide structurized logs

parent 167982f7
......@@ -11,6 +11,7 @@ import lcsb.mapviewer.annotation.cache.GeneralCacheInterface;
import lcsb.mapviewer.annotation.cache.WebPageDownloader;
import lcsb.mapviewer.annotation.services.*;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.species.*;
......@@ -96,7 +97,8 @@ public class BrendaAnnotator extends ElementAnnotator implements IExternalServic
}
}
} catch (UniprotSearchException e) {
logger.warn("Cannot find EC data for UniProt id: " + mdUniprot.getResource());
logger.warn(object.getLogMarker(ProjectLogEntryType.CANNOT_FIND_INFORMATION),
"Cannot find EC data for UniProt id: " + mdUniprot.getResource());
}
}
......
......@@ -15,6 +15,8 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader;
import lcsb.mapviewer.annotation.services.*;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.species.*;
......@@ -59,7 +61,7 @@ public class CazyAnnotator extends ElementAnnotator implements IExternalService
this.setCache(null);
try {
MiriamData md = uniprotToCazy(getExampleValidAnnotation());
MiriamData md = uniprotToCazy(getExampleValidAnnotation(),null);
status.setStatus(ExternalServiceStatusType.OK);
if (md == null || !md.getResource().equalsIgnoreCase("GH5_7")) {
......@@ -86,7 +88,7 @@ public class CazyAnnotator extends ElementAnnotator implements IExternalService
}
List<String> cazyIds = new ArrayList<String>();
for (MiriamData mdUniprot : mdUniprots) {
MiriamData mdCazy = uniprotToCazy(mdUniprot);
MiriamData mdCazy = uniprotToCazy(mdUniprot, object.getLogMarker(ProjectLogEntryType.OTHER));
if (mdCazy != null && cazyIds.indexOf(mdCazy.getResource()) == -1) {
cazyIds.add(mdCazy.getResource());
object.addMiriamData(mdCazy);
......@@ -158,7 +160,7 @@ public class CazyAnnotator extends ElementAnnotator implements IExternalService
* @throws AnnotatorException
* thrown when there is a problem with accessing external database
*/
public MiriamData uniprotToCazy(MiriamData uniprot) throws AnnotatorException {
public MiriamData uniprotToCazy(MiriamData uniprot, LogMarker marker) throws AnnotatorException {
if (uniprot == null) {
return null;
}
......@@ -174,11 +176,13 @@ public class CazyAnnotator extends ElementAnnotator implements IExternalService
if (collection.size() > 0) {
return collection.iterator().next();
} else {
logger.warn("Cannot find CAZy data for UniProt id: " + uniprot.getResource());
marker.getEntry().setType(ProjectLogEntryType.INVALID_IDENTIFIER);
logger.warn(marker, "Cannot find CAZy data for UniProt id: " + uniprot.getResource());
return null;
}
} catch (WrongResponseCodeIOException exception) {
logger.warn("Wrong response code when retrieving CAZy data for UniProt id: " + uniprot.getResource());
marker.getEntry().setType(ProjectLogEntryType.OTHER);
logger.warn(marker, "Wrong response code when retrieving CAZy data for UniProt id: " + uniprot.getResource());
return null;
} catch (IOException exception) {
throw new AnnotatorException(exception);
......
......@@ -36,7 +36,7 @@ public class CazyAnnotatorTest extends AnnotationTestFunctions {
@Test
public void testUniprotToCazy() throws Exception {
assertEquals(new MiriamData(MiriamType.CAZY, "GH5_7"),
cazyAnnotator.uniprotToCazy(new MiriamData(MiriamType.UNIPROT, "Q9SG95")));
cazyAnnotator.uniprotToCazy(new MiriamData(MiriamType.UNIPROT, "Q9SG95"), null));
}
@Test
......@@ -132,12 +132,12 @@ public class CazyAnnotatorTest extends AnnotationTestFunctions {
@Test
public void testInvalidUniprotToCazyNull() throws Exception {
assertNull(cazyAnnotator.uniprotToCazy(null));
assertNull(cazyAnnotator.uniprotToCazy(null, null));
}
@Test(expected = InvalidArgumentException.class)
public void testInvalidUniprotToCazyWrongMd() throws Exception {
cazyAnnotator.uniprotToCazy(new MiriamData(MiriamType.WIKIPEDIA, "bla"));
cazyAnnotator.uniprotToCazy(new MiriamData(MiriamType.WIKIPEDIA, "bla"), null);
}
@Test
......
......@@ -437,7 +437,9 @@ public class Reaction implements BioEntity {
*/
public void removeModifier(Modifier modifier) {
nodes.remove(modifier);
} @Override
}
@Override
public String getVisibilityLevel() {
return visibilityLevel;
}
......@@ -450,7 +452,9 @@ public class Reaction implements BioEntity {
*/
public void removeNode(AbstractNode node) {
nodes.remove(node);
} @Override
}
@Override
public void setVisibilityLevel(String visibilityLevel) {
this.visibilityLevel = visibilityLevel;
}
......@@ -521,7 +525,9 @@ public class Reaction implements BioEntity {
*/
public String getIdReaction() {
return idReaction;
} /**
}
/**
* Creates copy of the reaction.
*
* @return copy of the reaction
......@@ -675,7 +681,9 @@ public class Reaction implements BioEntity {
*/
public ModelData getModelData() {
return model;
} /**
}
/**
* Sets model where the reaction is located.
*
* @param model2
......@@ -692,9 +700,14 @@ public class Reaction implements BioEntity {
*/
public void setModelData(ModelData model) {
this.model = model;
} @XmlTransient
}
@XmlTransient
@Override
public Model getModel() {
if (model == null) {
return null;
}
return model.getModel();
}
......@@ -738,7 +751,9 @@ public class Reaction implements BioEntity {
*/
public Double getUpperBound() {
return upperBound;
} @Override
}
@Override
public String getFormula() {
return formula;
}
......@@ -750,7 +765,9 @@ public class Reaction implements BioEntity {
*/
public void setUpperBound(Double upperBound) {
this.upperBound = upperBound;
} @Override
}
@Override
public void setFormula(String formula) {
this.formula = formula;
}
......@@ -838,7 +855,9 @@ public class Reaction implements BioEntity {
public void setLine(PolylineData line) {
this.line = line;
} @Override
}
@Override
public void setVisibilityLevel(Integer zoomLevelVisibility) {
if (zoomLevelVisibility == null) {
this.visibilityLevel = null;
......@@ -848,19 +867,4 @@ public class Reaction implements BioEntity {
}
}
......@@ -23,7 +23,6 @@ import lcsb.mapviewer.annotation.services.annotators.ElementAnnotator;
import lcsb.mapviewer.commands.*;
import lcsb.mapviewer.common.*;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.converter.*;
import lcsb.mapviewer.converter.graphics.DrawingException;
import lcsb.mapviewer.converter.graphics.MapGenerator;
......
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