Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves issues of SBMLTestSuite and FBA #40

Merged
merged 42 commits into from
Jun 5, 2020

Conversation

hemilpanchiwala
Copy link
Member

Major changes from this PR:

  • Adds a running wrapper for the SBML Test Runner that allows to check the results through the plot and compare the distance plots.
  • Adds testing by CompSimulator for the comp models in SBMLTestSuiteTest
  • Adds three new distance metrics in SBSCL.
    • Maximum Absolute Distance
    • Maximum Relative Distance
    • Maximum Divergence Tolerance - The metric used by SBML Test Runner
  • Adds the newly added tests from SBML Test Suite.
  • Updates the INSTALL.md section for the SBML Test Runner.
  • Moves all the script files under the src/test/scripts folder. Updated the scripts files.
  • CobraSolver is refactored to FluxBalancedAnalysis.
  • Solves the issues with the FluxBalanceAnalysis so that all the FBC tests from SBML Test Suite now runs perfectly.
  • Fixes some other minor issues and some enhancement in the code

hemilpanchiwala and others added 30 commits May 22, 2020 22:58
Copy link
Member

@draeger draeger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general recommendation, I'd suggest making use of the templates for code style from the JSBML project at https://github.com/sbmlteam/jsbml/tree/master/dev/. They can really help to automatically insert blank spaces, curly braces, and so forth, where forgotten.

Further comments were given in the code.

* @param x
* @param expected
* @return maxAbsDistances the list of maximum absolute distances in the blocks
*/
public ArrayList<Double> getMaxAbsDistances(MultiTable x, MultiTable expected) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not declare unnecessarily specific return types for methods and also declare variables with the least specific type. In this concrete case, please use List<Double> to initialize the variable for the distances and also return a List<Double>. You can still use an ArrayList<Double> to initialize the variable, but not as return type. This applies to other positions as well.

cd resources/bigg
cd TEST_DIR
mkdir -p $TEST_DIR/resources/bigg
cd $TEST_DIR/resources/bigg
wget https://github.com/matthiaskoenig/bigg-models-fba/raw/master/models/bigg_models_v1.5.tar.gz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthiaskoenig Not clear to me why we don't download the BiGG models directly from BiGG. Doesn't this detour introduce the problem that we need to keep two places in sync with BiGG Models Database?

