-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathadam.pl
More file actions
executable file
·790 lines (665 loc) · 24.5 KB
/
adam.pl
File metadata and controls
executable file
·790 lines (665 loc) · 24.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
#!/usr/bin/perl -w
## Hussein Vastani
## Franziska Hinkelmann
## Bonbons
## Seda Arat (SDDS, oPDS, and oSDDS)
## June 2013
use v5.10;
use CGI qw/:standard/; # load CGI routines
use Fcntl qw( :flock );
print header; # create the HTTP header
$ENV{'PATH'}='/Applications/Macaulay2-1.6/bin:' . $ENV{'PATH'};
$p_value = param('p_value');
$k_value = param('k_bound');
$upload_file = param('upload_file');
$option_box = "";
$choice_box = param('choice_box'); # build, analyze
$format_box = param('inputType');
$continuous = param('continuous');
$anaysis_method = param('anaysis_method');
$limCyc_length = "1"; #param('limCyc_length');
$update_box = "0"; #param('update_box');
$update_schedule = "0"; #param('update_schedule');
$trajectory_box = "0"; #param('trajectory_box');
$trajectory_value = "0"; #param('trajectory_value');
$statespace = param('statespace');
$depgraph = param('depgraph');
$feedback = param('feedback');
$edit_functions = param('edit_functions');
$SSformat = param('SSformat');
$DGformat = param('DGformat');
$stochastic
= param('probabilities'); # if set, probabilities are drawn in state space
$updstoch_flag = "0";
$updsequ_flag = "0";
$weights = param('weights');
$dreamss = param('dreamss');
# Declaration and initialization of SDDS parameters
if ($format_box eq 'SDDS') {
$propensityMatrix = param('propensityMatrix');
$initialState = "\"" . param('initialState') . "\"";
$interestingNodes = "\"" . param('interestingNodes') . "\"";
$num_states = param('num_states');
$num_steps = param('num_steps');
$num_simulations = param('num_simulations');
$steadyStates = param('SteadyStates');
$transitionMatrix = param('TransitionMatrix');
$flag4ss = 0;
$flag4tm = 0;
}
# Declaration and initialization of oPDS parameters
elsif ($format_box eq 'oPDS') {
$external_parameters = param('externalParameters');
}
#Declaration and initialization of oSDDS parameters
elsif ($format_box eq 'oSDDS') {
$propensityMatrix = param('propensityMatrix-osdds');
$external_parameters = param('externalParameters-osdds');
$initialState = "\"" . param('initialState-osdds') . "\"";
$interestingNodes = "\"" . param('interestingNodes-osdds') . "\"";
$num_states = param('num_states-osdds');
$num_steps = param('num_steps-osdds');
$num_simulations = param('num_simulations-osdds');
$steadyStates = param('SteadyStates');
$transitionMatrix = param('TransitionMatrix');
$flag4ss = 0;
$flag4tm = 0;
}
else {}
$DEBUG = 0;
if ($choice_box eq "") {
say '<a href="http://adam.vbi.vt.edu"/>ADAM has moved.</a> Please update your bookmarks';
exit 1;
}
# this function reads input functions from file or text area and writes the input functions into $clientip.functionfile.txt
sub create_input_function {
# the program will do nothing for SDDS or oSDDS, and continue the algorithm
if (($format_box eq 'SDDS') || ($format_box eq 'oSDDS')) {
return;
}
use Cwd;
$cwd = getcwd();
`mkdir -p tmp/files`;
$filename = "$clientip.functionfile.txt";
say "--" . $upload_file . "--" if ($DEBUG);
if ($format_box eq 'oPDS') {
$funcfilename = "$clientip.funcfile.txt";
if ($upload_file) {
say "cp tmp/files/$upload_file $funcfilename <br> " if ($DEBUG);
$result = `cp "tmp/files/$upload_file" "$funcfilename"`;
}
elsif ($edit_functions) {
open (TA, ">$funcfilename") or die ("<br>ERROR: Cannot open the file for functions! <br>");
print "open ok \n<br>" if ($DEBUG);
print TA $edit_functions;
close (TA) or die ("<br>ERROR: Cannot close the file for functions! <br>");
}
else {
print "<br>ERROR: There must be input functions. Please upload a file for functions or enter the functions directly into the text area. <br>";
exit;
}
$epfilename = "$clientip.epfile.txt";
if ($external_parameters) {
open (EP, ">$epfilename") or die ("<br>ERROR: Cannot open the file for external parameters! <br>");
print "open ok \n<br>" if ($DEBUG);
print EP $external_parameters;
close (EP) or die ("<br>ERROR: Cannot close the file for external parameters! <br>");
}
else {
print "<br>ERROR: There must be some external parameters for the system. Please enter the external parameters directly into the text area. <br>";
exit;
}
%externalParameters = ();
open (EPFILE, "<$epfilename") or die ("Cannot open epfile! \n");
while (my $temp = <EPFILE>) {
chomp ($temp);
($ep, $value) = split (/=/, $temp);
$ep =~ s/\s//g;
$value =~ s/\s//g;
$externalParameters{$ep} = $value;
}
close (EPFILE);
open (FUNCFILE, "<$funcfilename") or die (" Cannot open funcfile! \n");
open (OUTFILE, ">$filename") or die (" Cannot open outputfile! \n");
while (my $func = <FUNCFILE>) {
chomp ($func);
# skip empty lines
if ($func =~ /^\s*$/) {
next;
}
foreach my $key (keys (%externalParameters)) {
my $value = $externalParameters{$key};
$func =~ s/$key/$value/g;
}
print OUTFILE "$func \n";
$n_nodes++;
}
close (FUNCFILE);
close (OUTFILE);
}
else {
print "Clientip $clientip \n<br>" if ($DEBUG);
if ($upload_file) {
say "cp tmp/files/$upload_file $filename <br> " if ($DEBUG);
$result = `cp "$cwd/tmp/files/$upload_file" "$filename"`;
if ($choice_box eq 'analyze'
&& ( $format_box eq 'PDS'
|| $format_box eq 'pPDS'
|| $format_box eq 'BN'
|| $format_box eq 'PBN' )
)
{
open (FILE, "< $filename") or die ("Cannot open $filename");
while ( $bytesread = read( FILE, $buffer, 1024 ) ) {
say "reading ..." if ($DEBUG);
while ( $buffer =~ m/f(\d+)/g ) {
if ( $1 > $n_nodes ) {
say "$1<br>" if ($DEBUG);
$n_nodes = $1;
}
}
}
close(FILE);
}
}
elsif ($edit_functions)
{ # Otherwise parse functions from textarea value (no file uploaded)
open( OUTFILE, ">$filename" );
print "open ok \n<br>" if ($DEBUG);
print OUTFILE $edit_functions;
$n_nodes = 0;
while ( $edit_functions =~ m/f(\d+)/g ) {
if ( $1 > $n_nodes ) { $n_nodes = $1; }
}
flock( OUTFILE, LOCK_UN )
or die("Could not unlock file $!");
close(OUTFILE);
}
else {
print
"<font color=red>No input functions! Please upload a file or enter the functions.</font>";
die("Program quitting. No input functions");
}
$buffer = "";
}
`perl -pi -e 's/\r//g' "$clientip.functionfile.txt"`;
}
# Take the Functions in functionfile.txt, translate them, and save the result back into functionfile.txt
sub translate_functions {
print "translate_functions<br>" if ($DEBUG);
$result = `
"/usr/bin/perl translator.pl $clientip.functionfile.txt $clientip.trfunctionfile.txt $n_nodes"
`;
$filename = "$clientip.trfunctionfile.txt";
if ( -e "$clientip.trfunctionfile.txt" ) {
print
"<A href=\"$clientip.trfunctionfile.txt\" target=\"_blank\"><font color=green><i>Translation from Boolean functions to Polynomial was successful.</i></font></A><br><br>";
}
else {
print
"<font color=red>Translation from Boolean functions to polynomial was unsuccessful</font><br>";
`rm -f $clientip.functionfile.txt`;
die("Translation unsuccessful");
}
}
sub set_update_type() {
return 0; # not implemented yet
$update_box_param = "";
if ( $update_box eq 'Update_stochastic' ) {
#print "Update Stochastic<br>";
$update_box_param = "updstoch";
$updstoch_flag = "1";
$update_schedule = "0";
}
if ( $update_box eq 'Sequential' ) {
#print "$update_box<br>";
$update_box_param = "async";
$updsequ_flag = "1";
if ( ( defined $update_schedule )
&& ( $update_schedule ne "" ) )
{
$update_schedule =~ s/^\s+|\s+$//g
; #remove all leading and trailing white spaces
$update_schedule =~ s/(\d+)\s+/$1 /g
; # remove extra spaces in between the numbers
$update_schedule =~ s/ /_/g;
#print "$update_schedule";
}
else {
print
"<br><font color=red>Please enter an update schedule or select <i>Synchronous</i>.</font><br>";
die("Program quitting. Empty value for update schedule field");
}
}
else {
$update_box_param = "parallel";
$update_schedule = "0";
}
}
# Does error checking and sets the flags in SDDS and oSDDS
sub SDDSerrorchecking_and_set_flags {
# error checking
if ($initialState eq "\"\"") {
print "<br> ERROR: The initial state must be specified for the system. Please check the initial state. <br>";
exit;
}
if ($interestingNodes eq "\"\"") {
print "<br> ERROR: The nodes of interest must be specified for the system. Please check the nodes of interest. <br>";
exit;
}
if ($num_states eq "") {
print "<br> ERROR: The number of states must be specified for the system. Please check the number of states. <br>";
exit;
}
if ($num_steps eq "") {
print "<br> ERROR: The number of steps must be specified for the system. Please check the number of states. <br>";
exit;
}
if ($num_simulations eq "") {
print "<br> ERROR: The number of simulations must be specified for the system. Please check the number of states. <br>";
exit;
}
# set flags
if ($steadyStates eq "Print Steady States") {
$flag4ss = 1;
}
if ($transitionMatrix eq "Print Transition Matrix") {
$flag4tm = 1;
}
}
`mkdir -p tmp`;
`touch tmp/access`;
#get the clients ip address
$clientip = $ENV{'REMOTE_ADDR'};
$clientip =~ s/\./\-/g;
( $sec, $min, $hr ) = localtime();
$clientip = $clientip . '-' . $sec . '-' . $min . '-' . $hr;
$clientip = 'tmp/files/' . $clientip;
#$clientip = $sec.'-'.$min.'-'.$hr;
#open(ACCESS, ">>tmp/access") or die("Failed to open file for writing");
#flock(ACCESS, LOCK_EX) or die ("Could not get exclusive lock $!");
#print ACCESS ($ENV{REMOTE_ADDR});
#system("date >>tmp/access");
#flock(ACCESS, LOCK_UN) or die ("Could not unlock file $!");
#close(ACCESS);
my $bytesread = "";
my $buffer = "";
#$fileuploaded = 0;
$SSformat =~ s/\*\.//;
$DGformat =~ s/\*\.//;
#make input functions - gives p_value and n_nodes
create_input_function();
if ($DEBUG) {
print "access was ok <br>";
print "option_box = $option_box <br>";
print "format_box = $format_box <br>";
print "translate_box = $translate_box <br>";
print "choice_box = $choice_box <br>";
print "anaysis_method = $anaysis_method <br>";
print "p_value = $p_value <br>";
print "n_nodes = $n_nodes <br>";
print "edit_functions = $edit_functions <br>";
print "propensityMatrix = $propensityMatrix <br>";
print "external_parameters = $external_parameters <br>";
}
given ($choice_box) {
when (/build/) {
#$DEBUG =1;
print "We are working with transition tables $format_box <br>"
if ($DEBUG);
print "p $p_value <br>" if ($DEBUG);
if ( $continuous eq 'continuous' ) {
print "We are working with continuous models: $continuous <br>"
if ($DEBUG);
$result = `ruby transitionTablesContinuous.rb $p_value "$filename"`;
}
else {
print "We are not working with continuous models $continuous <br>"
if ($DEBUG);
$result = `ruby transitionTables.rb $p_value $filename`;
print $result;
}
}
when (/analyze/) {
given ($format_box) {
when (/Petrinet/) {
say "cp $filename $clientip.spped" if $DEBUG;
$result = `cp "$filename" "$clientip.spped"`;
$result = `ruby petri-converter.rb $clientip $k_value`;
}
when (/GINsim/) {
say "cp $filename $clientip.ginsim.ginml" if $DEBUG;
$result = `cp "$filename" "$clientip.ginsim.ginml"`;
# Convert GINsim file and get p_value and n_nodes
#The ruby script is supposed to write the p value into a file
$result = `ruby ginSim-converter.rb $clientip`;
$pFile = "$clientip.pVal.txt";
$nFile = "$clientip.nVal.txt";
# Set p_value and n_nodes
open( MYFILE, $pFile ) || die("Could not open file!");
while (<MYFILE>) { chomp; $p_value = $_; }
close(MYFILE);
open( MYFILE, $nFile ) || die("Could not open file!");
while (<MYFILE>) { chomp; $n_nodes = $_; }
close(MYFILE);
}
when (/(BN)|(PBN)/) {
translate_functions();
}
when (/(PDS)|(pPDS)|(oPDS)/) {
# do nothing
}
when (/SDDS/) {
SDDSerrorchecking_and_set_flags();
use Cwd;
$cwd_sdds = getcwd();
`mkdir -p tmp/files`;
# checks if a file was uploaded for transition table
if ($upload_file) {
$filename = "$clientip.file.txt";
system ("cp tmp/files/$upload_file $filename");
`perl -pi -e 's/\r//g' "$clientip.file.txt"`;
}
else {
print "<br>ERROR: There must be a file uploaded for the (complete) transition table or functions. <br>";
exit;
}
# checks if propensity parameters were entered
if ($propensityMatrix) {
$filename_pm = "$clientip.pm.txt";
open (PM, ">$filename_pm") or die ("<br>ERROR: Cannot open the file for propensity parameters! <br>");
print PM $propensityMatrix;
close (PM) or die ("<br>ERROR: Cannot close the file for propensity parameters! <br>");
}
else {
print "<br>ERROR: The propensity matrix entries must be specified. <br>";
exit;
}
$plot_file = "$clientip.plot";
$histogram_file = "$clientip.histogram";
$tm_file = "$clientip.tm";
print "will be fixed soon! <br>";
if ($DEBUG) {
say ("<br> perl SDDS.pl -f $filename -p $filename_pm -i $initialState -n $interestingNodes -s $num_states -e $num_steps -m $num_simulations -a $flag4ss -b $flag4tm -g $plot_file -h $histogram_file -t $tm_file <br>");
}
system ("perl SDDS.pl -f $filename -p $filename_pm -i $initialState -n $interestingNodes -s $num_states -e $num_steps -m $num_simulations -a $flag4ss -b $flag4tm -g $plot_file -h $histogram_file -t $tm_file");
} # end of /SDDS/
when (/oSDDS/) {
SDDSerrorchecking_and_set_flags();
use Cwd;
$cwd_sdds = getcwd();
`mkdir -p tmp/files`;
# checks if a file was uploaded for functions
if ($upload_file) {
$filename_func = "$clientip.func.txt";
system ("cp tmp/files/$upload_file $filename_func");
`perl -pi -e 's/\r//g' "$clientip.func.txt"`;
}
else {
print "<br>ERROR: There must be a file uploaded for the functions. <br>";
exit;
}
$epfilename = "$clientip.epfile.txt";
if ($external_parameters) {
open (EP, ">$epfilename") or die ("<br>ERROR: Cannot open the file for external parameters! <br>");
print "open ok \n<br>" if ($DEBUG);
print EP $external_parameters;
close (EP) or die ("<br>ERROR: Cannot close the file for external parameters! <br>");
}
else {
print "<br>ERROR: There must be some external parameters for the (open) system. Please enter the external parameters directly into the text area. <br>";
exit;
}
%externalParameters = ();
open (EPFILE, "<$epfilename") or die ("Cannot open epfile! \n");
while (my $temp = <EPFILE>) {
chomp ($temp);
($ep, $value) = split (/=/, $temp);
$ep =~ s/\s//g;
$value =~ s/\s//g;
$externalParameters{$ep} = $value;
}
close (EPFILE);
open (FUNCFILE, "<$filename_func") or die (" Cannot open funcfile! \n");
open (OUTFILE, ">$filename") or die (" Cannot open outputfile! \n");
while (my $func = <FUNCFILE>) {
chomp ($func);
# skip empty lines
if ($func =~ /^\s*$/) {
next;
}
foreach my $key (keys (%externalParameters)) {
my $value = $externalParameters{$key};
$func =~ s/$key/$value/g;
}
print OUTFILE "$func \n";
}
close (FUNCFILE);
close (OUTFILE);
# checks if propensity parameters were entered
if ($propensityMatrix) {
$filename_pm = "$clientip.pm.txt";
open (PM, ">$filename_pm") or die ("<br>ERROR: Cannot open the file for propensity parameters! <br>");
print PM $propensityMatrix;
close (PM) or die ("<br>ERROR: Cannot close the file for propensity parameters! <br>");
}
else {
print "<br>ERROR: The propensity matrix entries must be specified. <br>";
exit;
}
$plot_file = "$clientip.plot";
$histogram_file = "$clientip.histogram";
$tm_file = "$clientip.tm";
print "will be fixed soon! <br>";
if ($DEBUG) {
say ("perl SDDS.pl -f $filename -p $filename_pm -i $initialState -n $interestingNodes -s $num_states -e $num_steps -m $num_simulations -a $flag4ss -b $flag4tm -g $plot_file -h $histogram_file -t $tm_file <br>");
}
system ("perl SDDS.pl -f $filename -p $filename_pm -i $initialState -n $interestingNodes -s $num_states -e $num_steps -m $num_simulations -a $flag4ss -b $flag4tm -g $plot_file -h $histogram_file -t $tm_file");
} # end of /oSDDS/
default {
say 'Invalid choice of model, there was an error.'
}
}
}
default {
say 'Invalid choice of input, there was an error.'
}
}
$useRegulatory = 0;
# Set flag for creating the dependency graph
if ( $depgraph eq "Dependency graph" ) {
if ( $choice_box eq "analyze" ) {
if ( ( $format_box eq "PDS" )
|| ( $format_box eq "BN" )
|| ( $format_box eq "GINsim" )
|| ( $format_box eq "oPDS" ))
{
$useRegulatory = 1;
}
}
$depgraph = 1;
}
else {
$depgraph = 0;
}
if (defined $feedback && $feedback eq "Feedback Circuit") {
$feedback = 1;
}
else {
$feedback = 0;
}
# Give link to functional circuits if checked
if ( $feedback == 1 ) {
$circuits = "$clientip.circuits.html";
open FILE, ">$circuits" or die $!;
print FILE "<html><body>";
close FILE;
$result = `ruby circuits.rb $n_nodes $p_value "$filename" $circuits`;
open FILE, ">>$circuits" or die $!;
print FILE "</body></html>";
close FILE;
print
"<a href=\"$circuits\" target=\"_blank\"><font color=\"#226677\"<i>Click to view the functional circuits.</i></font></a><br>";
}
if ( $anaysis_method eq "Conjunctive" ) {
# dynamics depend on the dependency graph, need to generate it
print "perl regulatory.pl $filename $n_nodes $clientip $DGformat" if ($DEBUG);
system("perl regulatory.pl $filename $n_nodes $clientip $DGformat") == 0 or die("regulatory.pl died");
$dpGraph = "$clientip.out1";
# Give link to dependency graph if checked
if ( $depgraph == 1 ) {
print
"<br><A href=\"$dpGraph.$DGformat\" target=\"_blank\"><font color=\"#226677\"><i>Click to view the dependency graph.</i></font></A><br>";
}
#print "ruby conjunctiveNetwork.rb $n_nodes $p_value $dpGraph.dot<br>" ;
system("ruby conjunctiveNetwork.rb $n_nodes $p_value $dpGraph.dot");
}
elsif ( $anaysis_method eq "Algorithms" ) {
$limCyc_length = 1;
if ( ( ! defined $limCyc_length ) || ( $limCyc_length eq "" ) ) {
print
"<font color=red>Please enter a length of the limit cycle you wish to compute. Enter 1 for fixed points</font>";
die("Program quitting. Empty field entered for limit cycle length in large networks."
);
}
# Give link to dependency graph if checked
if ( $useRegulatory == 1 ) {
print "perl regulatory.pl $filename $n_nodes $clientip $DGformat" if ($DEBUG);
system("perl regulatory.pl $filename $n_nodes $clientip $DGformat") == 0 or die("regulatory.pl died");
print
"<br><A href=\"$clientip.out1.$DGformat\" target=\"_blank\"><font color=\"#226677\"><i>Click to view the dependency graph.</i></font></A><br>";
}
set_update_type();
print "ruby analysisByGroebnerBasis.rb $n_nodes $p_value $filename $limCyc_length" if ($DEBUG);
$result = `ruby analysisByGroebnerBasis.rb $n_nodes $p_value $filename $limCyc_length`;
print $result;
}
elsif ( $anaysis_method eq "Simulation" ) {
if ( $p_value && $n_nodes ) {
print "Executing simulation<br>";
print "hello<br>" if ($DEBUG);
if ( $n_nodes > 30 || $p_value**$n_nodes > 2**30 ) {
print
"<font color=red>Simulation for large networks is not possible. Please chose <i>Algorithms</i> as <b>Analysis</b> option. </font><br>";
die("Program quitting. Too many nodes");
}
print "hello set_update_type<br>" if ($DEBUG);
set_update_type();
print $option_box if ($DEBUG);
# for more than 1000 nodes don't produce a graph, use C++ program instead
# Set flag for whether to print probabilities in state space
if ($probabilities eq "probabilities") {
$stochastic = 1;
}
else {
$stochastic = 0;
}
$option_box = "All trajectories from all possible initial states";
if ( $option_box eq "All trajectories from all possible initial states" ) {
# complete state space
print $format_box if ($DEBUG);
if ( $p_value**$n_nodes > 1000
&& (($format_box eq "PDS")))
{
print
"Calculating fixed points and limit cycles, not generating a graph of the state space.<BR>\n";
print(
"./Analysis/analysis $p_value ${clientip}.functionfile <BR>"
) if ($DEBUG);
print("<pre>");
system(
"./Analysis/analysis $p_value ${clientip}.functionfile");
print("</pre>");
print("Done.<br>");
}
else { #analysis through simulation with graph
if ( $p_value**$n_nodes > 1000 ) {
print
"<font color=red>Simulation for large stochastic networks is not possible. Please choose <i>Algorithms</i> as <b>Analysis</b> option. </font><br>";
die("Program quitting. Too many nodes");
}
print
"<font color=blue><b>Analysis of the state space</b></font> <br>";
print(
"perl dvd_stochastic_runner.pl $n_nodes $p_value 1 $updstoch_flag $clientip $SSformat $depgraph $updsequ_flag $update_schedule $stochastic 1 0 $filename\n<br> "
) if ($DEBUG);
$output = `/usr/bin/perl dvd_stochastic_runner.pl $n_nodes $p_value 1 $updstoch_flag $clientip $SSformat $depgraph $updsequ_flag $update_schedule $stochastic 1 0 $filename`;
print $output;
}
}
else { # trajectory
print
"<font color=blue><b>Computing Trajectory of the given initialization</b></font> <br>";
if ( ( defined $trajectory_value )
&& ( $trajectory_value ne "" ) )
{
$trajectory_value =~ s/^\s+|\s+$//g;
; #remove all leading and trailing white spaces
$trajectory_value =~ s/(\d+)\s+/$1 /g
; #remove extra white space between the numbers
$trajectory_value =~ s/ /_/g;
print "trajectory_value: $trajectory_value<br>"
if $DEBUG;
system(
"/usr/bin/perl dvd_stochastic_runner.pl $n_nodes $p_value 1 $updstoch_flag $clientip $SSformat $depgraph $updsequ_flag $update_schedule $stochastic 0 $trajectory_value $filename"
);
print
"/usr/bin/perl dvd_stochastic_runner.pl $n_nodes $p_value 1 $updstoch_flag $clientip $SSformat $depgraph $updsequ_flag $update_schedule $stochastic 0 $trajectory_value $filename<br>"
if $DEBUG;
}
else {
print
"<br><font color=red>Please enter an initial state or select <i>Complete State Space</i></font><br>";
die( "Program quitting. Empty value for initialization field"
);
}
}
if ( $statespace eq "State space graph"
&& $option_box eq
"All trajectories from all possible initial states" )
{
if ( -e "$clientip.out.$SSformat" ) {
print "<A href=\"$clientip.out.$SSformat\"
target=\"_blank\"><font color=\"#226677\"><i>Click to view the state space
graph.</i></font></A><br>"
}
}
else {
if ( -e "$clientip.graph.$SSformat" ) {
print
"<A href=\"$clientip.graph.$SSformat\" target=\"_blank\"><font
color=\"#226677\"><i>Click to view the trajectory.</i></font></A><br>"
}
}
#if(-e "$clientip.out1.$DGformat")
if ( -e "$clientip.out1.$SSformat" ) {
print
"<A href=\"$clientip.out1.$DGformat\" target=\"_blank\"><font
color=\"#226677\"><i>Click to view the dependency graph.</i></font></A><br>";
}
# `rm -f -R $clientip`;
# `rm -f $clientip.out.dot`;
# `rm -f $clientip.graph.dot`;
#
# `rm -f $clientip.out1.dot`;
# `rm -f $clientip.out2.dot`;
#
# `rm -f $clientip.functionfile.txt`;
# `rm -f $clientip.trfunctionfile.txt`;
}
}
elsif ( $anaysis_method eq "sdds_graph" ) {
if (-e "$clientip.plot.png") {
print "<br><A href=\"$clientip.plot.png\" target=\"_blank\"><font color=\"#226677\"><i>Click here to see the plot of cell population simulation.</i></font></A><br>";
}
if (-e "$clientip.histogram.png") {
print "<br><A href=\"$clientip.histogram.png\" target=\"_blank\"><font color=\"#226677\"><i>Click here to see the histogram for probability distribution.</i></font></A><br>";
}
if (-e "$clientip.tm.txt") {
print "<br><A href=\"$clientip.tm.txt\" target=\"_blank\"><font color=\"#226677\"><i>Click here to see the probability transition matrix of the system.</i></font></A><br>";
}
}
else {
print "There was an error." . "\n";
}
exit 1;