Skip to content

Commit 7fd7b17

Browse files
Merge branch 'master' into biosimulators_integration
2 parents 88c5146 + c8169af commit 7fd7b17

File tree

10 files changed

+1634
-160
lines changed

10 files changed

+1634
-160
lines changed

vcell-client/src/main/java/org/vcell/imagej/ImageJHelper.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
import java.util.Date;
2222
import java.util.HashMap;
2323
import java.util.Hashtable;
24+
import java.util.Iterator;
2425
import java.util.List;
2526
import java.util.Map;
27+
import java.util.Map.Entry;
2628
import java.util.StringTokenizer;
2729

28-
import javax.print.attribute.standard.Finishings;
2930
import javax.servlet.ServletException;
3031
import javax.servlet.http.HttpServletRequest;
3132
import javax.servlet.http.HttpServletResponse;
@@ -46,7 +47,6 @@
4647
import org.eclipse.jetty.server.handler.AbstractHandler;
4748
import org.eclipse.jetty.server.handler.ContextHandler;
4849
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
49-
import org.eclipse.jetty.server.handler.DebugHandler;
5050
import org.jdom.Namespace;
5151
import org.vcell.imagej.ImageJHelper.ApiSolverHandler.IJGeom;
5252
import org.vcell.util.BeanUtils;
@@ -140,6 +140,7 @@
140140
import cbit.vcell.solver.SimulationOwner;
141141
import cbit.vcell.solver.SolverDescription;
142142
import cbit.vcell.solver.SolverUtilities;
143+
import cbit.vcell.solver.TempSimulation;
143144
import cbit.vcell.solver.VCSimulationDataIdentifier;
144145
import cbit.vcell.solver.VCSimulationIdentifier;
145146
import cbit.vcell.solver.ode.ODESimData;
@@ -1400,6 +1401,14 @@ private static void addSimToIJContextInfo(ArrayList<IJContextInfo>ijContextInfos
14001401
ArrayList<IJSimInfo> ijSimInfos = new ArrayList<>();
14011402
for(Simulation sim:sims) {
14021403
ijSimInfos.add(new IJSimInfo(true, false, sim.getSimulationID(), sim.getName()));
1404+
final Iterator<Entry<String, String>> iterator = TempSimulation.mapTempSimIDToModelAppSim.entrySet().iterator();
1405+
String modelAppSim = TempSimulation.createModelAppSimName(sim);
1406+
while(iterator.hasNext()) {
1407+
final Entry<String, String> next = iterator.next();
1408+
if(next.getValue().equals(modelAppSim)) {
1409+
ijSimInfos.add(new IJSimInfo(true, false, next.getKey().toString(), sim.getName()+" (quickrun_"+next.getKey().toString()+")"));
1410+
}
1411+
}
14031412
}
14041413
ijContextInfos.add(new IJContextInfo(contextName,mathType,geomDim,geomName, ijSimInfos));
14051414
}
@@ -1421,11 +1430,11 @@ private static void populateDesktopIJModelInfos(IJDocType docType,ArrayList<KeyV
14211430
for(SimulationContext simulationContext:((BioModelWindowManager)documentWindowManager).getBioModel().getSimulationContexts()) {
14221431
addSimToIJContextInfo(ijContextInfos, simulationContext.getName(), simulationContext.getMathType(),simulationContext.getGeometryContext().getGeometry().getDimension(),simulationContext.getGeometry().getName(),simulationContext.getSimulations());
14231432
}
1424-
modelInfos.add(new IJModelInfo(documentWindowManager.getVCDocument().getName(), null, IJDocType.bm, true,documentWindowManager.getUser().getName(),null, ijContextInfos));
1433+
modelInfos.add(new IJModelInfo(documentWindowManager.getVCDocument().getName(), null, IJDocType.bm, true,(documentWindowManager.getUser()==null?null:documentWindowManager.getUser().getName()),null, ijContextInfos));
14251434
}else if(documentWindowManager instanceof MathModelWindowManager) {
14261435
MathModel mathModel = ((MathModelWindowManager)documentWindowManager).getMathModel();
14271436
addSimToIJContextInfo(ijContextInfos, null,mathModel.getMathDescription().getMathType(),mathModel.getGeometry().getDimension(),mathModel.getGeometry().getName(),((MathModelWindowManager)documentWindowManager).getSimulationWorkspace().getSimulations());
1428-
modelInfos.add(new IJModelInfo(documentWindowManager.getVCDocument().getName(), null, IJDocType.mm, true,documentWindowManager.getUser().getName(),null, ijContextInfos));
1437+
modelInfos.add(new IJModelInfo(documentWindowManager.getVCDocument().getName(), null, IJDocType.mm, true,(documentWindowManager.getUser()==null?null:documentWindowManager.getUser().getName()),null, ijContextInfos));
14291438
}
14301439
}
14311440
}
@@ -1629,7 +1638,7 @@ public static ArrayList<IJModelInfo> refreshIJModelInfoCache(IJDocType ijDocType
16291638
if(bOpenOnly == null || bOpenOnly.booleanValue() == false || (bOpenOnly.booleanValue() == true && bOpenOnDesktop == true)){
16301639
ArrayList<IJContextInfo> contInfos = new ArrayList<>();
16311640
ArrayList<IJSimInfo> ijsimfos= new ArrayList<>();
1632-
ijsimfos.add(new IJSimInfo(bOpenOnDesktop, false,Simulation.createSimulationID(new KeyValue(quickrunKey)), parentSimName));
1641+
ijsimfos.add(new IJSimInfo(bOpenOnDesktop, false,quickrunKey/*Simulation.createSimulationID(new KeyValue(quickrunKey))*/, parentSimName));
16331642
// ijsimfos.add(new IJSimInfo(quickrunKey, parentSimName));
16341643
contInfos.add(new IJContextInfo(parentContextName, parentMathType, parentGeomDim, parentGeomName, ijsimfos));
16351644
modelInfos.add(new IJModelInfo(parentModelName, parentDate, docType, (docType != IJDocType.quick?true:false), parentUser,parentModelKey,contInfos));
@@ -2430,7 +2439,9 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
24302439
StringTokenizer st = new StringTokenizer(file.getName(), "_");
24312440
st.nextToken();
24322441
String quickrunKey = st.nextToken();
2433-
if(Simulation.createSimulationID(new KeyValue(quickrunKey)).equals(ijSimInfo.simId)) {
2442+
// if(TempSimulation.mapTempSimIDToOriginalSimID.get(quickrunKey) != null && TempSimulation.mapTempSimIDToOriginalSimID.get(quickrunKey).equals(ijSimInfo.simId)) {
2443+
// if(Simulation.createSimulationID(new KeyValue(quickrunKey)).equals(ijSimInfo.simId)) {
2444+
if(quickrunKey.equals(ijSimInfo.simId)) {
24342445
ijDataResponder = IJDataResponder.create(new KeyValue(quickrunKey),file.getParentFile().getParentFile(), jobIndex);
24352446
break fileloop;
24362447
}
@@ -2494,6 +2505,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
24942505
response.setContentType("text/plain; charset=utf-8");
24952506
response.setStatus(HttpServletResponse.SC_OK);
24962507
response.getWriter().write("VCellApi");
2508+
//response.getWriter().write("VCellApi:"+VCellClientTest.getVCellClient().getRequestManager().getDocumentManager().getUser().getName());
24972509
baseRequest.setHandled(true);
24982510

24992511
}

vcell-core/src/main/java/cbit/vcell/solver/TempSimulation.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
package cbit.vcell.solver;
22

3+
import java.util.TreeMap;
4+
35
import org.vcell.util.document.SimulationVersion;
46
import org.vcell.util.document.VCellSoftwareVersion;
57
import org.vcell.util.document.Version;
68

9+
import cbit.vcell.mapping.SimulationContext;
10+
711
@SuppressWarnings("serial")
812
public class TempSimulation extends Simulation {
13+
//Store association of tempSimID to originalSimID for use in ImageJHelper
14+
public static final TreeMap<String,String> mapTempSimIDToOriginalSimID = new TreeMap<String,String>();
15+
public static final TreeMap<String,String> mapTempSimIDToModelAppSim = new TreeMap<String,String>();
916
final private SimulationVersion tempSimVersion = SimulationVersion.createTempSimulationVersion();
1017
public TempSimulation(Simulation simulation, boolean bCloneMath) {
1118
super(simulation, bCloneMath);
19+
mapTempSimIDToModelAppSim.put(tempSimVersion.getVersionKey().toString(), createModelAppSimName(simulation));
20+
mapTempSimIDToOriginalSimID.put(tempSimVersion.getVersionKey().toString(), (simulation.getVersion()==null || simulation.getVersion().getVersionKey()==null?"":simulation.getVersion().getVersionKey().toString()));
1221
}
1322

23+
public static String createModelAppSimName(Simulation simulation) {
24+
String modelAppSim = simulation.getName();
25+
if(simulation.getSimulationOwner() instanceof SimulationContext) {//biomodel
26+
modelAppSim = ((SimulationContext)simulation.getSimulationOwner()).getBioModel().getName()+"_"+simulation.getSimulationOwner().getName()+"_"+modelAppSim;
27+
}else {//mathmodel
28+
modelAppSim = simulation.getSimulationOwner().getName()+"_"+modelAppSim;
29+
}
30+
return modelAppSim;
31+
}
1432
@Override
1533
public Version getVersion() {
1634
return tempSimVersion;

vcell-core/src/main/java/cbit/vcell/xml/XmlHelper.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.jlibsedml.execution.ModelResolver;
5353
import org.jlibsedml.modelsupport.KisaoOntology;
5454
import org.jlibsedml.modelsupport.KisaoTerm;
55+
import org.jlibsedml.modelsupport.SUPPORTED_LANGUAGE;
5556
import org.sbml.jsbml.SBMLException;
5657
import org.vcell.cellml.CellQuanVCTranslator;
5758
import org.vcell.sbml.SbmlException;
@@ -591,6 +592,7 @@ public static List<VCDocument> sedmlToBioModel(VCLogger transLogger, ExternalDoc
591592
org.jlibsedml.Simulation sedmlSimulation = null; // this will become the vCell simulation
592593
org.jlibsedml.Model sedmlOriginalModel = null; // the "original" model referred to by the task
593594
String sedmlOriginalModelName = null; // this will be used in the BioModel name
595+
String sedmlOriginalModelLanguage = null; // can be sbml or vcml
594596
ArchiveComponents ac = null;
595597
if(externalDocInfo.getFile().getPath().toLowerCase().endsWith("sedx") || externalDocInfo.getFile().getPath().toLowerCase().endsWith("omex")) {
596598
ac = Libsedml.readSEDMLArchive(new FileInputStream(externalDocInfo.getFile().getPath()));
@@ -626,6 +628,7 @@ public static List<VCDocument> sedmlToBioModel(VCLogger transLogger, ExternalDoc
626628
throw new RuntimeException("Unexpected task " + selectedTask);
627629
}
628630
sedmlOriginalModelName = sedmlOriginalModel.getId();
631+
sedmlOriginalModelLanguage = sedmlOriginalModel.getLanguage();
629632

630633
// at this point we assume that the sedml simulation, algorithm and kisaoID are all valid
631634
Algorithm algorithm = sedmlSimulation.getAlgorithm();
@@ -681,11 +684,24 @@ public static List<VCDocument> sedmlToBioModel(VCLogger transLogger, ExternalDoc
681684
}
682685
// make it if we didn't and mark it as fresh
683686
if (bioModel == null) {
684-
XMLSource sbmlSource = new XMLSource(newMdl); // sbmlSource with all the changes applied
685-
bioModel = (BioModel)XmlHelper.importSBML(transLogger, sbmlSource, bSpatial);
686-
bioModel.setName(bioModelName);
687-
docs.add(bioModel);
688-
justMade = true;
687+
if(sedmlOriginalModelLanguage.contentEquals(SUPPORTED_LANGUAGE.VCELL_GENERIC.getURN())) { // vcml
688+
XMLSource vcmlSource = new XMLSource(newMdl);
689+
bioModel = (BioModel)XmlHelper.XMLToBioModel(vcmlSource);
690+
bioModel.setName(bioModelName);
691+
docs.add(bioModel);
692+
justMade = true;
693+
try {
694+
bioModel.getVCMetaData().createBioPaxObjects(bioModel);
695+
} catch (Exception e) {
696+
e.printStackTrace();
697+
}
698+
} else { // we assume it's sbml, if it's neither import will fail
699+
XMLSource sbmlSource = new XMLSource(newMdl); // sbmlSource with all the changes applied
700+
bioModel = (BioModel)XmlHelper.importSBML(transLogger, sbmlSource, bSpatial);
701+
bioModel.setName(bioModelName);
702+
docs.add(bioModel);
703+
justMade = true;
704+
}
689705
}
690706
// even if we just created the biomodel from the sbml file we have at least one application with initial conditions and stuff
691707
// see if there is a suitable application type for the sedml kisao

vcell-imagej-helper/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,12 @@
147147
<artifactId>jaxb-impl</artifactId>
148148
<version>2.3.0</version>
149149
</dependency>
150+
<!-- https://mvnrepository.com/artifact/jfree/jfreechart -->
151+
<dependency>
152+
<groupId>org.jfree</groupId>
153+
<artifactId>jfreechart</artifactId>
154+
<!-- <version>1.5.0</version> -->
155+
</dependency>
156+
150157
</dependencies>
151158
</project>

vcell-imagej-helper/src/main/java/org/vcell/imagej/helper/VCellHelper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ public ArrayList<VCellModelSearchResults> getSearchedModelSimCacheKey(Boolean bO
397397
Node node = si.item(i);
398398
String currentUser = (node.getAttributes().getNamedItem("user")==null?null:node.getAttributes().getNamedItem("user").getNodeValue());
399399
boolean bUserMatch = vcCellModelSearch.getUserId() == null || vcCellModelSearch.getUserId().equals(currentUser);
400+
if(node.getAttributes().getNamedItem("name")==null) {
401+
continue;
402+
}
400403
String currentModel = node.getAttributes().getNamedItem("name").getNodeValue();
401404
Long longDate = (node.getAttributes().getNamedItem("date")==null?null:Long.parseLong(node.getAttributes().getNamedItem("date").getNodeValue()));
402405
if(longDate != null && vcellModelVersionTimeRange != null && (longDate < vcellModelVersionTimeRange.getEarliest().getTime() || longDate > vcellModelVersionTimeRange.getLatest().getTime())) {

0 commit comments

Comments
 (0)