Problem assigning Partial Charges with OBChargeModel

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem assigning Partial Charges with OBChargeModel

Marcelino Arciniega
Hi all,

I am having problems to assing Partial Charges with OBChargeModel.
I basically copy and paste an example from:

http://openbabel.org/dev-api/classOpenBabel_1_1OBChargeModel.shtml

but it is not working.
Can someone please tell me where is my mistake? (the code is here bellow)

Thanks,

Marcelino

include <iostream>
#include <openbabel/obconversion.h>
#include <openbabel/mol.h>
#include <openbabel/chargemodel.h>
#include <openbabel/forcefield.h>

using namespace OpenBabel;
using namespace std;

int main(int argc,char **argv)
{
  OBConversion obconversion;
  obconversion.SetInFormat("mol2");
  OBMol mol;

  bool notatend = obconversion.ReadFile(&mol,"../structures/colorantes.mol2");
  while (notatend)
  {
    OBChargeModel *mmffCharges = OBChargeModel::FindType("mmff94");
    std::vector<double> partialCharges;
    if (mmffCharges && mmffCharges->ComputeCharges(mol)) {
      partialCharges = mmffCharges->GetPartialCharges();
      cout << " Charges were assigned " << endl;
    }

    mol.Clear();
    notatend = obconversion.Read(&mol);
  }

  return(0);
}


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://sdm.link/zohomanageengine
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Problem assigning Partial Charges with OBChargeModel

Fredrik Wallner
Hi,

To be able to give a good answer, you should at least provide two more pieces of information. The most important is what you mean by ”not working”, what exactly is the problem. The second is the example file you are using.