// compute distance
QualityMeasure distance = new RelativeEuclideanDistance();
double dist = distance.distance(solution, inputData);
Assert.assertTrue(dist <= 0.2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend to always indicate the data type also for literal numbers, here, for instance, 0.2d so that the compiler knows it is a double value. If you do it always, you will not forget it in situations where it can make a difference (e.g., when dividing integer numbers).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@draeger, this has been removed from the code now. The distance has been now updated to the MaxDivergenceTolerance.

*/
public ArrayList<Double> getColumnDistances(MultiTable x, MultiTable expected) {
ArrayList<Double> distances= new ArrayList<Double>();
public HashMap<String, Double> getMaxAbsDistances(MultiTable x, MultiTable expected) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, please do not return HashMap<String, Double> but Map<String, Double> to make it easier to use a different implementation later on.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@draeger, Updated this in the latest commit.

@hemilpanchiwala
Copy link
Member Author

hemilpanchiwala commented Jun 3, 2020

As a general recommendation, I'd suggest making use of the templates for code style from the JSBML project at https://github.com/sbmlteam/jsbml/tree/master/dev/. They can really help to automatically insert blank spaces, curly braces, and so forth, where forgotten.

Further comments were given in the code.

@draeger, I can just see their recommendations but can't add the templates as I am working on IntelliJ (even prefer), and the templates are only present for Eclipse.

@draeger
Copy link
Member

draeger commented Jun 3, 2020

As a general recommendation, I'd suggest making use of the templates for code style from the JSBML project at https://github.com/sbmlteam/jsbml/tree/master/dev/. They can really help to automatically insert blank spaces, curly braces, and so forth, where forgotten.
Further comments were given in the code.

@draeger, I can just see their recommendations but can't add the templates as I am working on IntelliJ (even prefer), and the templates are only present for Eclipse.

Ok; so IntelliJ doesn't have an import for such files or doesn't come with comparable functions?

@hemilpanchiwala
Copy link
Member Author

As a general recommendation, I'd suggest making use of the templates for code style from the JSBML project at https://github.com/sbmlteam/jsbml/tree/master/dev/. They can really help to automatically insert blank spaces, curly braces, and so forth, where forgotten.
Further comments were given in the code.

@draeger, I can just see their recommendations but can't add the templates as I am working on IntelliJ (even prefer), and the templates are only present for Eclipse.

Ok; so IntelliJ doesn't have an import for such files or doesn't come with comparable functions?

I can just format the code as per the Java code style which is provided in IntelliJ given at this link.

.travis.yml Outdated
# get BiGG models for testing
- source ./download_bigg_models.sh
# get sbml-test-case models for testing
- source ./download_sbml-test-suite.sh
- cd ../..
- cd ../../..

script:
- mvn clean install
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add newline at end of file (I even get the warning here)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

INSTALL.md Outdated
mvn clean install -DskipTests
```

The tests require additional resources which have to be downloaded. These include the sbml-testsuite and the BiGG models.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add links to the project pages (i.e. the git repository for the BiGG models and for the sbml-testsuite)! We are using these resources and should be linked in the documentation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

.travis.yml Outdated
@@ -5,12 +5,12 @@ jdk:
- oraclejdk11

install:
- cd src/test
- cd src/test/scripts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do the cd and back here!
Just directly call the scripts as mentioned in the installation instructions

source ./src/test/scripts/download_bigg_models.sh
source ./src/test/scripts/download_sbml-test-suite.sh

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

INSTALL.md Outdated
The tests require additional resources which have to be downloaded. These include the sbml-testsuite and the BiGG models.
```
source ./src/test/download_bigg_models.sh
source ./src/test/download_sbml-test-suite.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing the scripts directory

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

INSTALL.md Outdated
```

## SBML Test Runner
The SBML Test Runner is a standalone desktop application with a graphical user interface (GUI) for controlling SBML-compatible applications and making them run test cases from the [SBML Test Suite](http://sbml.org/Software/SBML_Test_Suite). It is written in Java with the Eclipse SWT widget toolkit and can be used on macOS, Linux and Windows.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete: It is written in Java with the Eclipse SWT widget toolkit and can be used on macOS, Linux and Windows.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!


MultiTable solution;

if (model.getExtension(CompConstants.shortLabel) == null){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not set the tolerances anywhere for the simulation. Please set the tolerances explicitly! Only then it is possible to check the solutions correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

* @return the epsilon value
*/
public double getEpsilon() {
return EPS;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this lowercase and call it epsilon or eps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthiaskoenig is here referring to the name of the variable, not the name of the method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

for (String head : header) {
if (!head.equalsIgnoreCase(data.getTimeName())) {
newHead[i++] = head.trim();
for (int p = 1; p < header.length; p++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment why this loop is starting at 1. What are you ignoring?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthiaskoenig, the time column has to be ignored for the newHead array. So, its started at index 1.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the main reason why the travis ignored the SBMLTestSuiteTest file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just add a comment. Here, it can be as simple as adding // we are starting at 1 because... in the line over the loop.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@draeger, this is commented above at line 100 in this file: // exclude time column.

}

/* (non-Javadoc)
* @see org.sbml.simulator.math.Distance#distance(java.lang.Iterable, java.lang.Iterable, double)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document this better ! Please describe what the distance is and state the used formula in the comment. This is the core comparison function metric used. This must be documented so that others understand what is done here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the comments properly in the initial description of the class.

* @see org.sbml.simulator.math.Distance#distance(java.lang.Iterable, java.lang.Iterable, double)
*/
@Override
public double distance(Column x, Column y, double defaultValue) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also did not see any test code for this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding in the next commit!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the tests for MaxDivergenceTolerance class

@hemilpanchiwala
Copy link
Member Author

change name of method. This is very unspecific. Use something like addBoundsEpsilon which states what the method is doing. updateBounds could do anything with the bounds. Also probably a good idea to define the eps locally here (because it is not used anywhere else).

@matthiaskoenig, but we have given get and set methods for the eps. So, I don't think we should declare it locally in the method.

Comment on lines +51 to +54
String filePath = dirPath + File.separator + currentCase + File.separator + currentCase + "-sbml-l" + level + 'v' + version + ".xml";
String settingsPath = dirPath + File.separator + currentCase + File.separator + currentCase + "-settings.txt";
String outputFilePath = outputDirPath + File.separator + currentCase + ".csv";
String resultsPath = dirPath + File.separator + currentCase + File.separator + currentCase + "-results.csv";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did anybody test this under Windows? To my knowledge, internally Java always uses / as separator in paths and the virtual machine translates it to the operating system.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to add: I think this will work, but I also think it is not needed (without having it tested).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I just saw that when we give /, then Java internally handles things to translate to platform-specific code. But File.separator can be a good way to show users what will make sense in their OS, rather than what makes sense to Java.

Comment on lines 64 to 65
double absolute = (!properties.getProperty("absolute").isEmpty()) ? Double.parseDouble(properties.getProperty("absolute")) : 0d;
double relative = (!properties.getProperty("relative").isEmpty()) ? Double.parseDouble(properties.getProperty("relative")) : 0d;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be preferable to declare String literals in the form public static final String ABSOLUTE = "absolute" and then to reuse these constants where needed. This reduces maintenance effort and possible errors caused by typos.

Another possibility is creating an internal enum such as:

public enum SettingsKeywords {
   absolute;
   ...
}

that can be uses similarly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated by adding final variables for Strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants