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

model annotation are model scope (not project)

parent 4a3cf9b2
......@@ -25,15 +25,12 @@ import lcsb.mapviewer.annotation.services.annotators.GoAnnotator;
import lcsb.mapviewer.annotation.services.annotators.HgncAnnotator;
import lcsb.mapviewer.annotation.services.annotators.ReconAnnotator;
import lcsb.mapviewer.annotation.services.annotators.UniprotAnnotator;
import lcsb.mapviewer.common.EventStorageLoggerAppender;
import lcsb.mapviewer.common.IProgressUpdater;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.AnnotatedObject;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.Species;
......@@ -167,13 +164,13 @@ public class ModelAnnotator {
/**
* Performs all possible and automatic annotations on the model.
*
* @param project
* project to update
* @param model
* model to update
* @param progressUpdater
* callback function used for updating progress of the function
*/
public void performAnnotations(Project project, final IProgressUpdater progressUpdater) {
performAnnotations(project, progressUpdater, null);
public void performAnnotations(Model model, final IProgressUpdater progressUpdater) {
performAnnotations(model, progressUpdater, null);
}
/**
......@@ -182,48 +179,37 @@ public class ModelAnnotator {
* @param annotators
* this map contains lists of {@link ElementAnnotator} objects that
* should be used for a given classes
* @param project
* project with models to update
* @param model
* model to update
* @param progressUpdater
* callback function used for updating progress of the function
*/
public void performAnnotations(Project project, final IProgressUpdater progressUpdater, Map<Class<?>, List<ElementAnnotator>> annotators) {
EventStorageLoggerAppender appender = new EventStorageLoggerAppender();
try {
Logger.getRootLogger().addAppender(appender);
progressUpdater.setProgress(0);
List<Model> models = new ArrayList<>();
for (ModelData model: project.getModels()) {
models.add(model.getModel());
models.addAll(model.getModel().getSubmodels());
}
final double size = models.size();
double counter = 0;
for (Model m : models) {
final double ratio = counter / size;
public void performAnnotations(Model model, final IProgressUpdater progressUpdater, Map<Class<?>, List<ElementAnnotator>> annotators) {
progressUpdater.setProgress(0);
List<Model> models = new ArrayList<Model>();
models.add(model);
models.addAll(model.getSubmodels());
final double size = models.size();
double counter = 0;
for (Model m : models) {
final double ratio = counter / size;
copyAnnotationFromOtherSpecies(m, new IProgressUpdater() {
@Override
public void setProgress(final double progress) {
progressUpdater.setProgress(ratio * IProgressUpdater.MAX_PROGRESS + (progress * COPYING_RATIO) / size);
}
});
annotateModel(m, new IProgressUpdater() {
copyAnnotationFromOtherSpecies(m, new IProgressUpdater() {
@Override
public void setProgress(final double progress) {
progressUpdater.setProgress(ratio * IProgressUpdater.MAX_PROGRESS + (progress * COPYING_RATIO) / size);
}
});
annotateModel(m, new IProgressUpdater() {
@Override
public void setProgress(double progress) {
progressUpdater
.setProgress(ratio * IProgressUpdater.MAX_PROGRESS + (COPYING_RATIO * IProgressUpdater.MAX_PROGRESS + progress * ANNOTATING_RATIO) / size);
}
}, annotators);
counter++;
}
Logger.getRootLogger().removeAppender(appender);
project.addLoggingInfo(appender);
} finally {
Logger.getRootLogger().removeAppender(appender);
@Override
public void setProgress(double progress) {
progressUpdater
.setProgress(ratio * IProgressUpdater.MAX_PROGRESS + (COPYING_RATIO * IProgressUpdater.MAX_PROGRESS + progress * ANNOTATING_RATIO) / size);
}
}, annotators);
counter++;
}
}
/**
......
......@@ -29,7 +29,6 @@ import lcsb.mapviewer.annotation.services.annotators.AnnotatorException;
import lcsb.mapviewer.annotation.services.annotators.ElementAnnotator;
import lcsb.mapviewer.annotation.services.annotators.ReconAnnotator;
import lcsb.mapviewer.common.IProgressUpdater;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.AnnotatedObject;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamRelationType;
......@@ -312,9 +311,7 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions {
final MutableDouble maxProgress = new MutableDouble(0.0);
Project project = new Project();
project.addModel(model);
modelAnnotator.performAnnotations(project, new IProgressUpdater() {
modelAnnotator.performAnnotations(model, new IProgressUpdater() {
@Override
public void setProgress(double progress) {
maxProgress.setValue(Math.max(progress, maxProgress.getValue()));
......
......@@ -7,7 +7,6 @@ import lcsb.mapviewer.annotation.services.ModelAnnotator;
import lcsb.mapviewer.common.IProgressUpdater;
import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.persist.ApplicationContextLoader;
......@@ -82,10 +81,8 @@ public class BellExport {
// version = "1.1.38";
dbUtils.createSessionForCurrentThread();
Model model = p.createModel(new ConverterParams().filename(filename));
Project project = new Project();
project.addModel(model);
modelAnnotator.performAnnotations(project, new IProgressUpdater() {
modelAnnotator.performAnnotations(model, new IProgressUpdater() {
@Override
public void setProgress(double progress) {
}
......
......@@ -20,7 +20,6 @@ import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.IProgressUpdater;
import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.compartment.Compartment;
......@@ -113,11 +112,9 @@ public class Statistics {
try {
// String modelName = PdMapAnnotations.getLastPdFilename();
CellDesignerXmlParser parser = new CellDesignerXmlParser();
Project project = new Project();
for (String name : fileNames) {
Model model = parser.createModel(new ConverterParams().filename(name));
models.add(model);
project.addModel(model);
}
IProgressUpdater updater = new IProgressUpdater() {
......@@ -126,7 +123,9 @@ public class Statistics {
logger.debug("Progress: " + progress);
}
};
modelAnnotator.performAnnotations(project, updater);
for (Model model : models) {
modelAnnotator.performAnnotations(model, updater);
}
// modelAnnotator.removeIncorrectAnnotations(model, updater);
printStatistics(models);
......
......@@ -735,7 +735,7 @@ public class ProjectService implements IProjectService {
}
}
logger.debug("Updating annotations");
modelAnnotator.performAnnotations(project, new IProgressUpdater() {
modelAnnotator.performAnnotations(model, new IProgressUpdater() {
@Override
public void setProgress(final double progress) {
......
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