Skip to content

Commit

Permalink
Merge pull request #321 from cdk/cleanup/AtomContainer
Browse files Browse the repository at this point in the history
OK, it's a large patch, but I could not spot big things. It looks like an API change to me, which is OK in a developers branch. Better now than in stable. But I'm also going to have to trust you that you explored the impact (which I'm sure you did)... that said, if it shows up trouble, we can always revert.
  • Loading branch information
egonw committed May 14, 2017
2 parents 780ee9e + abf7bd7 commit f2274f2
Show file tree
Hide file tree
Showing 73 changed files with 2,401 additions and 2,180 deletions.

Large diffs are not rendered by default.

Expand Up @@ -180,25 +180,25 @@ public void setBonds(IBond[] bonds) {}
public void setAtom(int number, IAtom atom) {}

@Override
public IAtom getAtom(int number) {
public IAtom getAtom(int idx) {
throw new UnsupportedOperationException(
"not supported");
}

@Override
public IBond getBond(int number) {
public IBond getBond(int idx) {
throw new UnsupportedOperationException(
"not supported");
}

@Override
public ILonePair getLonePair(int number) {
public ILonePair getLonePair(int idx) {
throw new UnsupportedOperationException(
"not supported");
}

@Override
public ISingleElectron getSingleElectron(int number) {
public ISingleElectron getSingleElectron(int idx) {
throw new UnsupportedOperationException(
"not supported");
}
Expand Down Expand Up @@ -375,7 +375,7 @@ public int getConnectedBondsCount(IAtom atom) {
}

@Override
public int getConnectedBondsCount(int atomnumber) {
public int getConnectedBondsCount(int idx) {
return 0;
}

Expand Down Expand Up @@ -444,12 +444,12 @@ public void remove(IAtomContainer atomContainer) {
}

@Override
public void removeAtom(int position) {
public void removeAtomOnly(int position) {

}

@Override
public void removeAtom(IAtom atom) {
public void removeAtomOnly(IAtom atom) {

}

Expand Down Expand Up @@ -508,11 +508,17 @@ public void removeElectronContainer(
}

@Override
public void removeAtomAndConnectedElectronContainers(
public void removeAtom(
IAtom atom) {

}

@Override
@Deprecated
public void removeAtomAndConnectedElectronContainers(IAtom atom) {

}

@Override
public void removeAllElements() {

Expand Down
Expand Up @@ -165,7 +165,7 @@ public static boolean depthFirstTargetSearch(IAtomContainer molecule, IAtom root
} else {
if (!depthFirstTargetSearch(molecule, nextAtom, target, path)) {
// we did not find the target
path.removeAtom(nextAtom);
path.removeAtomOnly(nextAtom);
path.removeBond(bond);
} else {
return true;
Expand Down
Expand Up @@ -202,7 +202,7 @@ public IAtomContainer getPath(IAtomContainer spt, IAtom atom1, IAtom atom2) thro
PathTools.resetFlags(spt);
path.addAtom(atom1);
PathTools.depthFirstTargetSearch(spt, atom1, atom2, path);
if (path.getAtomCount() == 1) path.removeAtom(atom1); // no path found: remove initial atom
if (path.getAtomCount() == 1) path.removeAtomOnly(atom1); // no path found: remove initial atom
return path;
}

Expand Down
Expand Up @@ -106,11 +106,17 @@ public IDoubleBondStereochemistry map(Map<IAtom, IAtom> atoms, Map<IBond, IBond>
if (bonds == null) throw new IllegalArgumentException("null bond mapping provided");

// map the double bond and the connected ligand bonds
IBond doubleBond = stereoBond != null ? bonds.get(stereoBond) : null;
IBond doubleBond = bonds.containsKey(stereoBond) ? bonds.get(stereoBond) : stereoBond;
IBond[] connected = new IBond[ligandBonds.length];

for (int i = 0; i < connected.length; i++) {
if (ligandBonds[i] != null) connected[i] = bonds.get(ligandBonds[i]);
if (ligandBonds[i] != null) {
IBond bond = bonds.get(ligandBonds[i]);
if (bond != null)
connected[i] = bond;
else
connected[i] = ligandBonds[i];
}
}

return new DoubleBondStereochemistry(doubleBond, connected, stereo);
Expand Down
Expand Up @@ -194,8 +194,15 @@ public boolean contains(IAtom atom) {
*/
@Override
public IStereoElement map(Map<IAtom, IAtom> atoms, Map<IBond, IBond> bonds) {
return new ExtendedTetrahedral(atoms.get(focus), new IAtom[]{atoms.get(peripherals[0]),
atoms.get(peripherals[1]), atoms.get(peripherals[2]), atoms.get(peripherals[3])}, winding);
IAtom focus = atoms.containsKey(this.focus) ? atoms.get(this.focus) : this.focus;
IAtom[] carriers = new IAtom[4];
for (int i = 0; i < 4; i++) {
IAtom newAtom = atoms.get(peripherals[i]);
carriers[i] = newAtom != null ? newAtom : peripherals[i];
}
return new ExtendedTetrahedral(focus,
carriers,
winding);
}

/**
Expand Down
Expand Up @@ -133,11 +133,17 @@ public ITetrahedralChirality map(Map<IAtom, IAtom> atoms, Map<IBond, IBond> bond
if (atoms == null) throw new IllegalArgumentException("null atom mapping provided");

// convert the chiral atom and it's ligands to their equivalent
IAtom chiral = chiralAtom != null ? atoms.get(chiralAtom) : null;
IAtom chiral = atoms.containsKey(chiralAtom) ? atoms.get(chiralAtom) : chiralAtom;
IAtom[] ligands = new IAtom[ligandAtoms.length];

for (int i = 0; i < ligands.length; i++) {
if (ligandAtoms[i] != null) ligands[i] = atoms.get(ligandAtoms[i]);
if (ligandAtoms[i] != null) {
IAtom atom = atoms.get(ligandAtoms[i]);
if (atom != null)
ligands[i] = atom;
else
ligands[i] = this.ligandAtoms[i];
}
}

// create a new tetrahedral instance with the mapped chiral atom and ligands
Expand Down

0 comments on commit f2274f2

Please sign in to comment.