Skip to content

Commit

Permalink
Merge pull request #39 from RuleWorld/issue37
Browse files Browse the repository at this point in the history
Merging branch made to address seg fault in Issue 37
  • Loading branch information
aadibiasi authored May 24, 2024
2 parents 31eef54 + 0790b4a commit a5e2941
Show file tree
Hide file tree
Showing 14 changed files with 299 additions and 60 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: main-validation

on:
push:
branches: [ master ]
branches: [ master, issue37]
pull_request:
branches: [ master ]

Expand Down Expand Up @@ -34,9 +34,9 @@ jobs:
cd build
cmake -G "Ninja" ..
ninja
cp C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/libgcc_s_seh-1.dll ${{github.workspace}}/build/.
cp C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/libstdc++-6.dll ${{github.workspace}}/build/.
cp C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/libwinpthread-1.dll ${{github.workspace}}/build/.
# cp C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/libgcc_s_seh-1.dll ${{github.workspace}}/build/.
# cp C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/libstdc++-6.dll ${{github.workspace}}/build/.
# cp C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/libwinpthread-1.dll ${{github.workspace}}/build/.
./NFsim.exe -h
- name: Configure CMake
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
python-version: '3.8'
- name: Cache pip
uses: actions/cache@v2
with:
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ validate/basicModels/*.*dat
validate/basicModels/*.net
validate/basicModels/*.xml
validate/basicModels/*.tsv
validate/basicModels/*.json
validate/basicModels/*.json
test/Issue37/test2.nfevent.json
test/Issue37/test.nfevent.json
test/Issue37/out.gdat
test/Issue37/issue37_test2.species
test/Issue37/issue37_test2.gdat
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ executable, you'll need to copy the the following DLLs along with it:

## Release Notes

### v1.14.2 May, 2024

(a) Bugfix: Fixed a segmentation fault resulting from having a species start with zero concentration. Two simple models were added to the validation process to catch this error.
(b) Changes to the validation process were made. Previously, 15 trajectories would be generated for each model before testing the differences of NFsim and SSA versus NFsim and ODE. Now only one trajectory would be tested and more would generate upon faliure until a model failed 15 times in a row.

### v1.14.1 May, 2023

(a) Bugfix: Added a missing "\[" when no operations are present

### v1.14.0 February, 2023

Relabeling the version number to follow previous scheme to avoid further confusion.
Expand Down
2 changes: 1 addition & 1 deletion dist/changeFilename.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import platform
import os

version = '1.14.0'
version = '1.14.2'
destdir = os.path.join(version, '{0}-{1}'.format(platform.system(), platform.architecture()[0]))
os.makedirs(destdir)
print('moving NFSIm to {0}\n'.format(destdir))
Expand Down
55 changes: 30 additions & 25 deletions src/NFinput/NFinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,33 +1051,38 @@ string NFinput::initStartSpecies(
// AS2023 - start initial state block
string logstr = " \"initialState\": {\n";
logstr += " \"molecule_array\": [\n";
// AS2023 - to add compression we make the full molecule type
// vector first
int molec_size = *max_element(mgids.begin(), mgids.end());
molec_size+=1;
vector <int> molec_vec;
for(unsigned int isi=0; isi<molec_size; isi++) {
molec_vec.push_back(-1);
}
for(unsigned int img=0; img<mgids.size(); img++) {
molec_vec[mgids[img]] = mids[img];
}
// AS2023 - now we use it to compress the initial state vector
int last_val = molec_vec[0];
int val_ctr = 1;
for(unsigned int ici=1; ici<molec_vec.size(); ici++) {
if (molec_vec[ici]!=last_val) {
logstr += " [" + to_string(last_val) + "," + to_string(val_ctr) + "],\n";
last_val = molec_vec[ici];
val_ctr = 1;
} else {
val_ctr += 1;
// cout << "number of molecules: " << mgids.size() << endl;
if (mgids.size()>0){
// AS2023 - to add compression we make the full molecule type
// vector first
int molec_size = *max_element(mgids.begin(), mgids.end());
molec_size+=1;
vector <int> molec_vec;
for(unsigned int isi=0; isi<molec_size; isi++) {
molec_vec.push_back(-1);
}
for(unsigned int img=0; img<mgids.size(); img++) {
molec_vec[mgids[img]] = mids[img];
}
// AS2023 - now we use it to compress the initial state vector
int last_val = molec_vec[0];
int val_ctr = 1;
for(unsigned int ici=1; ici<molec_vec.size(); ici++) {
if (molec_vec[ici]!=last_val) {
logstr += " [" + to_string(last_val) + "," + to_string(val_ctr) + "],\n";
last_val = molec_vec[ici];
val_ctr = 1;
} else {
val_ctr += 1;
}
}
logstr += " [" + to_string(last_val) + "," + to_string(val_ctr) + "]\n";
// logstr += " [" + to_string(last_val) + "," + to_string(val_ctr) + "],\n";
// // AS 2023
// logstr.erase(logstr.end()-2, logstr.end());
}
logstr += " [" + to_string(last_val) + "," + to_string(val_ctr) + "],\n";
// AS 2023
logstr.erase(logstr.end()-2, logstr.end());
logstr += "\n ],\n";
logstr += " ],\n";

// AS2023
logstr += " \"ops\": [\n ";
for(int k=0;k<operations.size();k++) {
Expand Down
2 changes: 1 addition & 1 deletion src/NFsim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ int main(int argc, char *argv[])
// turned off for the general release code.
//if (!schedulerInterpreter(&argc, &argv)) return 0;

string versionNumber = "1.14.1";
string versionNumber = "1.14.2";
cout<<"starting NFsim v"+versionNumber+"..."<<endl<<endl;
clock_t start,finish;
double time;
Expand Down
80 changes: 80 additions & 0 deletions test/Issue37/issue37.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by BioNetGen 2.9.0 -->
<sbml xmlns="http://www.sbml.org/sbml/level3" level="3" version="1">
<model id="uhohnfsim">
<ListOfParameters>
<Parameter id="_rateLaw1" type="Constant" value="10" expr="10"/>
<Parameter id="_rateLaw2" type="Constant" value="1" expr="1"/>
</ListOfParameters>
<ListOfMoleculeTypes>
<MoleculeType id="A"/>
</ListOfMoleculeTypes>
<ListOfCompartments>
</ListOfCompartments>
<ListOfSpecies>
<Species id="S1" concentration="10" name="A()">
<ListOfMolecules>
<Molecule id="S1_M1" name="A"/>
</ListOfMolecules>
</Species>
</ListOfSpecies>
<ListOfReactionRules>
<ReactionRule id="RR1" name="_R1" symmetry_factor="1">
<ListOfReactantPatterns>
</ListOfReactantPatterns>
<ListOfProductPatterns>
<ProductPattern id="RR1_PP1">
<ListOfMolecules>
<Molecule id="RR1_PP1_M1" name="A"/>
</ListOfMolecules>
</ProductPattern>
</ListOfProductPatterns>
<RateLaw id="RR1_RateLaw" type="Ele" totalrate="0">
<ListOfRateConstants>
<RateConstant value="_rateLaw1"/>
</ListOfRateConstants>
</RateLaw>
<Map>
</Map>
<ListOfOperations>
<Add id="RR1_PP1_M1"/>
</ListOfOperations>
</ReactionRule>
<ReactionRule id="RR2" name="_reverse__R1" symmetry_factor="1">
<ListOfReactantPatterns>
<ReactantPattern id="RR2_RP1">
<ListOfMolecules>
<Molecule id="RR2_RP1_M1" name="A"/>
</ListOfMolecules>
</ReactantPattern>
</ListOfReactantPatterns>
<ListOfProductPatterns>
</ListOfProductPatterns>
<RateLaw id="RR2_RateLaw" type="Ele" totalrate="0">
<ListOfRateConstants>
<RateConstant value="_rateLaw2"/>
</ListOfRateConstants>
</RateLaw>
<Map>
<MapItem sourceID="RR2_RP1_M1"/>
</Map>
<ListOfOperations>
<Delete id="RR2_RP1" DeleteMolecules="0"/>
</ListOfOperations>
</ReactionRule>
</ListOfReactionRules>
<ListOfObservables>
<Observable id="O1" name="A" type="Molecules">
<ListOfPatterns>
<Pattern id="O1_P1">
<ListOfMolecules>
<Molecule id="O1_P1_M1" name="A"/>
</ListOfMolecules>
</Pattern>
</ListOfPatterns>
</Observable>
</ListOfObservables>
<ListOfFunctions>
</ListOfFunctions>
</model>
</sbml>
18 changes: 18 additions & 0 deletions test/Issue37/issue37_test2.bngl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
begin model

begin species
A() 100
B() 0
end species

begin observables
Molecules A A()
end observables

begin reaction rules
0 <-> A() 10,1
end reaction rules

end model

simulate({method=>"nf",t_end=>100,n_steps=>100})
86 changes: 86 additions & 0 deletions test/Issue37/issue37_test2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by BioNetGen 2.9.1 -->
<sbml xmlns="http://www.sbml.org/sbml/level3" level="3" version="1">
<model id="issue37_test2">
<ListOfParameters>
<Parameter id="_rateLaw1" type="Constant" value="10" expr="10"/>
<Parameter id="_rateLaw2" type="Constant" value="1" expr="1"/>
</ListOfParameters>
<ListOfMoleculeTypes>
<MoleculeType id="A"/>
<MoleculeType id="B"/>
</ListOfMoleculeTypes>
<ListOfCompartments>
</ListOfCompartments>
<ListOfSpecies>
<Species id="S1" concentration="100" name="A()">
<ListOfMolecules>
<Molecule id="S1_M1" name="A"/>
</ListOfMolecules>
</Species>
<Species id="S2" concentration="0" name="B()">
<ListOfMolecules>
<Molecule id="S2_M1" name="B"/>
</ListOfMolecules>
</Species>
</ListOfSpecies>
<ListOfReactionRules>
<ReactionRule id="RR1" name="_R1" symmetry_factor="1">
<ListOfReactantPatterns>
</ListOfReactantPatterns>
<ListOfProductPatterns>
<ProductPattern id="RR1_PP1">
<ListOfMolecules>
<Molecule id="RR1_PP1_M1" name="A"/>
</ListOfMolecules>
</ProductPattern>
</ListOfProductPatterns>
<RateLaw id="RR1_RateLaw" type="Ele" totalrate="0">
<ListOfRateConstants>
<RateConstant value="_rateLaw1"/>
</ListOfRateConstants>
</RateLaw>
<Map>
</Map>
<ListOfOperations>
<Add id="RR1_PP1_M1"/>
</ListOfOperations>
</ReactionRule>
<ReactionRule id="RR2" name="_reverse__R1" symmetry_factor="1">
<ListOfReactantPatterns>
<ReactantPattern id="RR2_RP1">
<ListOfMolecules>
<Molecule id="RR2_RP1_M1" name="A"/>
</ListOfMolecules>
</ReactantPattern>
</ListOfReactantPatterns>
<ListOfProductPatterns>
</ListOfProductPatterns>
<RateLaw id="RR2_RateLaw" type="Ele" totalrate="0">
<ListOfRateConstants>
<RateConstant value="_rateLaw2"/>
</ListOfRateConstants>
</RateLaw>
<Map>
<MapItem sourceID="RR2_RP1_M1"/>
</Map>
<ListOfOperations>
<Delete id="RR2_RP1" DeleteMolecules="0"/>
</ListOfOperations>
</ReactionRule>
</ListOfReactionRules>
<ListOfObservables>
<Observable id="O1" name="A" type="Molecules">
<ListOfPatterns>
<Pattern id="O1_P1">
<ListOfMolecules>
<Molecule id="O1_P1_M1" name="A"/>
</ListOfMolecules>
</Pattern>
</ListOfPatterns>
</Observable>
</ListOfObservables>
<ListOfFunctions>
</ListOfFunctions>
</model>
</sbml>
2 changes: 2 additions & 0 deletions validate/basicModels/r29.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NFSIM ONLY: population testing, with reaction log
-sim 100 -oSteps 100 -rxnlog basicModels/v29_rxns.json
2 changes: 2 additions & 0 deletions validate/basicModels/r30.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NFSIM ONLY: population testing, with reaction log
-sim 100 -oSteps 100 -rxnlog basicModels/v30_rxns.json
16 changes: 16 additions & 0 deletions validate/basicModels/v29.bngl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# issue37_test.bngl

begin model
begin species
A() 0
end species
begin observables
Molecules A A()
end observables
begin reaction rules
0 <-> A() 10,1
end reaction rules
end model

## model actions ##
writeXML()
17 changes: 17 additions & 0 deletions validate/basicModels/v30.bngl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# issue37_test2.bngl

begin model
begin species
A() 100
B() 0
end species
begin observables
Molecules A A()
end observables
begin reaction rules
0 <-> A() 10,1
end reaction rules
end model

## model actions ##
writeXML()
Loading

0 comments on commit a5e2941

Please sign in to comment.