Permalink
Browse files

Added missing sulphur atom type as found in thiosulphonate (fixes #30…

…80848)

Signed-off-by: Rajarshi Guha <rajarshi.guha@gmail.com>
  • Loading branch information...
egonw authored and rajarshi committed Oct 21, 2010
1 parent 8df6674 commit 4ccb251ee0f94905071beeea2b1e56d968bda360
@@ -886,6 +886,12 @@ private IAtomType perceiveSulphurs(IAtomContainer atomContainer, IAtom atom)
IAtomType type = getAtomType("S.onyl");
if (isAcceptable(atom, atomContainer, type)) return type;
}
int doubleBondedSulphurs = countAttachedDoubleBonds(atomContainer, atom, "S");
if (doubleBondedSulphurs == 1 &&
doubleBondedOxygens == 1) {
IAtomType type = getAtomType("S.thionyl");
if (isAcceptable(atom, atomContainer, type)) return type;
}
IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom);
if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) {
IAtomType type = getAtomType("S.anyl");
@@ -1520,12 +1526,15 @@ private int countAttachedDoubleBonds(IAtomContainer container, IAtom atom, Strin
int neighborcount = neighbors.size();
int doubleBondedAtoms = 0;
for (int i=neighborcount-1;i>=0;i--) {
if (neighbors.get(i).getOrder() == CDKConstants.BONDORDER_DOUBLE) {
IBond bond = neighbors.get(i);
IBond bond = neighbors.get(i);
if (bond.getOrder() == CDKConstants.BONDORDER_DOUBLE) {
if (bond.getAtomCount() == 2 && bond.contains(atom)) {
if (symbol != null) {
if (bond.getAtom(0).getSymbol().equals(symbol) ||
bond.getAtom(1).getSymbol().equals(symbol)) {
// if other atom is a sulphur
if ((bond.getAtom(0) != atom &&
bond.getAtom(0).getSymbol().equals(symbol)) ||
(bond.getAtom(1) != atom &&
bond.getAtom(1).getSymbol().equals(symbol))) {
doubleBondedAtoms++;
}
} else {
@@ -660,6 +660,15 @@
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>
<at:AtomType rdf:ID="S.thionyl">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;S"/>
<at:formalNeighbourCount>4</at:formalNeighbourCount>
<at:lonePairCount>0</at:lonePairCount>
<at:piBondCount>2</at:piBondCount>
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>
<at:AtomType rdf:ID="S.onyl">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;S"/>
@@ -772,7 +772,7 @@ public void testTetrahydropyran() throws Exception {
String[] expectedTypes = {"S.2", "C.sp2", "C.sp3", "C.sp3"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
@Test public void testSulphuricAcid() throws Exception {
IMolecule mol = new Molecule();
IAtom atom = new Atom("O");
@@ -794,6 +794,35 @@ public void testTetrahydropyran() throws Exception {
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
/**
* @cdk.inchi InChI=1S/CH4O2S2/c1-5(2,3)4/h1H3,(H,2,3,4)
*/
@Test public void testThioSulphonate() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"S");
mol.addAtom(a1);
IAtom a2 = builder.newInstance(IAtom.class,"S");
mol.addAtom(a2);
IAtom a3 = builder.newInstance(IAtom.class,"O");
mol.addAtom(a3);
IAtom a4 = builder.newInstance(IAtom.class,"O");
mol.addAtom(a4);
IAtom a5 = builder.newInstance(IAtom.class,"C");
mol.addAtom(a5);
IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.DOUBLE);
mol.addBond(b1);
IBond b2 = builder.newInstance(IBond.class,a1, a3, IBond.Order.SINGLE);
mol.addBond(b2);
IBond b3 = builder.newInstance(IBond.class,a1, a4, IBond.Order.DOUBLE);
mol.addBond(b3);
IBond b4 = builder.newInstance(IBond.class,a1, a5, IBond.Order.SINGLE);
mol.addBond(b4);
String[] expectedTypes = {"S.thionyl", "S.2", "O.sp3", "O.sp2", "C.sp3"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
@Test public void testSulphuricAcid_Charged() throws Exception {
IMolecule mol = new Molecule();
IAtom atom = new Atom("O");

0 comments on commit 4ccb251

Please sign in to comment.