However, a probable guess is that there is a problem with the plugins, usually due to errors in the configuration of shared directories. Have you double checked that OBChargeModel *mmffCharges = OBChargeModel::FindType("mmff94”); returns anything other than nil?

Kind regards,
Fredrik

20 juni 2016 kl. 20:37 skrev Marcelino Arciniega <[hidden email]>:

Hi all, 

I am having problems to assing Partial Charges with OBChargeModel.
I basically copy and paste an example from:

http://openbabel.org/dev-api/classOpenBabel_1_1OBChargeModel.shtml

but it is not working. 
Can someone please tell me where is my mistake? (the code is here bellow)

Thanks,

Marcelino

include <iostream>
#include <openbabel/obconversion.h>
#include <openbabel/mol.h>
#include <openbabel/chargemodel.h>
#include <openbabel/forcefield.h>

using namespace OpenBabel;
using namespace std;

int main(int argc,char **argv)
{
  OBConversion obconversion;
  obconversion.SetInFormat("mol2");
  OBMol mol;

  bool notatend = obconversion.ReadFile(&mol,"../structures/colorantes.mol2");
  while (notatend)
  {
    OBChargeModel *mmffCharges = OBChargeModel::FindType("mmff94");
    std::vector<double> partialCharges;
    if (mmffCharges && mmffCharges->ComputeCharges(mol)) {
      partialCharges = mmffCharges->GetPartialCharges();
      cout << " Charges were assigned " << endl;
    }

    mol.Clear();
    notatend = obconversion.Read(&mol);
  }

  return(0);
}

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://sdm.link/zohomanageengine_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://sdm.link/zohomanageengine
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Problem assigning Partial Charges with OBChargeModel

Marcelino Arciniega
In reply to this post by Marcelino Arciniega
Hi Fredrik,

Thanks for your reply and I am sorry for my poor posting.
What I mean by "not working", is that no charges are being loaded. I did try with other force fields without success.

The example that I was refering to is this one:
  OBMol inputMolecule;
  OBChargeModel *mmffCharges = OBChargeModel::FindType("mmff94");
  const std::vector<double> partialCharges;
  if (mmffCharges && mmffCharges->ComputeCharges(inputMolecule)) {
    partialCharges = mmffCharges->GetPartialCharges();
  }

Could you please give a futher hint regarding where to check the possible error in the shared directories?

Thansk in advance,

Marcelino


De: "Fredrik Wallner" <[hidden email]>
Para: "Marcelino Arciniega" <[hidden email]>
CC: [hidden email]
Enviados: Lunes, 20 de Junio 2016 14:58:18
Asunto: Re: [Open Babel] Problem assigning Partial Charges with OBChargeModel

Hi,

To be able to give a good answer, you should at least provide two more pieces of information. The most important is what you mean by ”not working”, what exactly is the problem. The second is the example file you are using.

However, a probable guess is that there is a problem with the plugins, usually due to errors in the configuration of shared directories. Have you double checked that OBChargeModel *mmffCharges = OBChargeModel::FindType("mmff94”); returns anything other than nil?

Kind regards,
Fredrik

20 juni 2016 kl. 20:37 skrev Marcelino Arciniega <[hidden email]>:

Hi all, 

I am having problems to assing Partial Charges with OBChargeModel.
I basically copy and paste an example from:

http://openbabel.org/dev-api/classOpenBabel_1_1OBChargeModel.shtml

but it is not working. 
Can someone please tell me where is my mistake? (the code is here bellow)

Thanks,

Marcelino

include <iostream>
#include <openbabel/obconversion.h>
#include <openbabel/mol.h>
#include <openbabel/chargemodel.h>
#include <openbabel/forcefield.h>

using namespace OpenBabel;
using namespace std;

int main(int argc,char **argv)
{
  OBConversion obconversion;
  obconversion.SetInFormat("mol2");
  OBMol mol;

  bool notatend = obconversion.ReadFile(&mol,"../structures/colorantes.mol2");
  while (notatend)
  {
    OBChargeModel *mmffCharges = OBChargeModel::FindType("mmff94");
    std::vector<double> partialCharges;
    if (mmffCharges && mmffCharges->ComputeCharges(mol)) {
      partialCharges = mmffCharges->GetPartialCharges();
      cout << " Charges were assigned " << endl;
    }

    mol.Clear();
    notatend = obconversion.Read(&mol);
  }

  return(0);
}

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://sdm.link/zohomanageengine_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss



------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Problem assigning Partial Charges with OBChargeModel

Geoff Hutchison
In reply to this post by Marcelino Arciniega
Beyond Fredrik's answer, I'd suggest trying first from the command-line:

obabel -L charges
# should print a bunch of charge models
obabel structures/colorantes.mol2 -omol2 --partialcharge mmff94
# should print a mol2 file with assigned mmff94 charges

Assuming *that* works, then I'd go to code.

-Geoff

---
Prof. Geoffrey Hutchison
Department of Chemistry
University of Pittsburgh
tel: (412) 648-0492
email: [hidden email]
web: http://hutchison.chem.pitt.edu/


> On Jun 20, 2016, at 2:37 PM, Marcelino Arciniega <[hidden email]> wrote:
>
> Hi all,
>
> I am having problems to assing Partial Charges with OBChargeModel.
> I basically copy and paste an example from:
>
> http://openbabel.org/dev-api/classOpenBabel_1_1OBChargeModel.shtml
>
> but it is not working.
> Can someone please tell me where is my mistake? (the code is here bellow)
>
> Thanks,
>
> Marcelino
>
> include <iostream>
> #include <openbabel/obconversion.h>
> #include <openbabel/mol.h>
> #include <openbabel/chargemodel.h>
> #include <openbabel/forcefield.h>
>
> using namespace OpenBabel;
> using namespace std;
>
> int main(int argc,char **argv)
> {
>   OBConversion obconversion;
>   obconversion.SetInFormat("mol2");
>   OBMol mol;
>
>   bool notatend = obconversion.ReadFile(&mol,"../structures/colorantes.mol2");
>   while (notatend)
>   {
>     OBChargeModel *mmffCharges = OBChargeModel::FindType("mmff94");
>     std::vector<double> partialCharges;
>     if (mmffCharges && mmffCharges->ComputeCharges(mol)) {
>       partialCharges = mmffCharges->GetPartialCharges();
>       cout << " Charges were assigned " << endl;
>     }
>
>     mol.Clear();
>     notatend = obconversion.Read(&mol);
>   }
>
>   return(0);
> }
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
> reports. http://sdm.link/zohomanageengine_______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss


------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: {Spam?} Re: Problem assigning Partial Charges with OBChargeModel

Marcelino Arciniega
Hi Geoffrey,

thanks a lot for your help. Certainly  obabel was able to assing mmff94 charges.
However, my orginal intention is to compute the dipolar moment, that why was trying to
write small script. Thus, Im really interested in knowing:

why this OBChargeModel is not assigning the charges?

OBChargeModel *mmffCharges = OBChargeModel::FindType("mmff94");
std::vector<double> partialCharges;
if (mmffCharges && mmffCharges->ComputeCharges(mol)) {
       partialCharges = mmffCharges->GetPartialCharges();
       cout << " Charges were assigned " << endl;
}

Could you please hint where should I start looking to solve this issue?

Thanks a lot,

Marcelino


From: "Geoffrey Hutchison" <[hidden email]>
To: "Marcelino Arciniega" <[hidden email]>
Cc: [hidden email]
Sent: Tuesday, June 21, 2016 3:38:31 PM
Subject: {Spam?}  Re: [Open Babel] Problem assigning Partial Charges with OBChargeModel

Beyond Fredrik's answer, I'd suggest trying first from the command-line:

obabel -L charges
# should print a bunch of charge models
obabel structures/colorantes.mol2 -omol2 --partialcharge mmff94
# should print a mol2 file with assigned mmff94 charges

Assuming *that* works, then I'd go to code.

-Geoff

---
Prof. Geoffrey Hutchison
Department of Chemistry
University of Pittsburgh
tel: (412) 648-0492
email: [hidden email]
web: http://hutchison.chem.pitt.edu/


> On Jun 20, 2016, at 2:37 PM, Marcelino Arciniega <[hidden email]> wrote:
>
> Hi all,
>
> I am having problems to assing Partial Charges with OBChargeModel.
> I basically copy and paste an example from:
>
> http://openbabel.org/dev-api/classOpenBabel_1_1OBChargeModel.shtml
>
> but it is not working.
> Can someone please tell me where is my mistake? (the code is here bellow)
>
> Thanks,
>
> Marcelino
>
> include <iostream>
> #include <openbabel/obconversion.h>
> #include <openbabel/mol.h>
> #include <openbabel/chargemodel.h>
> #include <openbabel/forcefield.h>
>
> using namespace OpenBabel;
> using namespace std;
>
> int main(int argc,char **argv)
> {
>   OBConversion obconversion;
>   obconversion.SetInFormat("mol2");
>   OBMol mol;
>
>   bool notatend = obconversion.ReadFile(&mol,"../structures/colorantes.mol2");
>   while (notatend)
>   {
>     OBChargeModel *mmffCharges = OBChargeModel::FindType("mmff94");
>     std::vector<double> partialCharges;
>     if (mmffCharges && mmffCharges->ComputeCharges(mol)) {
>       partialCharges = mmffCharges->GetPartialCharges();
>       cout << " Charges were assigned " << endl;
>     }
>
>     mol.Clear();
>     notatend = obconversion.Read(&mol);
>   }
>
>   return(0);
> }
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
> reports. http://sdm.link/zohomanageengine_______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss



------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: {Spam?} Re: Problem assigning Partial Charges with OBChargeModel

Geoff Hutchison
> if (mmffCharges && mmffCharges->ComputeCharges(mol)) {


Practical Real-Life Debugging experience says "check each part of this && statement" and see which one of them is failing.

So? Which one? Is the mmffCharges object not created? Or can it not compute charges?

If it's not created, I'd make sure that you've created an OBConversion object somewhere. In older versions, all plugins (including charges and force fields) are loaded on creating an OBConversion object, but not before.

Hope that helps,
-Geoff


------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss