Skip to content

Commit

Permalink
deleteNS
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Metelkin committed Nov 25, 2023
1 parent d2d17c6 commit 1c9b303
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 10 deletions.
15 changes: 6 additions & 9 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,27 @@

## bugs

- highlight multiline comments in Heta dictionary and array (with/without comma)
- multiple single-line comments in dict result in error

## features

- write reusable `Build` class
- atStart to exports: Matlab, DBSolve
- checking legal functions inside Expressions and functionDefinition
- `#defineFunction`: circular dependences within functions, internal functions, different exports, functionDef vs units
- calculate units for pow function
- write reusable `Build` class
- remove unnecessary rules in export
- checking units for diff eq
- check unit consistency for Species: amount/area if compartment is area
- AnyUnit for zero numbers
- highlight multiline comments in Heta dictionary and array (with/without comma)
- atStart to exports: Matlab, DBSolve
- remove `isAmount`, `compartment` properties from `@Reaction`

## ideas

- generation of 'platform.yml' by `heta init`
- deprecated `include` statement
- `#move`, `#moveNS`
- `#deleteNS` action
- `#move`, `#moveNS`
- remove support of `include` statement is deprecated, use `#include` action (v0.7.0)
- `include` statement is deprecated, use `#include` action (v0.8.0)
- check file format for modules
- syntax highlight in web
- add "ignoreCompartment" property in Species
- do not translate base units in SBML export like second => _second
- automatic creation of modifiers in SBML
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Programming platform for Quantitative Systems Pharmacology modeling in NodeJS",
"main": "src/index.js",
"scripts": {
"test:dev": "mocha test/check-units/calc-unit --config=./test/.mocharc.json",
"test:dev": "mocha test/container/container-actions --config=./test/.mocharc.json",
"test": "mocha test --config=./test/.mocharc.json",
"jsdoc": "jsdoc -r -c .jsdoc.json --readme api-references.md -d docs/dev src",
"test:cov": "nyc --reporter=lcov npm run test",
Expand Down
12 changes: 12 additions & 0 deletions src/container/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,18 @@ Container.prototype.setNS = function(q = {}){
this.logger.info(`Namespace "${space}" was set as "${typeString}"`);
};

Container.prototype.deleteNS = function(_q = {}) {
let q = Object.assign({space: 'nameless'}, _q);
if (this.namespaceStorage.has(q.space)) {
this.namespaceStorage.delete(q.space);
this.logger.info(`Namespace "${q.space}" was deleted.`);
} else {
this.logger.error(`Namespace "${q.space}" is not found.`);
}

return this;
};

/**
* Clones and rename all components to another space.
*
Expand Down
8 changes: 8 additions & 0 deletions src/sbml-export/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ class SBMLExport extends AbstractExport {
} else {
try {
listOfUnitDefinitions = ns.getUniqueUnits()
/*
.filter((units) => {
return units.length !== 1
|| legalUnits.indexOf(units[0].kind) < 0
|| units[0].exponent !== 1
|| units[0].multiplier !== 1;
})
*/
.map((units) => {
return units
.toXmlUnitDefinition(legalUnits, { nameStyle: 'string', simplify: true });
Expand Down
26 changes: 26 additions & 0 deletions test/container/container-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,29 @@ describe('Unit tests for Container load', () => {
c.logger.resetErrors();
});
});

describe('Test deleting NS', () => {
let c = new Container();

it('Create NS', () => {
c.setNS({space: 'one'});
c.setNS({space: 'two'});

expect(c.namespaceStorage.size).to.equal(3);
});

it('Delete NS one', () => {
c.deleteNS({space: 'one'});

expect(c.namespaceStorage.size).to.equal(2);
});

it('Delete not existed NS', () => {
c.deleteNS({space: 'one'});
c.deleteNS({space: 'three'});

expect(c.logger.hasErrors).to.be.true;
expect(c.namespaceStorage.size).to.equal(2);
});

});

0 comments on commit 1c9b303

Please sign in to comment.