Skip to content

Commit

Permalink
fix dot export for abstract namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Metelkin committed Nov 24, 2023
1 parent 1edd967 commit d2c3377
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
3 changes: 0 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@

## bugs

- wrong figures for abstract namespaces in DOT: no references to compartment
- nothing is dislayed if you use wrong cli command: `heta builds`

## features

- write reusable `Build` class
Expand Down
4 changes: 2 additions & 2 deletions bin/heta-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const fs = require('fs');
const path = require('path');
const { Builder } = require('../src/builder');
const { load } = require('js-yaml'); // https://www.npmjs.com/package/js-yaml
const _ = require('lodash');
const _merge = require('lodash/merge');
const semver = require('semver');
const { version, bugs } = require('../package');
const colors = require('colors');
Expand Down Expand Up @@ -100,7 +100,7 @@ program
};

// === update declaration ===
_.merge(declaration, CLIDeclaration);
_merge(declaration, CLIDeclaration);

// === wrong version throws, if no version stated than skip ===
let satisfiesVersion = declaration.builderVersion
Expand Down
25 changes: 12 additions & 13 deletions src/dot-export/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,27 @@ class DotExport extends AbstractExport{
.forEach((comp) => clustersDict[comp.id] = []);
ns.selectByInstanceOf('Process')
.forEach((proc) => {
let substrates = proc.actors
.filter((x) => x.stoichiometry < 0);
let hasFirstSubstrate = substrates.length > 0
&& substrates[0].targetObj !== undefined
&& substrates[0].targetObj.compartment !== undefined;
if (hasFirstSubstrate) {
let mainComp = substrates[0].targetObj.compartment;
clustersDict[mainComp].push(proc);
} else {
clustersDict['_'].push(proc);
}
let substrates = proc.actors.filter((x) => x.stoichiometry < 0);
// push records
proc.actors.forEach((actor) => {
let record = ns.get(actor.target) || { id: actor.target }; // use fake record
let compartmentId = record.compartment || '_';
clustersDict[compartmentId]?.push(record) || (clustersDict[compartmentId] = [record]);
});
// push process
let compartmentOfFirstSubstrate = ns.get(substrates[0]?.target)?.compartment || '_';
clustersDict[compartmentOfFirstSubstrate]?.push(proc);
});
/* display all records
ns.selectByInstanceOf('Record')
.filter((rec) => rec.isDynamic)
.forEach((rec) => {
if (rec.compartment !== undefined) {
clustersDict[rec.compartment].push(rec);
} else {
clustersDict['_'].push(rec);
}
});

*/
return {
ns,
clustersDict
Expand Down
2 changes: 1 addition & 1 deletion src/templates/dot.dot.njk
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ digraph {{ ns.spaceName }} {
tooltip="{{ key }}"
//
{%- for component in val %}
{%- if component.instanceOf('Process') %}
{%- if component.instanceOf and component.instanceOf('Process') %}
{{ component.id }} [shape=circle,width=.1,height=.1,label=""] // xlabel="{{ component.id }}"
{%- else %}
{{ component.id }} [shape=box]
Expand Down

0 comments on commit d2c3377

Please sign in to comment.