Skip to content

Commit

Permalink
Output the chiral flag as absolute in V2000 molfiles if there is tetr…
Browse files Browse the repository at this point in the history
…ahedral centres present.
  • Loading branch information
johnmay committed Aug 8, 2017
1 parent 5851070 commit cfd5802
Showing 1 changed file with 12 additions and 9 deletions.
Expand Up @@ -360,22 +360,25 @@ public void writeMolecule(IAtomContainer container) throws Exception {
writer.write(comment);
writer.newLine();

// write Counts line
line += formatMDLInt(container.getAtomCount(), 3);
line += formatMDLInt(container.getBondCount(), 3);
line += " 0 0 0 0 0 0 0 0999 V2000";
writer.write(line);
writer.newLine();

// index stereo elements for setting atom parity values
Map<IAtom,ITetrahedralChirality> atomstereo = new HashMap<>();
Map<IAtom,Integer> atomindex = new HashMap<>();
for (IStereoElement element : container.stereoElements())
if (element instanceof ITetrahedralChirality)
atomstereo.put(((ITetrahedralChirality) element).getChiralAtom(), (ITetrahedralChirality) element);
if (element instanceof ITetrahedralChirality)
atomstereo.put(((ITetrahedralChirality) element).getChiralAtom(), (ITetrahedralChirality) element);
for (IAtom atom : container.atoms())
atomindex.put(atom, atomindex.size());

// write Counts line
line += formatMDLInt(container.getAtomCount(), 3);
line += formatMDLInt(container.getBondCount(), 3);
line += " 0 0";
// we mark all stereochemistry to absolute for now
line += atomstereo.isEmpty() ? " 0" : " 1";
line += "0 0 0 0 0999 V2000";
writer.write(line);
writer.newLine();

// write Atom block
for (int f = 0; f < container.getAtomCount(); f++) {
IAtom atom = container.getAtom(f);
Expand Down

0 comments on commit cfd5802

Please sign in to comment.