Skip to content

Commit

Permalink
Merge pull request #12 from privrja/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
privrja authored Apr 7, 2019
2 parents c8dd8a2 + a47f46a commit 5cf22a6
Show file tree
Hide file tree
Showing 35 changed files with 404 additions and 200 deletions.
98 changes: 87 additions & 11 deletions dist/smiles-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2428,6 +2428,7 @@ var Drawer = function () {

this.initRings();
this.initHydrogens();
this.graph.findDecayPoints();

if (!this.infoOnly) {
this.position();
Expand Down Expand Up @@ -5812,7 +5813,6 @@ var Graph = function () {
// Used for the bridge detection algorithm
this._time = 0;
this._init(parseTree);
this.findDecayPoints();
}

/**
Expand Down Expand Up @@ -5933,6 +5933,81 @@ var Graph = function () {
break;
}
}
}, {
key: 'reduceDecays',
value: function reduceDecays() {
this._decaysCopy = [];
this.dfsSmilesInitialization();
for (var i = 0; i < this.decays.length; i++) {
this.smallBlockDfsStart(this.edges[this.decays[i]]);
}
this.decays = [];
this.decays = this._decaysCopy;
this.setStandardDecays();
}
}, {
key: 'dfsSmallInitialization',
value: function dfsSmallInitialization(vertices) {
for (var i = 0; i < vertices.length; ++i) {
this.vertices[vertices[i]].vertexState = VertexState.VALUES.NOT_FOUND;
}
}
}, {
key: 'smallBlockDfsStart',
value: function smallBlockDfsStart(edge) {
var stackVisitedVertexes = [];
var depth = this.smallDfs(this.vertices[edge.sourceId], 0, stackVisitedVertexes);
// this.dfsSmallInitialization(stackVisitedVertexes);
this.dfsSmilesInitialization();

if (depth > 3) {
stackVisitedVertexes = [];
depth = this.smallDfs(this.vertices[edge.targetId], 0, stackVisitedVertexes);
// this.dfsSmallInitialization(stackVisitedVertexes);
this.dfsSmilesInitialization();
if (depth > 3) {
this._decaysCopy.push(edge.id);
}
}
}
}, {
key: 'smallDfs',
value: function smallDfs(vertex, depth, stackVisitedVertexes) {
stackVisitedVertexes.push(vertex.id);
if (depth > 3) {
return depth;
}

if (vertex.vertexState !== VertexState.VALUES.NOT_FOUND) {
return depth;
}

vertex.vertexState = VertexState.VALUES.OPEN;
++depth;

for (var i = 0; i < vertex.edges.length; ++i) {
var edge = this.edges[vertex.edges[i]];
if (edge.isDecay) {
continue;
}
var nextVertex = Graph.getProperVertex(vertex.id, edge.sourceId, edge.targetId);
depth = this.smallDfs(this.vertices[nextVertex], depth, stackVisitedVertexes);
}
vertex.vertexState = VertexState.VALUES.CLOSED;
return depth;
}
}, {
key: 'setStandardDecays',
value: function setStandardDecays() {
var _this = this;

this.edges.forEach(function (e) {
e.setDecay(false);
});
this.decays.forEach(function (e) {
_this.edges[e].setDecay(true);
});
}
}, {
key: 'standardDecays',
value: function standardDecays() {
Expand All @@ -5945,15 +6020,16 @@ var Graph = function () {
}
}
}
this.reduceDecays();
}
}, {
key: 'sourceDecays',
value: function sourceDecays() {
var _this = this;
var _this2 = this;

this.options.decaySource.forEach(function (e) {
_this.edges[e].setDecay(true);
_this.decays.push(e);
_this2.edges[e].setDecay(true);
_this2.decays.push(e);
});
}

Expand Down Expand Up @@ -7034,15 +7110,15 @@ var Graph = function () {
}, {
key: 'dfsSmiles',
value: function dfsSmiles(vertex, stackSmiles) {
var _this2 = this;
var _this3 = this;

var lastVertexId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
var isSecondPass = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;

if (vertex.vertexState === VertexState.VALUES.OPEN && !isSecondPass && lastVertexId !== -1) {
this._isCyclic = true;
if (!vertex.digits.some(function (e) {
return _this2.vertices[lastVertexId].digits.includes(e);
return _this3.vertices[lastVertexId].digits.includes(e);
})) {
vertex.digits.push(this._digitCounter);
this.vertices[lastVertexId].digits.push(this._digitCounter);
Expand Down Expand Up @@ -7134,31 +7210,31 @@ var Graph = function () {
}, {
key: 'smilesNumbersAdd',
value: function smilesNumbersAdd(vertex) {
var _this3 = this;
var _this4 = this;

var numbers = '';

var _loop = function _loop(i) {
var num = vertex.digits[i];
if (_this3._printedDigits.some(function (e) {
if (_this4._printedDigits.some(function (e) {
return e === num;
})) {
var nextVertex = _this3.vertices.find(function (e) {
var nextVertex = _this4.vertices.find(function (e) {
return e.digits.includes(num) && e.id !== vertex.id;
});
var intersection = vertex.edges.filter(function (element) {
return nextVertex.edges.includes(element);
});

if (intersection.length > 0) {
var bond = _this3.edges[intersection[0]].bondType;
var bond = _this4.edges[intersection[0]].bondType;
if (bond !== '-') {
numbers += bond;
}
}
}

_this3._printedDigits.push(num);
_this4._printedDigits.push(num);
var numString = num.toString();
if (numString.length === 1) {
numbers += numString;
Expand Down
2 changes: 1 addition & 1 deletion dist/smiles-drawer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/smiles-drawer.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/ArrayHelper.html
Original file line number Diff line number Diff line change
Expand Up @@ -3333,7 +3333,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Mar 28 2019 09:34:43 GMT+0100 (GMT+01:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 22:40:27 GMT+0200 (GMT+02:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion doc/ArrayHelper.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ <h1 class="page-title">ArrayHelper.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Mar 28 2019 09:34:43 GMT+0100 (GMT+01:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 22:40:27 GMT+0200 (GMT+02:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion doc/Atom.html
Original file line number Diff line number Diff line change
Expand Up @@ -2853,7 +2853,7 @@ <h4 class="name" id="restoreRings"><span class="type-signature"></span>restoreRi
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Mar 28 2019 09:34:43 GMT+0100 (GMT+01:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 22:40:27 GMT+0200 (GMT+02:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion doc/Atom.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ <h1 class="page-title">Atom.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Mar 28 2019 09:34:43 GMT+0100 (GMT+01:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 22:40:27 GMT+0200 (GMT+02:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion doc/CanvasWrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -3718,7 +3718,7 @@ <h5>Parameters:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Mar 28 2019 09:34:43 GMT+0100 (GMT+01:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 22:40:27 GMT+0200 (GMT+02:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion doc/CanvasWrapper.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ <h1 class="page-title">CanvasWrapper.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Mar 28 2019 09:34:43 GMT+0100 (GMT+01:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 22:40:27 GMT+0200 (GMT+02:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion doc/DecayPoint.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h1 class="page-title">DecayPoint.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Mar 28 2019 09:34:43 GMT+0100 (GMT+01:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 22:40:27 GMT+0200 (GMT+02:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
Loading

0 comments on commit 5cf22a6

Please sign in to comment.