Skip to content

Commit a2c8039

Browse files
committed
Pre-work we will store this info as an Sgroup.
1 parent e1ce193 commit a2c8039

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

base/core/src/main/java/org/openscience/cdk/sgroup/SgroupType.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ public enum SgroupType {
7676
CtabGeneric("GEN"),
7777

7878
// extension for handling positional variation and distributed coordination bonds
79-
ExtMulticenter("N/A");
79+
ExtMulticenter("_MAP", false),
80+
// extension for handling bond attachment, LO: in CXSMILES
81+
ExtAttachOrdering("_APO", false);
8082

8183

8284
static final Map<String, SgroupType> map = new HashMap<>();
@@ -86,12 +88,29 @@ public enum SgroupType {
8688
map.put(t.ctabKey, t);
8789
}
8890

89-
private final String ctabKey;
91+
private final String ctabKey;
92+
private final boolean ctabStandard;
9093

9194
SgroupType(String ctabKey) {
92-
this.ctabKey = ctabKey;
95+
this(ctabKey, true);
9396
}
9497

98+
SgroupType(String ctabKey, boolean ctabStandard) {
99+
this.ctabKey = ctabKey;
100+
this.ctabStandard = ctabStandard;
101+
}
102+
103+
104+
/**
105+
* Indicates if this SGroup type is support by standard CTAB
106+
* (Molfile/SDfile) sgroups.
107+
* @return true/false
108+
*/
109+
public boolean isCtabStandard() {
110+
return ctabStandard;
111+
}
112+
113+
95114
public String getKey() {
96115
return ctabKey;
97116
}

storage/ctab/src/main/java/org/openscience/cdk/io/MDLV2000Writer.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -912,11 +912,7 @@ private void writeSgroups(IAtomContainer container, BufferedWriter writer, Map<I
912912
sgroups = new ArrayList<>(sgroups);
913913

914914
// remove non-ctab Sgroups
915-
Iterator<Sgroup> iter = sgroups.iterator();
916-
while (iter.hasNext()) {
917-
if (iter.next().getType() == SgroupType.ExtMulticenter)
918-
iter.remove();
919-
}
915+
sgroups.removeIf(sgroup -> !sgroup.getType().isCtabStandard());
920916

921917
for (List<Sgroup> wrapSgroups : wrap(sgroups, 8)) {
922918
// Declare the SGroup type

storage/ctab/src/main/java/org/openscience/cdk/io/MDLV3000Writer.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -541,11 +541,7 @@ private void writeSgroupBlock(List<Sgroup> sgroups, Map<IChemObject, Integer> id
541541
sgroups = new ArrayList<>(sgroups);
542542

543543
// remove non-ctab Sgroups
544-
Iterator<Sgroup> iter = sgroups.iterator();
545-
while (iter.hasNext()) {
546-
if (iter.next().getType() == SgroupType.ExtMulticenter)
547-
iter.remove();
548-
}
544+
sgroups.removeIf(sgroup -> !sgroup.getType().isCtabStandard());
549545

550546
if (sgroups.isEmpty())
551547
return;
@@ -670,8 +666,8 @@ private void writeMol(IAtomContainer mol) throws IOException, CDKException {
670666
List<Sgroup> sgroups = getSgroups(mol);
671667

672668
int numSgroups = 0;
673-
for (int i = 0; i < sgroups.size(); i++)
674-
if (sgroups.get(i).getType() != SgroupType.ExtMulticenter)
669+
for (Sgroup sgroup : sgroups)
670+
if (sgroup.getType().isCtabStandard())
675671
numSgroups++;
676672

677673
writer.write("BEGIN CTAB\n");

0 commit comments

Comments
 (0)