Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/casekit/nmr/analysis/HOSECodeShiftStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.bson.Document;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.layout.StructureDiagramGenerator;
import org.openscience.nmrshiftdb.util.AtomUtils;
import org.openscience.nmrshiftdb.util.ExtendedHOSECodeGenerator;
Expand All @@ -28,6 +29,8 @@ public class HOSECodeShiftStatistics {

private final static Gson GSON = new GsonBuilder().setLenient()
.create();
private final static StructureDiagramGenerator structureDiagramGenerator = new StructureDiagramGenerator();
private final static ExtendedHOSECodeGenerator extendedHOSECodeGenerator = new ExtendedHOSECodeGenerator();

public static Map<String, Map<String, List<Double>>> collectHOSECodeShifts(final List<DataSet> dataSetList,
final Integer maxSphere,
Expand Down Expand Up @@ -60,8 +63,6 @@ public static Map<String, Map<String, List<Double>>> collectHOSECodeShifts(final
public static boolean insert(final DataSet dataSet, final Integer maxSphere, final boolean use3D,
final boolean withExplicitH,
final Map<String, Map<String, List<Double>>> hoseCodeShifts) {
final StructureDiagramGenerator structureDiagramGenerator = new StructureDiagramGenerator();
final ExtendedHOSECodeGenerator extendedHOSECodeGenerator = new ExtendedHOSECodeGenerator();
final IAtomContainer structure;
Signal signal;
String hoseCode;
Expand Down Expand Up @@ -101,13 +102,32 @@ public static boolean insert(final DataSet dataSet, final Integer maxSphere, fin

if (use3D) {
try {
// store wedge bond information
final int[] ordinals = new int[structure.getBondCount()];
int k = 0;
for (final IBond bond : structure.bonds()) {
ordinals[k] = bond.getStereo()
.ordinal();
k++;
}
// set 2D coordinates
structureDiagramGenerator.setMolecule(structure);
structureDiagramGenerator.generateCoordinates(structure);
/* !!! No explicit H in mol !!! */
Utils.convertExplicitToImplicitHydrogens(structure);
/* add explicit H atoms */
AtomUtils.addAndPlaceHydrogens(structure);
// restore wedge bond information
k = 0;
for (final IBond bond : structure.bonds()) {
bond.setStereo(IBond.Stereo.values()[ordinals[k]]);

k++;
if (k
>= ordinals.length) {
break;
}
}
} catch (final CDKException | IOException | ClassNotFoundException e) {
e.printStackTrace();
}
Expand Down
6 changes: 4 additions & 2 deletions src/casekit/nmr/model/StructureCompact.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@Setter
public class StructureCompact {

private int[][][] bondProperties; // connected atom index, bond order, bond is in ring, bond is aromatic
private int[][][] bondProperties; // connected atom index, bond order, bond is in ring, bond is aromatic, bond stereo configuration
private Integer[][] atomProperties; // element symbol, hybridization, implicitHydrogenCount, valency, formalCharge, isInRingAtom, isAromaticAtom

public StructureCompact(final IAtomContainer ac) {
Expand All @@ -61,7 +61,8 @@ public StructureCompact(final IAtomContainer ac) {
? 1
: 0, bond.isAromatic()
? 1
: 0});
: 0,
bond.getStereo().ordinal()});
}
}
temp = new int[connectedAtomsList.size()][];
Expand Down Expand Up @@ -147,6 +148,7 @@ public IAtomContainer toAtomContainer() {
== 1);
bond.setIsAromatic(this.bondProperties[i][k][3]
== 1);
bond.setStereo(IBond.Stereo.values()[this.bondProperties[i][k][4]]);
ac.addBond(bond);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/casekit/nmr/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public static Float getBondOrderSum(final IAtomContainer ac, final int atomIndex
* @throws CDKException
*/
public static DataSet atomContainerToDataSet(final IAtomContainer structure) throws CDKException {
return atomContainerToDataSet(structure, true);
return atomContainerToDataSet(structure, false);
}

/**
Expand Down