Skip to content

Commit

Permalink
Merge pull request #7 from privrja/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
privrja authored Jan 23, 2019
2 parents e7cfd4e + 5b50a30 commit 08249ce
Show file tree
Hide file tree
Showing 35 changed files with 256 additions and 183 deletions.
78 changes: 50 additions & 28 deletions dist/smiles-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5786,7 +5786,6 @@ var Graph = function () {
this.decays = Array();
this.vertexIdsToEdgeId = {};
this.isomeric = isomeric;
this.isRing = false;

// Used for the bridge detection algorithm
this._time = 0;
Expand Down Expand Up @@ -6859,10 +6858,13 @@ var Graph = function () {
}, {
key: 'buildSmiles',
value: function buildSmiles() {
this.isRing = false;
var smiles = [];
this.dfsSmilesInitialization();
this.dfsBuildSmilesStart(smiles);
if (this.decays.length === 0) {
this.startDfs(this.vertices[0], smiles);
} else {
this.dfsBuildSmilesStart(smiles);
}
return smiles;
}

Expand All @@ -6874,14 +6876,6 @@ var Graph = function () {
}, {
key: 'dfsSmilesInitialization',
value: function dfsSmilesInitialization() {
for (var i = 0; i < this.vertices.length; ++i) {
this.vertices[i].vertexState = VertexState.VALUES.NOT_FOUND;
this.vertices[i].smilesNumbers = [];
}
}
}, {
key: 'dfsSmilesInitializationForSecondDfs',
value: function dfsSmilesInitializationForSecondDfs() {
for (var i = 0; i < this.vertices.length; ++i) {
this.vertices[i].vertexState = VertexState.VALUES.NOT_FOUND;
}
Expand Down Expand Up @@ -6933,11 +6927,27 @@ var Graph = function () {
if (vertex.vertexState !== VertexState.VALUES.NOT_FOUND) {
return;
}
stackSmiles.push(vertex.value.element + Graph.smilesNumbersAdd(vertex));

if (vertex.value.element === 'H') {
return;
}

if (vertex.value.isPartOfAromaticRing) {
stackSmiles.push(vertex.value.element.toLowerCase() + Graph.smilesNumbersAdd(vertex));
} else {
stackSmiles.push(vertex.value.element + Graph.smilesNumbersAdd(vertex));
}
vertex.vertexState = VertexState.VALUES.OPEN;
for (var i = 0; i < vertex.edges.length; ++i) {
var edge = this.edges[vertex.edges[i]];
if (edge.isDecay) continue;
if (edge.isDecay) {
if (vertex.value.element === "C") {
stackSmiles.push("(");
stackSmiles.push("O");
stackSmiles.push(")");
}
continue;
}
stackSmiles.push("(");
Graph.addBondTypeToStack(edge, stackSmiles);
var nextVertex = Graph.getProperVertex(vertex.id, edge.sourceId, edge.targetId);
Expand Down Expand Up @@ -7114,33 +7124,45 @@ var Graph = function () {
}, {
key: 'repairSmiles',
value: function repairSmiles(smiles, tmpRange, first, second, number) {
var pattern = new RegExp("^(Br|Cl|br|cl|[BCNOPSFIbcnopsfi])$");
var pattern = new RegExp("^(Br|Cl|[BCNOPSFIbcnopsfi])$");
if (pattern.test(tmpRange)) {
return this.removeNumbers(smiles, first, second);
}
var patternOrg = new RegExp("^(Br|Cl|br|cl|[BCNOPSFIbcnopsfi])");
var patternOrg = new RegExp("^(Br|Cl|[BCNOPSFIbcnopsfi])");
if (patternOrg.test(tmpRange)) {
return smiles;
}

while (tmpRange.length !== 0) {
switch (tmpRange[0]) {
case '(':
tmpRange = tmpRange.substring(1);
if (pattern.test(tmpRange)) {
return this.removeNumbers(smiles, first, second);
if (tmpRange[0] === '(') {
tmpRange = tmpRange.substring(1);
if (pattern.test(tmpRange)) {
return this.removeNumbers(smiles, first, second);
}
var leftBrackets = 1;
var rightBrackets = 0;
while (leftBrackets !== rightBrackets) {
switch (tmpRange[0]) {
case '(':
leftBrackets++;
break;
case ')':
rightBrackets++;
break;
}
if ("" === tmpRange) {
return smiles;
}
break;
case ')':
tmpRange = tmpRange.substring(1);
return this.repairSmiles(smiles, tmpRange, first, second, number);
default:
tmpRange = tmpRange.substring(1);
break;
}
return this.repairSmiles(smiles, tmpRange, first, second, number);
} else {
tmpRange = tmpRange.substring(1);
}
}
return smiles;
}

/**
* Substring in range and remove last Organic Subset
* @param smiles
Expand All @@ -7152,7 +7174,7 @@ var Graph = function () {
}, {
key: 'removeRangeLast',
value: function removeRangeLast(smiles, first, second) {
return smiles.substr(first + 1, second - first - 1);
return smiles.substring(first + 1, second);
}

/**
Expand Down Expand Up @@ -7217,7 +7239,7 @@ var Graph = function () {
if (num.length === 1) {
numbers += num;
} else {
numbers += '%' + num + '%';
numbers += '%' + num;
}
}
return numbers;
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 Sat Jan 19 2019 10:10:27 GMT+0100 (Střední Evropa (běžný čas)) 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 Wed Jan 23 2019 16:51:02 GMT+0100 (Střední Evropa (běžný čas)) 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 Sat Jan 19 2019 10:10:27 GMT+0100 (Střední Evropa (běžný čas)) 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 Wed Jan 23 2019 16:51:02 GMT+0100 (Střední Evropa (běžný čas)) 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 Sat Jan 19 2019 10:10:27 GMT+0100 (Střední Evropa (běžný čas)) 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 Wed Jan 23 2019 16:51:02 GMT+0100 (Střední Evropa (běžný čas)) 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 Sat Jan 19 2019 10:10:27 GMT+0100 (Střední Evropa (běžný čas)) 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 Wed Jan 23 2019 16:51:02 GMT+0100 (Střední Evropa (běžný čas)) 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 Sat Jan 19 2019 10:10:27 GMT+0100 (Střední Evropa (běžný čas)) 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 Wed Jan 23 2019 16:51:02 GMT+0100 (Střední Evropa (běžný čas)) 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 Sat Jan 19 2019 10:10:27 GMT+0100 (Střední Evropa (běžný čas)) 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 Wed Jan 23 2019 16:51:02 GMT+0100 (Střední Evropa (běžný čas)) 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 Sat Jan 19 2019 10:10:27 GMT+0100 (Střední Evropa (běžný čas)) 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 Wed Jan 23 2019 16:51:02 GMT+0100 (Střední Evropa (běžný čas)) 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/Drawer.html
Original file line number Diff line number Diff line change
Expand Up @@ -10711,7 +10711,7 @@ <h5>Parameters:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Jan 19 2019 10:10:27 GMT+0100 (Střední Evropa (běžný čas)) 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 Wed Jan 23 2019 16:51:02 GMT+0100 (Střední Evropa (běžný čas)) 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/Drawer.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -3203,7 +3203,7 @@ <h1 class="page-title">Drawer.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Jan 19 2019 10:10:27 GMT+0100 (Střední Evropa (běžný čas)) 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 Wed Jan 23 2019 16:51:02 GMT+0100 (Střední Evropa (běžný čas)) 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/Edge.html
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ <h5>Parameters:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Jan 19 2019 10:10:27 GMT+0100 (Střední Evropa (běžný čas)) 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 Wed Jan 23 2019 16:51:02 GMT+0100 (Střední Evropa (běžný čas)) 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/Edge.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ <h1 class="page-title">Edge.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Jan 19 2019 10:10:27 GMT+0100 (Střední Evropa (běžný čas)) 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 Wed Jan 23 2019 16:51:02 GMT+0100 (Střední Evropa (běžný čas)) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

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

0 comments on commit 08249ce

Please sign in to comment.