Skip to content

Commit

Permalink
added option to assume the chiral flag to be true in SDFileParser
Browse files Browse the repository at this point in the history
  • Loading branch information
thsa committed Dec 7, 2024
1 parent e5b0f0e commit b9572c4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/com/actelion/research/chem/io/SDFileParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class SDFileParser extends CompoundFileParser {
private String[] mFieldName;
private String[] mFieldData;
private int mNoOfRecords,mIDFieldIndex;
private boolean mAssumeChiralTrue;

public SDFileParser(String fileName) {
this(fileName, null);
Expand Down Expand Up @@ -105,6 +106,17 @@ public SDFileParser(Reader reader, String[] fieldName) {
}


/**
* Some software exports mol/sd-files with an unset chiral flag despite
* the original molecule is a pure enantiomer. This method allows the
* MolfileParser to override the molfile's chiral flag for such cases.
* @param b
*/
public void setAssumeChiralTrue(boolean b) {
mAssumeChiralTrue = b;
}


private void init() {
mMolfileBuffer = new StringBuilder(10240);
mDataBuffer = new StringBuilder(10240);
Expand Down Expand Up @@ -269,7 +281,11 @@ public StereoMolecule getMolecule() {
if (mMol != null)
return mMol;

mMol = new MolfileParser().getCompactMolecule(getNextMolFile());
MolfileParser molfileParser = new MolfileParser();
if (mAssumeChiralTrue)
molfileParser.setAssumeChiralTrue(true);

mMol = molfileParser.getCompactMolecule(getNextMolFile());
if (mMol != null && (mMol.getName() == null || mMol.getName().length() == 0))
mMol.setName(getMoleculeName());
return mMol;
Expand Down

0 comments on commit b9572c4

Please sign in to comment.