@@ -215,41 +215,26 @@ public static String exportSBML(VCDocument vcDoc, int level, int version, int pk
215
215
}
216
216
if (vcDoc instanceof BioModel ) {
217
217
try {
218
- // check if model to be exported to SBML has units compatible with SBML default units (default units in SBML can be assumed only until SBML Level2)
219
- ModelUnitSystem forcedModelUnitSystem = simContext .getModel ().getUnitSystem ();
220
- if (level < 3 && !ModelUnitSystem .isCompatibleWithDefaultSBMLLevel2Units (forcedModelUnitSystem )) {
221
- forcedModelUnitSystem = ModelUnitSystem .createDefaultSBMLLevel2Units ();
222
- } else if (forcedModelUnitSystem .getVolumeSubstanceUnit ().getSymbol () != "molecules" ){
223
- // need to replace volumeSubstanceUnit; molecules is the only one that allows the exporter to create valid unit conversions of parameters
224
- String volumeSubstanceSymbol = "molecules" ;
225
- String membraneSubstanceSymbol = forcedModelUnitSystem .getMembraneSubstanceUnit ().getSymbol ();
226
- String lumpedReactionSubstanceSymbol = forcedModelUnitSystem .getLumpedReactionSubstanceUnit ().getSymbol ();
227
- String lengthSymbol = forcedModelUnitSystem .getLengthUnit ().getSymbol ();
228
- String areaSymbol = forcedModelUnitSystem .getAreaUnit ().getSymbol ();
229
- String volumeSymbol = forcedModelUnitSystem .getVolumeUnit ().getSymbol ();
230
- String timeSymbol = forcedModelUnitSystem .getTimeUnit ().getSymbol ();
231
- forcedModelUnitSystem = ModelUnitSystem .createVCModelUnitSystem (volumeSubstanceSymbol , membraneSubstanceSymbol , lumpedReactionSubstanceSymbol , volumeSymbol , areaSymbol , lengthSymbol , timeSymbol );
232
- }
233
- // create new Biomodel with new (SBML compatible) unit system
234
- BioModel modifiedBiomodel = ModelUnitConverter .createBioModelWithNewUnitSystem (simContext .getBioModel (), forcedModelUnitSystem );
218
+ // clone BioModel
219
+ BioModel clonedBioModel = cloneBioModel (simContext .getBioModel ());
235
220
// extract the simContext from new Biomodel. Apply overrides to *this* modified simContext
236
- SimulationContext simContextFromModifiedBioModel = modifiedBiomodel .getSimulationContext (simContext .getName ());
237
- SimulationContext clonedSimContext = applyOverridesForSBML (modifiedBiomodel , simContextFromModifiedBioModel , simJob );
221
+ SimulationContext simContextFromClonedBioModel = clonedBioModel .getSimulationContext (simContext .getName ());
222
+ SimulationContext clonedSimContext = applyOverridesForSBML (clonedBioModel , simContextFromClonedBioModel , simJob );
238
223
// extract sim (in simJob) from modified Biomodel, if not null
239
224
SimulationJob modifiedSimJob = null ;
240
225
if (simJob != null ) {
241
- Simulation simFromModifiedBiomodel = clonedSimContext .getSimulation (simJob .getSimulation ().getName ());
242
- modifiedSimJob = new SimulationJob (simFromModifiedBiomodel , simJob .getJobIndex (), null );
226
+ Simulation simFromClonedBiomodel = clonedSimContext .getSimulation (simJob .getSimulation ().getName ());
227
+ modifiedSimJob = new SimulationJob (simFromClonedBiomodel , simJob .getJobIndex (), null );
243
228
}
244
- SBMLExporter sbmlExporter = new SBMLExporter (modifiedBiomodel , level , version , isSpatial );
245
- sbmlExporter .setSelectedSimContext (simContextFromModifiedBioModel );
229
+ SBMLExporter sbmlExporter = new SBMLExporter (clonedBioModel , level , version , isSpatial );
230
+ sbmlExporter .setSelectedSimContext (clonedSimContext );
246
231
sbmlExporter .setSelectedSimulationJob (modifiedSimJob );
247
- String ret = sbmlExporter .getSBMLFile ();
232
+ String sbmlSTring = sbmlExporter .getSBMLString ();
248
233
249
234
// cleanup the string of all the "sameAs" statements
250
- ret = SBMLAnnotationUtil .postProcessCleanup (ret );
251
- return ret ;
252
- } catch (ExpressionException | SbmlException | SBMLException | XMLStreamException e ) {
235
+ sbmlSTring = SBMLAnnotationUtil .postProcessCleanup (sbmlSTring );
236
+ return sbmlSTring ;
237
+ } catch (SbmlException | SBMLException | XMLStreamException e ) {
253
238
e .printStackTrace (System .out );
254
239
throw new XmlParseException (e );
255
240
}
@@ -808,15 +793,14 @@ public static BioModel XMLToBioModel(XMLSource xmlSource) throws XmlParseExcepti
808
793
return XMLToBioModel (xmlSource , true , null );
809
794
}
810
795
811
- /** @deprecated */
812
- public static BioModel cloneBioModelWithNewUnitSystem (BioModel origBiomodel , ModelUnitSystem forcedModelUnitSystem ) throws XmlParseException {
796
+ public static BioModel cloneBioModel (BioModel origBiomodel ) throws XmlParseException {
813
797
String biomodelXMLString = bioModelToXML (origBiomodel );
814
798
XMLSource newXMLSource = new XMLSource (biomodelXMLString );
815
- return XMLToBioModel (newXMLSource , true , forcedModelUnitSystem );
799
+ return XMLToBioModel (newXMLSource );
816
800
}
817
801
818
802
819
- static BioModel XMLToBioModel (XMLSource xmlSource , boolean printkeys , ModelUnitSystem forcedModelUnitSystem ) throws XmlParseException {
803
+ public static BioModel XMLToBioModel (XMLSource xmlSource , boolean printkeys , ModelUnitSystem forcedModelUnitSystem ) throws XmlParseException {
820
804
821
805
//long l0 = System.currentTimeMillis();
822
806
BioModel bioModel = null ;
0 commit comments