Try building in debug, and running it through gdb.

On 19 July 2011 00:08, Jimmy G Lafontaine Rivera <laf...@gmail.com> wrote:
> Hi, I have been unable to run a program correctly. I need the program to
> take a molecule from a SMILES string a perform a substructure search on it.
> I get the following error: "Access violation reading location 0x0081ffff". I
> am not sure if the problem was on the installation of the libraries or it's
> on the code. The program compiles properly, this is the code (it is taken
> from the examples):
>
> #include "stdafx.h"
> #include <stdio.h>
> #include <openbabel/parsmart.h>
> #include <openbabel/mol.h>
> #include <openbabel/atom.h>
> #include <openbabel/obconversion.h>
> using namespace OpenBabel;
> int main()
> {
> // Create an OBConversion object.
> OBConversion conv;
> // Set the input format.
> if (!conv.SetInFormat("inchi")) {
> // Handle error.
> return 1;
> }
> // Create the OBMol object.
> OBMol mol;
> // Read the smiles string.
> if (conv.ReadString(&mol, "1S/C2H2O3/c3-1-2(4)5/h1H,(H,4,5)")) {
>  //Always got error on this //line, but when I switched the input format to
> inchi the error moved to the line with sp.Init("CC");
> // Handle error.
> return 1;
> }
> std::cerr << mol.NumAtoms();
> OBAtom* atom;
> // Create a SMARTS pattern of a phenyl ring
> OBSmartsPattern sp;
> sp.Init("CC");        // Error is now obtained after the execution of this
> line
> // Properties of the substructure
> if (sp.IsValid())
> {
>   std::cout << sp.NumAtoms();
>   std::cout << sp.NumBonds();
>   //std::cout << sp.GetSmarts();
> }
> // Matching
> (bool) sp.Match(mol, true);  // Single matching
> (bool) sp.Match(mol, false); // Complete matching
> // Substructure mapping
> std::vector<std::vector<int> > mapListA;
> mapListA = sp.GetMapList(); // Non-unique matches
> std::vector<std::vector<int> > mapListU;
> mapListU = sp.GetUMapList(); // Unique matches
> for (int m(0); m < mapListU.size(); ++m)
> {
>   std::cout << "Unique match " << m << std::endl;
>   for (int a(0); a < mapListU[m].size(); ++a)
>   {
>  atom = mol.GetAtom(mapListU[m][a]);
>  std::cout << atom->GetAtomicNum() << std::endl;
>   }
> }
> return 0;
> }
>
>
>
> ------------------------------------------------------------------------------
> Storage Efficiency Calculator
> This modeling tool is based on patent-pending intellectual property that
> has been used successfully in hundreds of IBM storage optimization engage-
> ments, worldwide.  Store less, Store more with what you own, Move data to
> the right place. Try It Now!
> http://www.accelacomm.com/jaw/sfnl/114/51427378/
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>
>

------------------------------------------------------------------------------
10 Tips for Better Web Security
Learn 10 ways to better secure your business today. Topics covered include:
Web security, SSL, hacker attacks & Denial of Service (DoS), private keys,
security Microsoft Exchange, secure Instant Messaging, and much more.
http://www.accelacomm.com/jaw/sfnl/114/51426210/
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to