Re: [Open Babel] charge wrongly calculated
Is this list still alive? On Wed, 8 Aug 2012 10:26:57 +0100 Hannes Loeffler wrote: > Hi, > > the following script reads the attached mol2 file but wrongly outputs > 0 for the charge. Openbabel is version 2.3. > > import pybel > mol = pybel.readfile('mol2', 'amm.mol2').next() > print mol.charge > > I think it should be obvious from the N.4 Sybyl atom type that there > must be a charge. The sum of charges in the mol2 file also adds up to > +1. > > Is there a way to force recalculation of charges? > > Thanks, > Hannes. -- Scanned by iCritical. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
[Open Babel] How to do this with Python?
Hi, how would I do the following in Python? babel -imol2 a.mol2 b.mol2 -osdf ab.sdf Obviously I need to convert two mol2 files and combined them in a single sdf. Thanks, Hannes. -- Scanned by iCritical. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Re: [Open Babel] How to do this with Python?
Thanks a lot Noel. I just looked through the Pybel code. Assuming I wanted to do all that directly I could do the following (ignoring any safe guards for the moment), right? import openbabel as ob conv = ob.OBConversion() conv.SetInAndOutFormats('mol2', 'sdf') m1 = ob.OBMol() m2 = ob.OBMol() conv.ReadFile(m1, 'test.mol2') conv.Read(m2) conv.WriteFile(m1, 'test.sdf') conv.Write(m2) conv.CloseOutFile() On Tue, 9 Oct 2012 15:04:23 +0100 Noel O'Boyle wrote: > Hello Hannes, > > You need to use the readfile method for reading, and Outputfile class > for writing. If you cannot figure it out, post some code here and I > will correct it. > > - Noel > > On 8 October 2012 11:08, Hannes Loeffler > wrote: > > Hi, > > > > how would I do the following in Python? > > > > babel -imol2 a.mol2 b.mol2 -osdf ab.sdf > > > > > > Obviously I need to convert two mol2 files and combined them in a > > single sdf. > > > > Thanks, > > Hannes. > > -- > > Scanned by iCritical. > > > > -- > > Don't let slow site performance ruin your business. Deploy New > > Relic APM Deploy New Relic app performance management and know > > exactly what is happening inside your Ruby, Python, PHP, Java, > > and .NET app Try New Relic at no cost today and get our sweet Data > > Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev > > ___ > > OpenBabel-discuss mailing list > > OpenBabel-discuss@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss -- Scanned by iCritical. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
[Open Babel] missing attributes in 2.3.2 (Python)
Hi, I compiled 2.3.2 but find that some classes, e.g. OBAlign, and possibly other stuff is absent from openbabel.py. I passed -DRUN_SWIG=ON to cmake and swig does create openbabel.py. The other odd thing is that 'make install' copies openbabel.py, pybel.py and _openbabel.so into $CMAKE_INSTALL_PREFIX/lib instead of the relevant Python directory. Cheers, Hannes. -- Scanned by iCritical. -- Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report. http://p.sf.net/sfu/symantec-dev2dev ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Re: [Open Babel] missing attributes in 2.3.2 (Python)
Hi Noel, On Thu, 14 Mar 2013 21:41:31 + Noel O'Boyle wrote: > (Please cc to the list) > > It looks like when the bindings were generated for release, Eigen2 was > not present. You will have to run Swig yourself to regenerate the > bindings I'm afraid. It's pretty straightforward though. You should > download and compile the latest version of Swig (or if you're feeling > lucky, just use the Swig provided by your package manager). Then > configure CMake with -DRUN_SWIG=TRUE -DSWIG_EXECUTABLE=wherever. I had that all along. I have just found the real issue. SWIG is not called with -DHAVE_EIGEN -DHAVE_EIGEN3 when making the Python bindings because scripts/CMakeLists.txt tries to expand ${eigen2_define}, which appears to be not defined anywhere, instead of ${eigen_define} as in the Java case. Cheers, Hannes. > On 12 March 2013 13:52, Hannes Loeffler > wrote: > > Thanks a lot for your quick reply. > > > > I do have Eigen3. Cmake automatically detected it and set > > EIGEN3_INCLUDE_DIR accordingly. I also see that math/align.o is > > built and linked into libopenbabel.so.4.0.2. Likewise with > > ops/opalign.o. > > > > > > On Tue, 12 Mar 2013 13:25:04 + > > Noel O'Boyle wrote: > > > >> 1. Eigen3 is required for some classes such as OBAlign. See the > >> install docs. 2. The "make install" is installing the files to > >> where we expect. It's not possible for us to figure out in the > >> general case where Python would install things (I regard this as a > >> failure on Python's side, rather than ours). Just set your > >> PYTHONPATH and all will be well. > >> > >> - Noel > >> > >> On 12 March 2013 13:13, Hannes Loeffler > >> wrote: > >> > Hi, > >> > > >> > I compiled 2.3.2 but find that some classes, e.g. OBAlign, and > >> > possibly other stuff is absent from openbabel.py. I passed > >> > -DRUN_SWIG=ON to cmake and swig does create openbabel.py. > >> > > >> > The other odd thing is that 'make install' copies openbabel.py, > >> > pybel.py and _openbabel.so into $CMAKE_INSTALL_PREFIX/lib > >> > instead of the relevant Python directory. > >> > > >> > Cheers, > >> > Hannes. > >> > -- > >> > Scanned by iCritical. > >> > > >> > -- > >> > Symantec Endpoint Protection 12 positioned as A LEADER in The > >> > Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a > >> > good choice" in the endpoint security space. For insight on > >> > selecting the right partner to tackle endpoint security > >> > challenges, access the full report. > >> > http://p.sf.net/sfu/symantec-dev2dev > >> > ___ > >> > OpenBabel-discuss mailing list > >> > OpenBabel-discuss@lists.sourceforge.net > >> > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss > > > > -- > > Scanned by iCritical. -- Scanned by iCritical. -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
[Open Babel] SetName appends residue number to residue name in MOL2
Hi, I have the following Python code to rename the first residue in a PDB file. The renaming works except that OpenBabel appends a '1', obviously the residue number, to the new name in the mol2 output. How can I force OpenBabel to stop altering my residue name? import pybel mol = pybel.readfile('pdb', 'test.pdb').next() obmol = mol.OBMol res1 = obmol.GetResidue(0) res1.SetName('FOOBAR') # appends '1' to 'FOOBAR' mol.write('mol2', 'test.mol2', overwrite = True) Cheers, Hannes. -- Scanned by iCritical. import pybel mol = pybel.readfile('pdb', 'test.pdb').next() obmol = mol.OBMol res1 = obmol.GetResidue(0) res1.SetName('FO') mol.write('mol2', 'test.mol2', overwrite = True) test.pdb Description: application/palm-database -- November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
[Open Babel] mol2 writer adds residue number to residue name
Hi, here is something that has bugged me for some time now and is quite an annoying misfeature of MOL2Format::WriteMolecule(). In line 591 of src/formats/mol2format.cpp (checked out just a minute ago) the residue name is appended with its number (res->GetNum()). The practical problem is that whenever I change the residue name to a desired string in my Python script I get a modified residue on output. This is obviously exacerbated by multiple read/writes. If this is really a vital option to some I think it should be possible to switch this off with a write option. Cheers, Hannes. -- Scanned by iCritical. -- Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck® Code Sight™ - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Re: [Open Babel] mol2 writer adds residue number to residue name
In case anybody is willing I have attached a patch. This introduces a new option 'r' which, when set, switches off residue number appending unless 'l' is also set and residue name is simply '<1>'. The defaults are as they used to be. On Mon, 14 Jul 2014 12:03:45 +0100 Hannes Loeffler wrote: > Hi, > > here is something that has bugged me for some time now and is quite an > annoying misfeature of MOL2Format::WriteMolecule(). In line 591 of > src/formats/mol2format.cpp (checked out just a minute ago) the residue > name is appended with its number (res->GetNum()). > > The practical problem is that whenever I change the residue name to a > desired string in my Python script I get a modified residue on > output. This is obviously exacerbated by multiple read/writes. > > If this is really a vital option to some I think it should be possible > to switch this off with a write option. > > Cheers, > Hannes. -- Scanned by iCritical. --- mol2format.cpp.orig 2014-07-23 13:37:43.0 +0100 +++ mol2format.cpp 2014-07-23 13:44:59.0 +0100 @@ -34,6 +34,7 @@ OBConversion::RegisterFormat("ml2",this); OBConversion::RegisterFormat("sy2",this); OBConversion::RegisterOptionParam("l", NULL, 0, OBConversion::OUTOPTIONS); + OBConversion::RegisterOptionParam("r", NULL, 0, OBConversion::OUTOPTIONS); } virtual const char* Description() //required @@ -42,6 +43,7 @@ "Sybyl Mol2 format\n" "Write Options e.g. -xl\n" " l Output ignores residue information (only ligands)\n\n"; +" r Output does not append residue number to residue name\n\n"; }; virtual const char* SpecificationURL() @@ -503,6 +505,7 @@ ostream &ofs = *pConv->GetOutStream(); OBMol &mol = *pmol; bool ligandsOnly = pConv->IsOption("l", OBConversion::OUTOPTIONS)!=NULL; +bool resNum = pConv->IsOption("r", OBConversion::OUTOPTIONS)!=NULL; //The old code follows string str,str1; @@ -588,7 +591,11 @@ // use original atom names defined by residue snprintf(label,BUFF_SIZE,"%s",(char*)res->GetAtomID(atom).c_str()); // make sure that residue name includes its number -snprintf(rlabel,BUFF_SIZE,"%s%d",res->GetName().c_str(), res->GetNum()); +if (resNum) { + snprintf(rlabel,BUFF_SIZE,"%s",res->GetName().c_str()); +} else { + snprintf(rlabel,BUFF_SIZE,"%s%d",res->GetName().c_str(), res->GetNum()); +} snprintf(rnum,BUFF_SIZE,"%d",res->GetNum()); } -- Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
[Open Babel] accessing and manipulating GAFF atom types?
Hi, I was wondering if there is currently a mechanism to read out and manipulate GAFF atom types. It looks to me that OBForceFieldGaff handles those types only internally while to the outside the internal force fields are presented. for atom in ob.OBMolAtomIter(mol): idx = atom.GetIdx() # can only handle internal types? if idx == 24 or idx == 26: atom.SetType('nb') # warning that type can't be translated # output is interal types only? print idx, atom.GetType() Many thanks, Hannes. -- Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
[Open Babel] get all matches with OBSmartsPattern?
Hi, I am trying to get all substructure matches with OBSmartsPattern but this doesn't seem to work as expected when explicit hydrogens are involved. The attached Python script calculates a MCS with the help of RDKit's implementation of fmcs. The MCS is created as SMARTS pattern (script uses pre-computed pattern if RDKit not available) which I want to use to find all possible matches. I run fmcs in topological mode i.e. without any atom or bond type information. smi1 = 'n1c(N)c(N)ccc1' smi2 = 'n1c(Cl)c(N)ccc1' In the case where hydrogens are included (MCS is all atoms in smi2) I would expect four matches with the first molecule but get only two. The "Cl" in the MCS can match either Ns of smi1 (I only get this without hydrogens) and the two hydrogens added to the amino group can "flip" and thus give two additional matches (I only get this when hydrogens added for one Cl-to-N match). I guess I misunderstand how this is supposed to work. RDKit's GetSubstructMatches() gives me the same result. Many thanks, Hannes.try: import rdkit.Chem import rdkit.Chem.MCS have_rdkit = True except: have_rdkit = False import openbabel as ob addH = True smi1 = 'n1c(N)c(N)ccc1' smi2 = 'n1c(Cl)c(N)ccc1' if have_rdkit: mol1 = rdkit.Chem.MolFromSmiles(smi1) mol2 = rdkit.Chem.MolFromSmiles(smi2) if addH: mol1 = rdkit.Chem.AddHs(mol1) mol2 = rdkit.Chem.AddHs(mol2) mcs = rdkit.Chem.MCS.FindMCS( (mol1, mol2), maximize = 'atoms', atomCompare = 'any', bondCompare = 'any', completeRingsOnly = True) p = rdkit.Chem.MolFromSmarts(mcs.smarts) smarts = mcs.smarts print mcs.smarts, '\n' print '=== RDKit ===' for m1 in mol1.GetSubstructMatches(p, uniquify = False): print [i+1 for i in m1] print for m2 in mol2.GetSubstructMatches(p, uniquify = False): print [i+1 for i in m2] else: if addH: smarts = '[*]~@1~@[*](~@[*](~@[*](~!@[*])~@[*](~!@[*])~@[*]~@1~!@[*])~!@[*](~!@[*])~!@[*])~!@[*]' else: smarts = '[*]~@1~@[*](~@[*](~@[*]~@[*]~@[*]~@1)~!@[*])~!@[*]' print '\n=== OpenBabel ===' conv = ob.OBConversion() conv.SetInFormat('smiles') obmol1 = ob.OBMol() obmol2 = ob.OBMol() conv.ReadString(obmol1, smi1) conv.ReadString(obmol2, smi2) if addH: obmol1.AddHydrogens(False, False, 0.0) obmol2.AddHydrogens(False, False, 0.0) pat1 = ob.OBSmartsPattern() pat2 = ob.OBSmartsPattern() pat1.Init(smarts) pat2.Init(smarts) pat1.Match(obmol1) pat2.Match(obmol2) for m1 in pat1.GetMapList(): print m1 print for m2 in pat2.GetMapList(): print m2 -- Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss