Skip to content

Commit d7df812

Browse files
committed
Make map index (mapidx) a first class property of an atom.
1 parent 39549c0 commit d7df812

File tree

6 files changed

+249
-181
lines changed
  • base
    • core/src/main/java/org/openscience/cdk
    • data/src/main/java/org/openscience/cdk
    • interfaces/src/main/java/org/openscience/cdk/interfaces
    • isomorphism/src/main/java/org/openscience/cdk/isomorphism/matchers
    • silent/src/main/java/org/openscience/cdk/silent
  • descriptor/cip/src/main/java/org/openscience/cdk/geometry/cip

6 files changed

+249
-181
lines changed

base/core/src/main/java/org/openscience/cdk/AtomRef.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,17 @@ public void setIsInRing(boolean ring) {
442442
atom.setIsInRing(ring);
443443
}
444444

445+
446+
@Override
447+
public int getMapIdx() {
448+
return atom.getMapIdx();
449+
}
450+
451+
@Override
452+
public void setMapIdx(int mapidx) {
453+
atom.setMapIdx(mapidx);
454+
}
455+
445456
@Override
446457
public int hashCode() {
447458
return atom.hashCode();

base/data/src/main/java/org/openscience/cdk/Atom.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,21 @@ public void setIsInRing(boolean ring) {
490490
setFlag(CDKConstants.ISINRING, ring);
491491
}
492492

493+
@Override
494+
public int getMapIdx() {
495+
Integer mapidx = getProperty(CDKConstants.ATOM_ATOM_MAPPING);
496+
if (mapidx == null)
497+
return 0;
498+
return mapidx;
499+
}
500+
501+
@Override
502+
public void setMapIdx(int mapidx) {
503+
if (mapidx < 0)
504+
throw new IllegalArgumentException("setMapIdx(val) value must be >= 0");
505+
setProperty(CDKConstants.ATOM_ATOM_MAPPING, mapidx);
506+
}
507+
493508
/**
494509
* Returns a one line string representation of this Atom.
495510
* Methods is conform RFC #9.

base/interfaces/src/main/java/org/openscience/cdk/interfaces/IAtom.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,20 @@ public interface IAtom extends IAtomType {
256256
*/
257257
void setIsInRing(boolean ring);
258258

259+
/**
260+
* Access the map index for this atom.
261+
*
262+
* @return the map index (0 if not set)
263+
*/
264+
int getMapIdx();
265+
266+
/**
267+
* Set the map index for this atom.
268+
*
269+
* @param mapidx the new map index
270+
*/
271+
void setMapIdx(int mapidx);
272+
259273
/**
260274
* {@inheritDoc}
261275
*/

0 commit comments

Comments
 (0)