Skip to content
Snippets Groups Projects
Commit 9671bad9 authored by Santiago Ospina De Los Ríos's avatar Santiago Ospina De Los Ríos
Browse files

Remove python package

parent 73f955a8
No related branches found
No related tags found
1 merge request!1Use pdelab dynamic power grid function space
......@@ -25,7 +25,6 @@ dune_enable_all_packages()
# Always activate tests for now
set(DUNE_COPASI_TESTS ON)
add_subdirectory(python)
add_subdirectory(src)
add_subdirectory(dune)
add_subdirectory(doc)
......
configure_file("dune/copasi/cli/cmake_variables.py.in"
"${CMAKE_CURRENT_SOURCE_DIR}/dune/copasi/cli/cmake_variables.py")
dune_python_install_package(PATH .)
\ No newline at end of file
# environmental variables when package is setup with CMake
DUNE_COPASI_EXEC = "@CMAKE_BINARY_DIR@/src/dune-copasi-exec"
\ No newline at end of file
import os
import argparse
try:
from .cmake_variables import DUNE_COPASI_EXEC
except:
pass
from .run import run
from .preprocess import preprocess_config
def get_parser():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(title="Commands", dest="command")
subparsers.required = True
parser_run = subparsers.add_parser('run',
help="Run the dune-copasi main routine.",
description="Run the dune-copasi main routine.")
parser_run.add_argument('config',
help="Configuration file.")
try:
executable = os.environ['DUNE_COPASI_EXEC']
except Exception as e:
try:
executable = DUNE_COPASI_EXEC
except Exception as e:
raise IOError("dune-copasi executable not found")
parser_run.add_argument('--exec',
default=executable,
help="dune-copasi c++ executable.")
parser_run.set_defaults(func=run)
parser_preprocess = subparsers.add_parser('preprocess',
help="Preprocess the config file.",
description="Preprocess the config file.")
parser_preprocess.add_argument('config',
help="Configuration file.")
parser_preprocess.add_argument('new_config',
help="Preprocessed configuration file.")
parser_preprocess.set_defaults(func=preprocess_config)
return parser
\ No newline at end of file
import os
import configparser
import sympy
from sympy.parsing.sympy_parser import parse_expr
def inject_jacobian(section,config):
jac_section = section+'.jacobian'
jac_ditc = {}
for vari_str in config[section]:
func_str = config[section][vari_str].replace('^','**')
func_symb = parse_expr(func_str)
for varj_str in config[section]:
jac_key = 'd({})/d({})'.format(vari_str,varj_str)
has_jac = False
if config.has_section(jac_section):
if jac_key in config[jac_section]:
jac_str = str(config[jac_section][jac_key])
has_jac = True
if not has_jac:
varj_symb = sympy.Symbol(varj_str)
jac_symb = sympy.diff(func_symb,varj_symb)
jac_str = str(jac_symb).replace('**','^')
jac_ditc[jac_key] = jac_str
config[jac_section] = jac_ditc
return config
def preprocess_compartement(compartement,config):
reaction_key = 'model.'+compartement+'.reaction'
config = inject_jacobian(reaction_key,config)
return config
def preprocess_config(args):
if not os.path.isfile(args["config"]):
raise IOError("Configuration file {} not found".format(args["config"]))
config = configparser.ConfigParser()
config.read(args['config'])
for compartement in config['model.compartements']:
preprocess_compartement(compartement, config)
with open(args['new_config'], 'w') as configfile:
config.write(configfile)
\ No newline at end of file
import os
import sys
import subprocess
def run(args):
if not os.path.isfile(args["config"]):
raise IOError("Configuration file {} not found".format(args["config"]))
try:
subprocess.check_call([args["exec"], args["config"]])
except subprocess.CalledProcessError:
print("Error while running dune-copasi")
sys.exit(1)
\ No newline at end of file
#!/usr/bin/env python3
import sys
import warnings
from dune.copasi.cli.parser import get_parser
if __name__ == "__main__": # parse command line and call command handler
try:
with warnings.catch_warnings(record=True) as warn:
try:
parser = get_parser()
args = parser.parse_args()
except SystemExit:
sys.exit(1)
args.func(vars(args))
except Exception as e:
print("dune-copasi failed with ({0}) warning(s) and ({1}) error(s)".format(len(warn),1))
raise
#!/usr/bin/env python
import sys
from setuptools import setup
def dune_copasi_scripts():
return ['./scripts/dune-copasi']
setup(name='dune.copasi',
version='0.0.0',
namespace_packages=['dune'],
description='Biochemical System Simulator COPASI in DUNE',
author='Santiago Ospina De Los Ríos <santiago.ospina@iwr.uni-heidelberg.de>',
author_email='no_mailinglist_yet@dune-copasi.de',
url='http://copasi.org',
packages=['dune.copasi',
'dune.copasi.cli',
],
install_requires=['sympy',
'configparser',
'argparse'],
scripts=dune_copasi_scripts())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment