From f369c6599a09abb89fcc3d36bfca47b808b91fc7 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Fri, 29 Jun 2012 18:35:01 +0000 Subject: [PATCH] Re-factor SBML-to-PRISM translator. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@5405 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/prism/Reactions2Prism.java | 14 +++++++++++--- prism/src/prism/SBML2Prism.java | 18 +++++++++--------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/prism/src/prism/Reactions2Prism.java b/prism/src/prism/Reactions2Prism.java index e74a4339..c4d8247c 100644 --- a/prism/src/prism/Reactions2Prism.java +++ b/prism/src/prism/Reactions2Prism.java @@ -56,12 +56,15 @@ public class Reactions2Prism protected ArrayList parameterList; protected ArrayList reactionList; + // Config + + /** Maximum amount of each species (unless some initial amound is higher). */ + protected int maxAmount = 100; + // Optional PRISM code header/footer protected String prismCodeHeader; protected String prismCodeFooter; - - protected int maxAmount; - + // Constructors public Reactions2Prism() @@ -74,6 +77,11 @@ public class Reactions2Prism this.mainLog = mainLog; } + public void setMaxAmount(int maxAmount) + { + this.maxAmount = maxAmount; + } + /** * Print the currently loaded reaction set model (for testing purposes). */ diff --git a/prism/src/prism/SBML2Prism.java b/prism/src/prism/SBML2Prism.java index c5f263b8..33a1ac6c 100644 --- a/prism/src/prism/SBML2Prism.java +++ b/prism/src/prism/SBML2Prism.java @@ -62,7 +62,13 @@ public class SBML2Prism extends Reactions2Prism implements EntityResolver System.exit(1); } SBML2Prism sbml2prism = new SBML2Prism(errLog); - sbml2prism.translate(new File(args[0]), (args.length > 1) ? args[1] : "100"); + try { + if (args.length > 1) + sbml2prism.setMaxAmount(Integer.parseInt(args[1])); + } catch (NumberFormatException e) { + throw new PrismException("Invalid max amount \"" + args[1] + "\""); + } + sbml2prism.translate(new File(args[0])); } catch (PrismException e) { errLog.println("Error: " + e.getMessage() + "."); } @@ -81,16 +87,10 @@ public class SBML2Prism extends Reactions2Prism implements EntityResolver } /** - * Main method: load SBML file, process and sent resulting PRISM file to stdout + * Main method: load SBML file, process and send resulting PRISM file to stdout */ - public void translate(File f, String maxAmount) throws PrismException + public void translate(File f) throws PrismException { - // translate - try { - this.maxAmount = Integer.parseInt(maxAmount); - } catch (NumberFormatException e) { - throw new PrismException("Invalid max amount \"" + maxAmount + "\""); - } // Read in SBML Document doc = parseSBML(f); checkSBMLVersion(doc);