Re: [Open Babel] SMILES, SMARTS, and PDB
I think you need custom code. For python, you could use pybel. There are three lines that do what you want ( http://openbabel.org/docs/dev/UseTheLibrary/Python_PybelAPI.html#pybel.Smarts.findall). You only miss one or two lines to get the atoms by their indices. Although searching pdb files with it could be a demanding and time consuming task. It's really made for small molecules, i guess. I'd personally would loop through atoms check if they are HETATOMs and then check SMARTS pattern. Alternatively, you can filter them by name, if you can suspect what's your residues name could be (although it's the most error prone). Pozdrawiam, | Best regards, Maciek Wójcikowski mac...@wojcikowski.pl 2013/7/8 Brett Hannigan godot_gil...@yahoo.com Unfortunately, I don't think that's quite what I need. The obabel filter command will look at the given pdb and then output the entire pdb if it matches the given SMARTS query, right? What I would like to do is only get the atoms that match the SMARTS query. For example, let's say I have a pdb with a single phospho-serine residue. What I would like to do is get only the phosphate atoms from the pdb, and not get the rest of the residue atoms. Really what I am going for here is I'd like specify some groups that I find interesting, say a phosphate group, a phenyl group, etc. And then I have a database of protein + ligand pdbs. I'd like to loop through those pdbs and look for my groups that I am interested in. Rather than just identify the pdbs that have the sub-structure I am interested in (i.e. identify all pdbs with phosphates), I want to know which atoms in the pdb constitute the interesting sub-structure. That way I could then align all phosphate groups and look at the residues surrounding the phophates to see if I see common modes of binding etc. Phosphate would just be one example, you can imagine identifying many other interesting sub-structures. -Brett -- *From:* Maciek Wójcikowski mac...@wojcikowski.pl *To:* Brett T. Hannigan bret...@mail.med.upenn.edu *Cc:* openbabel-discuss@lists.sourceforge.net *Sent:* Saturday, July 6, 2013 6:21 AM *Subject:* Re: [Open Babel] SMILES, SMARTS, and PDB Hello, You can convert from PDB to PDB using filter option ( http://openbabel.org/wiki/--filter_option) obabel input.pdb -O output.pdb --filter s='CN' If your database is really large, or you want to search multiple times, then I'd suggest using FastSearch for performance reasons. For further lecture: http://openbabel.org/wiki/FastSearch Pozdrawiam, | Best regards, Maciek Wójcikowski mac...@wojcikowski.pl 2013/7/5 Brett T. Hannigan bret...@mail.med.upenn.edu I have a database of molecules in pdb files. I'd like to go through each molecule and see if it has certain substructures, and if they do identify which atoms are part of that substructure. So it's easy enough to read the pdb file in, convert it to SMILES representation, and then do a SMARTS query to look for my substructures. However, if the SMARTS query reports that the substructure is present in the molecule, I'm not sure how to identify the atoms in the pdb file which make up the match. Any ideas? -- ** Brett T. Hannigan 8011 Ardleigh St. Philadelphia, PA 19118 brett.hanni...@gmail.com ** -- This SF.net http://sf.net/ email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Re: [Open Babel] Segmentation fault in inchi conversion
I've fixed this. It's a minor change so you could apply it locally if you want. I just moved the call to DeleteHydrogens past the stereo section when reading the InChI: https://github.com/baoilleach/openbabel/commit/428ac8790d3b5307305912b892e9953c793b80dc - Noel On 26 June 2013 14:42, Jon Fuller jonathan.ful...@gmail.com wrote: Dear Chris and Fredrik, Thanks for the information regarding this problem. The solution that I've been using is to use an older version 2.3.0 to run my script. Additional thanks for the information about the differences between obabel and babel. Best, Jon On 26 June 2013 15:01, Chris Morley c.mor...@gaseq.co.uk wrote: I think this is due to a bug in the stereo perception code which appeared in v2.3.2 . It has been mentioned before on this and the development list but a fix is not yet committed to the development code. Version 2.3.1 works ok for me. Incidentally, prefer obabel to the older babel. obabel is safer with incorrect input and can handle commandline options with parameters much better than babel. Chris On 26/06/2013 11:57, Fredrik Wallner wrote: Hi, No, I never found a solution to this. I managed a workaround for the specific problem (although I cannot remember for sure I believe I accepted some help from ChemDraw…) so my needs fainted… Kind regards, Fredrik 25 jun 2013 kl. 14:33 skrev Jon Fuller jonathan.ful...@gmail.com mailto:jonathan.ful...@gmail.com: Hi Fredrik, Did you find a solution to this problem? I found a similar example: I pasted example code for pybel, but running the command below with both inchis in the file inchi.txt: babel -iinchi inchi.txt -osdf inchi.sdf Will result in Segmentation fault: 11 Remove the second inchi and the command works. mol1 = pybel.readstring(inchi, InChI=1S/C19H22N2O/c1-4-15-7-6-8-16(5-2)18(15)10-9-14-11-17(13-21-12-14)19(22)20-3/h6-13H,4-5H2,1-3H3,(H,20,22)/b10-9+) printmolecule one works mol2smiles = pybel.readstring(smiles, O=C(OC[C@H](\C3=C2/[C@@H](O[C@H]1O[C@@H]([C@@H](O)[C@H](OC(=O)C)[C@H]1O)COC(\C=C)(C)C)[C@H](O)[C@H](C)[C@H]4C(=C/[C@@]2(C)[C@@H](O)C3)\[C@@H](COC)CC4)C)C) printsmiles works for molecule two! print mol2smiles mol2inchichemspider = pybel.readstring(inchi, InChI=1S/C36H56O12/c1-10-35(6,7)45-17-26-30(41)33(46-21(5)38)31(42)34(47-26)48-32-28-24(18(2)15-44-20(4)37)13-27(39)36(28,8)14-25-22(16-43-9)11-12-23(25)19(3)29(32)40/h10,14,18-19,22-23,26-27,29-34,39-42H,1,11-13,15-17H2,2-9H3/b25-14-/t18-,19-,22-,23+,26-,27+,29-,30-,31-,32-,33+,34-,36+/m1/s1) printinchi does not work for molecule two print mol2inchichemspider Best, Jon On 11 April 2013 16:21, Fredrik Wallner fred...@wallner.nu mailto:fred...@wallner.nu wrote: Hi again, Some more information… The InChI InChI=1S/C8H12/c1-2-4-6-8-7-5-3-1/h1-2,7-8H,3-6H2/b2-1-,8-7- gives the same problem. I have now updated the ubuntu box to also run ob 2.3.2 and it segfaults now as well, so it seems it has something to do with differences between 2.3.1 and 2.3.2. Kind regards, Fredrik 11 apr 2013 kl. 14:45 skrev Fredrik Wallner fred...@wallner.nu mailto:fred...@wallner.nu: Hi, I get a segmentation fault when running the following command: obabel -iinchi -:InChI=1S/2C8H12.Ni/c2*1-2-4-6-8-7-5-3-1;/h2*1-2,7-8H,3-6H2;/b2*2-1-,8-7-; -osmi I'm running Open Babel 2.3.2 on a MacBook Pro, OSX 10.8.3 (installed via homerbrew). I have also tried it on an Ubuntu box (10.04.4) running ob 2.3.1 and here it's working without problem. Is there anyone else having problems with this, or is it just me? Kind regards, Fredrik -- Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net mailto:OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss -- Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis visualization. Get a free account!
Re: [Open Babel] SMILES, SMARTS, and PDB
You could also look into ProDy, if you use PDB files. http://www.csb.pitt.edu/prody/reference/atomic/flags.html#term-hetero Pozdrawiam, | Best regards, Maciek Wójcikowski mac...@wojcikowski.pl 2013/7/8 Maciek Wójcikowski mac...@wojcikowski.pl I think you need custom code. For python, you could use pybel. There are three lines that do what you want ( http://openbabel.org/docs/dev/UseTheLibrary/Python_PybelAPI.html#pybel.Smarts.findall). You only miss one or two lines to get the atoms by their indices. Although searching pdb files with it could be a demanding and time consuming task. It's really made for small molecules, i guess. I'd personally would loop through atoms check if they are HETATOMs and then check SMARTS pattern. Alternatively, you can filter them by name, if you can suspect what's your residues name could be (although it's the most error prone). Pozdrawiam, | Best regards, Maciek Wójcikowski mac...@wojcikowski.pl 2013/7/8 Brett Hannigan godot_gil...@yahoo.com Unfortunately, I don't think that's quite what I need. The obabel filter command will look at the given pdb and then output the entire pdb if it matches the given SMARTS query, right? What I would like to do is only get the atoms that match the SMARTS query. For example, let's say I have a pdb with a single phospho-serine residue. What I would like to do is get only the phosphate atoms from the pdb, and not get the rest of the residue atoms. Really what I am going for here is I'd like specify some groups that I find interesting, say a phosphate group, a phenyl group, etc. And then I have a database of protein + ligand pdbs. I'd like to loop through those pdbs and look for my groups that I am interested in. Rather than just identify the pdbs that have the sub-structure I am interested in (i.e. identify all pdbs with phosphates), I want to know which atoms in the pdb constitute the interesting sub-structure. That way I could then align all phosphate groups and look at the residues surrounding the phophates to see if I see common modes of binding etc. Phosphate would just be one example, you can imagine identifying many other interesting sub-structures. -Brett -- *From:* Maciek Wójcikowski mac...@wojcikowski.pl *To:* Brett T. Hannigan bret...@mail.med.upenn.edu *Cc:* openbabel-discuss@lists.sourceforge.net *Sent:* Saturday, July 6, 2013 6:21 AM *Subject:* Re: [Open Babel] SMILES, SMARTS, and PDB Hello, You can convert from PDB to PDB using filter option ( http://openbabel.org/wiki/--filter_option) obabel input.pdb -O output.pdb --filter s='CN' If your database is really large, or you want to search multiple times, then I'd suggest using FastSearch for performance reasons. For further lecture: http://openbabel.org/wiki/FastSearch Pozdrawiam, | Best regards, Maciek Wójcikowski mac...@wojcikowski.pl 2013/7/5 Brett T. Hannigan bret...@mail.med.upenn.edu I have a database of molecules in pdb files. I'd like to go through each molecule and see if it has certain substructures, and if they do identify which atoms are part of that substructure. So it's easy enough to read the pdb file in, convert it to SMILES representation, and then do a SMARTS query to look for my substructures. However, if the SMARTS query reports that the substructure is present in the molecule, I'm not sure how to identify the atoms in the pdb file which make up the match. Any ideas? -- ** Brett T. Hannigan 8011 Ardleigh St. Philadelphia, PA 19118 brett.hanni...@gmail.com ** -- This SF.net http://sf.net/ email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Re: [Open Babel] SMILES, SMARTS, and PDB
On 05/07/2013 17:54, Brett T. Hannigan wrote: I have a database of molecules in pdb files. I'd like to go through each molecule and see if it has certain substructures, and if they do identify which atoms are part of that substructure. So it's easy enough to read the pdb file in, convert it to SMILES representation, and then do a SMARTS query to look for my substructures. However, if the SMARTS query reports that the substructure is present in the molecule, I'm not sure how to identify the atoms in the pdb file which make up the match. Any ideas? I would suggest that you can browser the ligand-expo service provided by PDB and download the smiles or 3D structures of small molecules http://ligand-expo.rcsb.org/ld-download.html Lirong Wang, PhD School of Pharmacy University of Pittsburgh -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Re: [Open Babel] Segfault when merging molecules through python API
I've reproduced this behaviour. As you say it's fairly subtle. In fact I can't tell whether it's a bug at our end or a feature of swig in general. It appears that obmol += newmol replaces the underlying OBMol with a new one. You can see this by printing out the obmol (the address changes) in a non-segfaulting version: mol = pybel.readstring(smi, C).OBMol newmol = pybel.readstring(smi, C).OBMol print mol mol += newmol print mol print pybel.Molecule(mol).write(smi) openbabel.OBMol; proxy of Swig Object of type 'OpenBabel::OBMol *' at 0x022F5290 openbabel.OBMol; proxy of Swig Object of type 'OpenBabel::OBMol *' at 0x028CDF08 C.C If you do the addition in a function, then the mol variable remains pointing to an OBMol which has been destroyed or something. If you can find any clues to this in the SWIG docs, I'm happy to try to fix it but I've just taken a look and don't see anything obvious. I don't see anything fishy about our C++ code either: OBMol OBMol::operator+=(const OBMol source) ? - Noel On 3 July 2013 11:31, Fred Ludlow fred.lud...@gmail.com wrote: Hi, I've come across a subtle bug (or misunderstanding on my part..?) when merging molecules from python... I've attached a minimal example that segfaults (tested on Red Hat Enterprise Linux, python 2.7, openbabel 2.3.1). Essentially, it seems that if I do something like mol1 += mol2 inside a function, mol1 (or more likely the C++ object underneath) is no longer valid and doing things like converting it to an output string fails with a segfault. I'm guessing swig or python has decided there aren't any more references to it and has triggered deletion of the C++ object? e.g something like: def addNewFragment(obmol): frag = newFrag() # Create some OBMol instance obmol += frag mymol = getMol() # Some function to return OBMol instance addNewFragment(mymol) # At this point the mymol object is broken, and calls to many of its methods fail with a segfault Storing another reference to it (e.g. by returning the molecule from the function and assigning it to something ) fixes the problem, e.g: def addNewFragmentAndReturn(obmol): frag = newFrag() obmol += frag return obmol mymol =getMol() foo = addNewFragmentAndReturn(mymol) # mymol is still valid... (creating the foo reference seems to have kept it alive...) I think this is a bug - Can anyone else reproduce this (demo script attached) or is it me not understanding how to use the library :) Fred -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss