User b98d0d9f19
24-05-2016 16:13:52
Hi,
I am using MarvinBeans version 16.5.16.0 in Eclipse. I am attempting to extract atomic charges from a molecule (a particular major microspecies, to be precise), and as a consistency check I add up all atomic charges to see if they add up to the total charge of the microspecies. Strangely, this works for only about 90% of the molecules. Do you know why this would be the case?
The core of the code I'm using is:
ChargePlugin chargePlugin = new ChargePlugin();
MajorMicrospeciesPlugin mmsPlugin = new MajorMicrospeciesPlugin();
mmsPlugin.setpH(7.4); // major microspecies generation at pH = 7.4
MolImporter importer = new MolImporter("all_smiles.txt");
Molecule mol;
int molOn=0;
while ((mol = importer.read()) != null) {
molOn++;
mmsPlugin.setMolecule(mol);
mmsPlugin.run();
Molecule majorms = mmsPlugin.getMajorMicrospecies();
Hydrogenize.convertImplicitHToExplicit(majorms);
chargePlugin.setMolecule(majorms);
chargePlugin.run();
int count = majorms.getAtomCount();
double totalCharge=0;
for (int i=0; i < count; ++i) {
double charge = chargePlugin.getTotalCharge(i);
totalCharge+=charge;
}
System.out.println("sum of atomic charge for molecule "+(molOn)+" is "+totalCharge);
System.out.println("total charge: "+majorms.getTotalCharge());
It works for the SMILES inputs (for example):
COc1cc(OC)c(C(=O)CCCN2CCCC2)c(OC)c1
NC1CCN(C1)c1nc2n(cc(C(O)=O)c(=O)c2cc1F)-c1ccc(F)cc1F
But for:
Cc1[nH]cnc1CN1CCc2c(C1=O)c1ccccc1n2C
the sum of atomic charges is off by about 0.06. When I try more inputs, I find that about 90% of inputs give roughly the right answer (up to machine precision) whereas the other 10% are off by about 0.05-0.1 of a charge. Do you know what could be causing this?
Full code and input file attached.