Skip to content

Commit

Permalink
KETCHER-718 partial cleanup fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Kozhevnikov committed Jan 31, 2014
1 parent 7e3adad commit d300e4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions chem/struct.js
Expand Up @@ -110,10 +110,10 @@ chem.Struct.prototype.toLists = function ()
};
};

chem.Struct.prototype.clone = function (atomSet, bondSet, dropRxnSymbols)
chem.Struct.prototype.clone = function (atomSet, bondSet, dropRxnSymbols, aidMap)
{
var cp = new chem.Struct();
return this.mergeInto(cp, atomSet, bondSet, dropRxnSymbols);
return this.mergeInto(cp, atomSet, bondSet, dropRxnSymbols, false, aidMap);
};

chem.Struct.prototype.getScaffold = function () {
Expand Down Expand Up @@ -147,7 +147,7 @@ chem.Struct.prototype.getFragment = function (fid) {
return this.clone(this.getFragmentIds(fid));
};

chem.Struct.prototype.mergeInto = function (cp, atomSet, bondSet, dropRxnSymbols, keepAllRGroups)
chem.Struct.prototype.mergeInto = function (cp, atomSet, bondSet, dropRxnSymbols, keepAllRGroups, aidMap)
{
atomSet = atomSet || util.Set.keySetInt(this.atoms);
bondSet = bondSet || util.Set.keySetInt(this.bonds);
Expand Down Expand Up @@ -188,7 +188,8 @@ chem.Struct.prototype.mergeInto = function (cp, atomSet, bondSet, dropRxnSymbols
}
});

var aidMap = {};
if (typeof aidMap === 'undefined' || aidMap === null)
aidMap = {};
this.atoms.each(function(aid, atom) {
if (util.Set.contains(atomSet, aid))
aidMap[aid] = cp.atoms.add(atom.clone(fidMap));
Expand Down
4 changes: 3 additions & 1 deletion ui/ui.js
Expand Up @@ -1331,9 +1331,11 @@ ui.onClick_CleanUp = function ()
var selective = atoms.length > 0;
ui.editor.deselectAll();
try {
var mol = ui.ctab.clone();
var aidMap = {};
var mol = ui.ctab.clone(null, null, false, aidMap);
if (selective) {
util.each(atoms, function(aid){
aid = aidMap[aid];
var dsg = new chem.SGroup('DAT');
var dsgid = mol.sgroups.add(dsg);
dsg.id = dsgid;
Expand Down

0 comments on commit d300e4a

Please sign in to comment.