From: Pavol J. <ju...@pa...> - 2007-04-12 17:00:23
|
Hello, I would like to read a structure from cif file and extract the lattice parameters using the python interface for openbabel. I went through the openbabel wiki, also through openbabel API, but I am still at loss how to perform this task. Here is my python code: import pybel, openbabel cete3 = pybel.readfile("cif", "cete3_p1.cif").next() uc = cete3.OBMol.GetData(openbabel.UnitCell) This executes fine, but uc is an instance of openbabel.OBGenericData class and it does not have GetA() or any other method of the OBUnitCell() class. I tried to convert it to OBUnitCell instance with uc1 = openbabel.OBUnitCell(uc) but that does not work either. Could anyone advice my how to get to those unit cell parameters with python openbabel? Thanks a lot, Pavol |
From: Geoffrey H. <ge...@ge...> - 2007-04-12 22:03:56
|
On Apr 12, 2007, at 1:00 PM, Pavol Juhas wrote: > cete3 = pybel.readfile("cif", "cete3_p1.cif").next() > uc = cete3.OBMol.GetData(openbabel.UnitCell) > > This executes fine, but uc is an instance of openbabel.OBGenericData > class and it does not have GetA() or any other method of the > OBUnitCell() class. Ugh. In C++ such type conversion is done with casting. I think the only solution will be to add conversion functions -- perhaps in the SWIG interface file, which allows such conversion. Unfortunately, Noel, who contributed Pybel is on vacation right now, or he might have some other ideas. Could you file this as a bug report in the tracker? Thanks, -Geoff P.S. On the plus side, I think we should be able to release a fixed Python interface without needing to wait for a 2.1.1 update to Open Babel itself. |
From: Noel O'B. <bao...@gm...> - 2007-05-09 11:43:38
|
This has now been resolved in the development version. The Python code you describe below works, and 'uc' has the GetA() method, etc. I am working on adding this to pybel also, where it will be available as "cete3.unitcell" if present. Noel On 12/04/07, Geoffrey Hutchison <ge...@ge...> wrote: > > On Apr 12, 2007, at 1:00 PM, Pavol Juhas wrote: > > > cete3 = pybel.readfile("cif", "cete3_p1.cif").next() > > uc = cete3.OBMol.GetData(openbabel.UnitCell) > > > > This executes fine, but uc is an instance of openbabel.OBGenericData > > class and it does not have GetA() or any other method of the > > OBUnitCell() class. > > Ugh. In C++ such type conversion is done with casting. I think the > only solution will be to add conversion functions -- perhaps in the > SWIG interface file, which allows such conversion. Unfortunately, > Noel, who contributed Pybel is on vacation right now, or he might > have some other ideas. > > Could you file this as a bug report in the tracker? > > Thanks, > -Geoff > > P.S. On the plus side, I think we should be able to release a fixed > Python interface without needing to wait for a 2.1.1 update to Open > Babel itself. > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > OpenBabel-scripting mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > |
From: Noel O'B. <bao...@gm...> - 2007-04-23 07:47:55
|
On 12/04/07, Geoffrey Hutchison <ge...@ge...> wrote: > > On Apr 12, 2007, at 1:00 PM, Pavol Juhas wrote: > > > cete3 = pybel.readfile("cif", "cete3_p1.cif").next() > > uc = cete3.OBMol.GetData(openbabel.UnitCell) > > > > This executes fine, but uc is an instance of openbabel.OBGenericData > > class and it does not have GetA() or any other method of the > > OBUnitCell() class. > > Ugh. In C++ such type conversion is done with casting. I think the > only solution will be to add conversion functions -- perhaps in the > SWIG interface file, which allows such conversion. Unfortunately, > Noel, who contributed Pybel is on vacation right now, or he might > have some other ideas. I also really want to be able to access the Data in molecule file formats. I will discuss some ideas with Geoff. In the meanwhile, you should check out PyCiFRW, a Python module for reading/writing CIF files: (1) http://anbf2.kek.jp/CIF/ (2) http://scripts.iucr.org/cgi-bin/paper?wf5020 (Open Access paper) > Could you file this as a bug report in the tracker? > > Thanks, > -Geoff > > P.S. On the plus side, I think we should be able to release a fixed > Python interface without needing to wait for a 2.1.1 update to Open > Babel itself. > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > OpenBabel-scripting mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > |
From: Noel O'B. <bao...@gm...> - 2007-05-02 14:06:41
|
If you add: %inline %{ OpenBabel::OBPairData *GDtoPD(OpenBabel::OBGenericData *data) { return (OpenBabel::OBPairData *) data; } %} to openbabel-python.i, you can use it to cast OBGenericData to OBPairData. But how do you find out what data is available? Noel On 23/04/07, Noel O'Boyle <bao...@gm...> wrote: > On 12/04/07, Geoffrey Hutchison <ge...@ge...> wrote: > > > > On Apr 12, 2007, at 1:00 PM, Pavol Juhas wrote: > > > > > cete3 = pybel.readfile("cif", "cete3_p1.cif").next() > > > uc = cete3.OBMol.GetData(openbabel.UnitCell) > > > > > > This executes fine, but uc is an instance of openbabel.OBGenericData > > > class and it does not have GetA() or any other method of the > > > OBUnitCell() class. > > > > Ugh. In C++ such type conversion is done with casting. I think the > > only solution will be to add conversion functions -- perhaps in the > > SWIG interface file, which allows such conversion. Unfortunately, > > Noel, who contributed Pybel is on vacation right now, or he might > > have some other ideas. > > I also really want to be able to access the Data in molecule file > formats. I will discuss some ideas with Geoff. In the meanwhile, you > should check out PyCiFRW, a Python module for reading/writing CIF > files: > (1) http://anbf2.kek.jp/CIF/ > (2) http://scripts.iucr.org/cgi-bin/paper?wf5020 (Open Access paper) > > > Could you file this as a bug report in the tracker? > > > > Thanks, > > -Geoff > > > > P.S. On the plus side, I think we should be able to release a fixed > > Python interface without needing to wait for a 2.1.1 update to Open > > Babel itself. > > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share your > > opinions on IT & business topics through brief surveys-and earn cash > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > > OpenBabel-scripting mailing list > > Ope...@li... > > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > > > |
From: Noel O'B. <bao...@gm...> - 2007-05-03 16:13:04
|
To answer my question, the following code will iterate over all of the data: for data in mol.BeginData(): pdata = openbabel.GDtoPD(data) print pdata.GetAttribute(), "==", pdata.GetValue() On 02/05/07, Noel O'Boyle <bao...@gm...> wrote: > If you add: > %inline %{ > OpenBabel::OBPairData *GDtoPD(OpenBabel::OBGenericData *data) { > return (OpenBabel::OBPairData *) data; > } > %} > > to openbabel-python.i, you can use it to cast OBGenericData to OBPairData. > > But how do you find out what data is available? > > Noel > > On 23/04/07, Noel O'Boyle <bao...@gm...> wrote: > > On 12/04/07, Geoffrey Hutchison <ge...@ge...> wrote: > > > > > > On Apr 12, 2007, at 1:00 PM, Pavol Juhas wrote: > > > > > > > cete3 = pybel.readfile("cif", "cete3_p1.cif").next() > > > > uc = cete3.OBMol.GetData(openbabel.UnitCell) > > > > > > > > This executes fine, but uc is an instance of openbabel.OBGenericData > > > > class and it does not have GetA() or any other method of the > > > > OBUnitCell() class. > > > > > > Ugh. In C++ such type conversion is done with casting. I think the > > > only solution will be to add conversion functions -- perhaps in the > > > SWIG interface file, which allows such conversion. Unfortunately, > > > Noel, who contributed Pybel is on vacation right now, or he might > > > have some other ideas. > > > > I also really want to be able to access the Data in molecule file > > formats. I will discuss some ideas with Geoff. In the meanwhile, you > > should check out PyCiFRW, a Python module for reading/writing CIF > > files: > > (1) http://anbf2.kek.jp/CIF/ > > (2) http://scripts.iucr.org/cgi-bin/paper?wf5020 (Open Access paper) > > > > > Could you file this as a bug report in the tracker? > > > > > > Thanks, > > > -Geoff > > > > > > P.S. On the plus side, I think we should be able to release a fixed > > > Python interface without needing to wait for a 2.1.1 update to Open > > > Babel itself. > > > > > > ------------------------------------------------------------------------- > > > Take Surveys. Earn Cash. Influence the Future of IT > > > Join SourceForge.net's Techsay panel and you'll get the chance to share your > > > opinions on IT & business topics through brief surveys-and earn cash > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > _______________________________________________ > > > OpenBabel-scripting mailing list > > > Ope...@li... > > > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > > > > > > |