From 88e6f64a73932b6907f626dbd42bc2beeff3fcca Mon Sep 17 00:00:00 2001 From: ChocolateCharlie Date: Wed, 29 Jun 2022 22:02:24 +0200 Subject: [PATCH] Clean hardcoded file names --- jupyter_notebooks/createModel.ipynb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/jupyter_notebooks/createModel.ipynb b/jupyter_notebooks/createModel.ipynb index 6ef050f7..e98e6c1b 100644 --- a/jupyter_notebooks/createModel.ipynb +++ b/jupyter_notebooks/createModel.ipynb @@ -100,7 +100,8 @@ "outputs": [], "source": [ "# Antimony model name and information text\n", - "fileModel = open('SPARCED.txt','w') # file name\n", + "fileModelName = 'SPARCED.txt'\n", + "fileModel = open(fileModelName,'w') # file name\n", "fileModel.write(\"# PanCancer Model by Birtwistle Lab \\n\") # some explanation\n", "fileModel.write(\"model SPARCED()\\n\") # model name" ] @@ -199,7 +200,7 @@ "outputs": [], "source": [ "# Write species and assign compartments\n", - "species_sheet = np.array([np.array(line.strip().split(\"\\t\")) for line in open('Species.txt', encoding='latin-1')])" + "species_sheet = np.array([np.array(line.strip().split(\"\\t\")) for line in open(fileSpecies, encoding='latin-1')])" ] }, { @@ -253,10 +254,10 @@ "fileModel.write(\"\\n\\n # Reactions:\\n\") # Antimony Reactions module title\n", "\n", "#reads in file from excel and gets rid of first row and column (they're data labels)\n", - "stoic_sheet = np.array([np.array(line.strip().split(\"\\t\")) for line in open('StoicMat.txt')])\n", + "stoic_sheet = np.array([np.array(line.strip().split(\"\\t\")) for line in open(fileStoic)])\n", "\n", "#creates associated ratelaw data list\n", - "ratelaw_sheet = np.array([np.array(line.strip().split(\"\\t\")) for line in open('Ratelaws.txt')])\n", + "ratelaw_sheet = np.array([np.array(line.strip().split(\"\\t\")) for line in open(fileRatelaws)])\n", "ratelaw_data = np.array([line[1:] for line in ratelaw_sheet[1:]])\n", "\n", "#gets first column minus blank space at the beginning, adds to stoic data list\n", @@ -501,13 +502,13 @@ "outputs": [], "source": [ "# load model and convert to SBML\n", - "if loadFile(\"SPARCED.txt\") == 1:\n", + "if loadFile(fileModelName) == 1:\n", " print(\"Success loading antimony file\")\n", "else:\n", " print(\"Failed to load antimony file\")\n", " exit(1)\n", "\n", - "if writeSBMLFile(\"SPARCED.xml\",\"SPARCED\") == 1:\n", + "if writeSBMLFile(sbml_file,\"SPARCED\") == 1:\n", " print(\"Success converting antimony to SBML\")\n", "else:\n", " print(\"Failure converting antimony to SBML\")\n",