Permalink
Browse files

Added roundtripping for IAtomType.formalCharge

  • Loading branch information...
1 parent 96cffcc commit b1396a2ca2fb3b0977d6735efcc9e0c52826ce31 @egonw egonw committed Oct 8, 2009
@@ -73,5 +73,6 @@ private static final Property property(String local) {
public static final Property hasHybridization = property("hasHybridization");
public static final Property hasAtomTypeName = property("hasAtomTypeName");
public static final Property hasMaxBondOrder = property("hasMaxBondOrder");
+ public static final Property hasFormalCharge = property("hasFormalCharge");
}
@@ -155,6 +155,12 @@ private static void serializeAtomTypeFields(Model model,
if (type.getAtomTypeName() != null) {
model.add(rdfObject, CDK.hasAtomTypeName, type.getAtomTypeName());
}
+ if (type.getFormalCharge() != null) {
+ model.add(
+ rdfObject, CDK.hasFormalCharge,
+ type.getFormalCharge().toString()
+ );
+ }
if (type.getMaxBondOrder() != null) {
model.add(
rdfObject, CDK.hasMaxBondOrder,
@@ -200,6 +206,9 @@ private static void deserializeAtomTypeFields(
Resource maxOrder = (Resource)order.getResource();
element.setMaxBondOrder(resource2Order(maxOrder));
}
+ Statement formalCharge = rdfObject.getProperty(CDK.hasFormalCharge);
+ if (formalCharge != null)
+ element.setFormalCharge(formalCharge.getInt());
}
public static Order resource2Order(Resource rdfOrder) {
@@ -114,6 +114,7 @@ private void roundtripBond_Order(IBond.Order order) {
IMolecule mol = new NNMolecule();
IAtom object = new NNAtom("C");
object.setAtomTypeName("C.sp3");
+ object.setFormalCharge(+1);
mol.addAtom(object);
Model model = Convertor.molecule2Model(mol);
IMolecule rtMol = Convertor.model2Molecule(model, builder);

0 comments on commit b1396a2

Please sign in to comment.