Skip to content

Commit 752e950

Browse files
committed
Added the clear and test for spawn.
1 parent 323b5e4 commit 752e950

File tree

9 files changed

+64
-27
lines changed

9 files changed

+64
-27
lines changed

javascript/common/tremppi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ tremppi = {
362362
break;
363363
case 'widget':
364364
tremppi.activateMenuItems('open');
365-
if (!tremppi.isFinal() && (details[1] === tremppi.widget_name)) {
365+
if (!tremppi.isFinal() && (details[1] === tremppi.widget_name) && tremppi.reports.indexOf(tremppi.widget_name) === -1 && ("tools" !== tremppi.widget_name)) {
366366
tremppi.activateMenuItems('save');
367367
}
368368
break;

javascript/editor.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"nodes": [{"position": {"y": 25.06391307738162, "x": 32.80176543684172}, "selectable": true, "grabbable": true, "data": {"Name": "A", "Label": "A:1", "MaxActivity": 1, "id": "n0"}, "removed": false, "locked": false, "classes": "", "group": "nodes", "grabbed": false, "selected": false}, {"position": {"y": -29.146074776874396, "x": -34.64748760526245}, "selectable": true, "grabbable": true, "data": {"Name": "B", "Label": "B:2", "MaxActivity": 2, "id": "n1"}, "removed": false, "locked": false, "classes": "", "group": "nodes", "grabbed": false, "selected": false}], "edges": [{"position": {}, "selectable": true, "grabbable": true, "data": {"target": "n1", "line_style": "solid", "line_color": "green", "target_arrow_shape": "triangle", "Label": "Activating Only", "id": "e0", "source": "n0", "Threshold": 1}, "removed": false, "locked": false, "classes": "", "group": "edges", "grabbed": false, "selected": false}, {"position": {}, "selectable": true, "grabbable": true, "data": {"target": "n1", "line_style": "solid", "line_color": "black", "target_arrow_shape": "triangle", "Label": "Activating", "id": "e1", "source": "n1", "Threshold": 2}, "removed": false, "locked": false, "classes": "", "group": "edges", "grabbed": false, "selected": false}]}

javascript/tools/controls.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ tremppi.tools.addToQueue = function (command) {
4444
if (!confirm('Do you really want to call ' + command + '? This operation is irreversible.')) {
4545
return;
4646
}
47+
$('#spawn').prop("disabled", false);
48+
$('#clean').prop("disabled", true);
49+
}
50+
if (command === 'spawn'){
51+
$('#spawn').prop("disabled", true);
52+
$('#clean').prop("disabled", false);
4753
}
4854
$.ajax({
4955
type: "POST",

javascript/tools/page.js

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,41 @@
11
/******************************************************************************
2-
Created by Adam Streck, 2013-2015, [email protected]
3-
4-
This file is part of the Toolkit for Reverse Engineering of Molecular Pathways
5-
via Parameter Identification (TREMPPI)
6-
7-
This program is free software: you can redistribute it and/or modify it under
8-
the terms of the GNU General Public License as published by the Free Software
9-
Foundation, either version 3 of the License, or (at your option) any later
10-
version.
11-
12-
This program is distributed in the hope that it will be useful, but WITHOUT ANY
13-
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14-
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15-
16-
You should have received a copy of the GNU General Public License along with
17-
this program. If not, see <http://www.gnu.org/licenses/>.
18-
******************************************************************************/
2+
Created by Adam Streck, 2013-2015, [email protected]
3+
4+
This file is part of the Toolkit for Reverse Engineering of Molecular Pathways
5+
via Parameter Identification (TREMPPI)
6+
7+
This program is free software: you can redistribute it and/or modify it under
8+
the terms of the GNU General Public License as published by the Free Software
9+
Foundation, either version 3 of the License, or (at your option) any later
10+
version.
11+
12+
This program is distributed in the hope that it will be useful, but WITHOUT ANY
13+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14+
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License along with
17+
this program. If not, see <http://www.gnu.org/licenses/>.
18+
******************************************************************************/
1919
/* global tremppi */
2020

2121
tremppi.tools.tool_list = [
2222
{
2323
category: "MODEL",
2424
tools: [
25-
{name: "spawn", description: "read a model and create a database of parametrizations based on the model"}
25+
{
26+
name: "spawn",
27+
description: "read a model and create a database of parametrizations based on the model",
28+
condition: function () {
29+
return typeof tremppi.tools.setup === 'undefined' || tremppi.tools.setup.setup === 'undefined' || tremppi.tools.setup.created === 0;
30+
}
31+
},
32+
{
33+
name: "clean",
34+
description: "clean all the data and create a new database from the model",
35+
condition: function () {
36+
return !(typeof tremppi.tools.setup === 'undefined' || tremppi.tools.setup.setup === 'undefined' || tremppi.tools.setup.created === 0);
37+
}
38+
}
2639
]
2740
},
2841
{
@@ -57,8 +70,7 @@ tremppi.tools.tool_list = [
5770
category: "UTILITY",
5871
tools: [
5972
{name: "configure", description: "call to explicitly recreate data configuration files"},
60-
{name: "update", description: "update the javascript and html files in the project directory"},
61-
{name: "clean", description: "call to remove all the data files"}
73+
{name: "update", description: "update the javascript and html files in the project directory"}
6274
]
6375
}
6476
];
@@ -82,15 +94,18 @@ tremppi.tools.page = function () {
8294
$('#' + tool_name).qtip({
8395
content: tool_set[tool_no].description
8496
});
97+
98+
if (typeof tool_set[tool_no].condition !== 'undefined') {
99+
$('#' + tool_name).prop("disabled", !tool_set[tool_no].condition());
100+
}
85101
}
86102
}
87103
var reports_div = $('<div id="reports"></div>').appendTo('#widget');
88104
var progress_list = $('<div id="progress"></div>').appendTo(reports_div);
89105
var kill_all = $('<button class="btn" id="kill_button" >KILL ALL PROCESSES</button>').appendTo(reports_div);
90106
kill_all.click(tremppi.tools.killAll);
91107
var log_file = $('<textarea id="log_file" placeholder="Contents of the log.txt file."></textarea>').appendTo(reports_div);
92-
}
93-
else {
108+
} else {
94109
log_file = $('<textarea id="log_file" placeholder="Contents of the log.txt file." style="height: 100%;" ></textarea>').appendTo('#widget');
95110
}
96111
};
@@ -112,6 +127,6 @@ tremppi.tools.toolbarClass = function () {
112127
return {};
113128
};
114129

115-
tremppi.tools.beforeUnload = function() {
116-
130+
tremppi.tools.beforeUnload = function () {
131+
117132
};

native/tremppi_spawn/tremppi_spawn.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ int tremppi_spawn(int argc, char ** argv)
133133
try
134134
{
135135
PythonFunctions::configure("select");
136+
PythonFunctions::configure("tools");
136137
PythonFunctions::configure("properties");
137138
}
138139
catch (exception & e)

python/clean.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
import shutil
2020
import sys
2121
import os.path
22-
from tremppi.header import data_folder, configure_filename, system_init, system
22+
from tremppi.header import data_folder, configure_filename, system_init, system, model_file
2323
from tremppi.project_files import generate_data
24+
from tremppi.configure import configure
2425

2526
if __name__ == "__main__":
2627
parser = argparse.ArgumentParser(description='Clean data from a TREMPPI project')
@@ -30,5 +31,8 @@
3031
if not os.path.exists(os.path.join(system.DEST_PATH, configure_filename)):
3132
raise Exception('The target folder ' + system.DEST_PATH + ' does not seem to be a TREMPPI project folder. The ' + configure_filename + ' is missing.')
3233
else:
34+
os.rename(os.path.join(system.DEST_PATH, data_folder, model_file), os.path.join(system.DEST_PATH, model_file))
3335
shutil.rmtree(os.path.join(system.DEST_PATH, data_folder))
34-
generate_data(os.path.join(system.DEST_PATH, data_folder))
36+
generate_data(os.path.join(system.DEST_PATH, data_folder))
37+
os.rename(os.path.join(system.DEST_PATH, model_file), os.path.join(system.DEST_PATH, data_folder, model_file))
38+
configure(system.DEST_PATH, 'tools')

python/tremppi/configure.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,16 @@ def configure(data_path, widget):
432432
json.dump(json_data, file_js)
433433
file_js.write(';')
434434

435+
elif widget == "tools":
436+
with open(os.path.join(data_path, widget + '.js'), 'w+') as file_js:
437+
file_js.write('tremppi.' + widget + '.setup = ')
438+
json_data = {"created": int(os.path.exists(os.path.join(data_path, database_file))) }
439+
json.dump(json_data, file_js)
440+
file_js.write(';')
441+
435442
elif widget in widgets:
436443
js_filename = os.path.join(data_path, widget + '.js')
437444
open(js_filename, 'w+').close()
445+
438446
else:
439447
raise Exception("Unknown widget " + widget)

python/tremppi/header.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
data_folder = 'data'
3636
widgets = ['index', 'properties', 'editor', 'select', 'witness', 'regulations', 'correlations', 'quantitative', 'qualitative', 'group', 'tools']
3737
folders = ['common', 'libs', 'index', 'properties', 'editor', 'select', 'witness', 'regulations', 'correlations', 'quantitative', 'qualitative', 'group', 'tools']
38+
model_file = 'editor.json'
3839

3940

4041
class System:

python/tremppi/server_app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
class TremppiRegisterForm(RegisterForm):
3737
recaptcha = RecaptchaField()
3838

39+
3940
# Setup Flask app and app.config
4041
def create_app():
4142
print("App at: " + system.DEST_PATH)

0 commit comments

Comments
 (0)