From: Andrew F. <fa...@mo...> - 2009-07-23 22:41:20
|
Good Afternoon All, I was trying to find a bug in some code I was writing, using the python debugger interface in eric4, when I ran into an unexpected snag. When I was using a standard pybel read loop: set=[] for molecule in pybel.readfile('sdf',filename) set2.append(molecule) eric4 returns an unhandled exception at line 90 of pybel.py (in the OBConversion_ReadFile method) which is: notatend = obconversion.ReadFile(obmol,filename Is this problem because I am not doing something in a sufficiently pythonic idiom, or is eric4 being rigid about checking for EOF and the like when pybel checks for problems in the input stream further down in the code? FWIW, the code runs fine (aside from the logic bug further along that I was trying to track down) from the command line, and this is the latest stable release of openbabel (I upgraded to see if that would fix it; it didn't) and python 2.54. Thanks in advance, Andy |
From: Noel O'B. <bao...@gm...> - 2009-07-24 01:56:34
|
set, set2? 2009/7/23 Andrew Fant <fa...@mo...>: > Good Afternoon All, > I was trying to find a bug in some code I was writing, using the > python debugger interface in eric4, when I ran into an unexpected snag. > > When I was using a standard pybel read loop: > > set=[] > for molecule in pybel.readfile('sdf',filename) > set2.append(molecule) > > eric4 returns an unhandled exception at line 90 of pybel.py (in the > OBConversion_ReadFile method) which is: > > notatend = obconversion.ReadFile(obmol,filename > > Is this problem because I am not doing something in a sufficiently > pythonic idiom, or is eric4 being rigid about checking for EOF and the > like when pybel checks for problems in the input stream further down in > the code? FWIW, the code runs fine (aside from the logic bug further > along that I was trying to track down) from the command line, and this > is the latest stable release of openbabel (I upgraded to see if that > would fix it; it didn't) and python 2.54. > > Thanks in advance, > Andy > > ------------------------------------------------------------------------------ > _______________________________________________ > OpenBabel-scripting mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > |
From: Andrew F. <fa...@mo...> - 2009-07-24 18:55:43
Attachments:
generateerror.py
|
Noel asked me to verify the code was working on the command line and to post it to the group. The following code should be fed two sd formatted files from the command line. It works fine from the command line but dies the previously mentioned ugly death under eric. (yes, I know it needs refactoring. this was a cut and paste job to do a one-off.) Andy |
From: Noel O'B. <bao...@gm...> - 2009-07-26 18:43:39
|
OK, I guess I asked for that :-) Could you reduce it down to the shortest possible program that reproduces the error? For example, a 2 or 3 line program (including imports) would be ideal. You'll should also supply the input file, e.g. a one-molecule sdf file would be ideal. You also need to supply the versions of your operating system, python, eric, openbabel. Since this is an eric bug, rather than in openbabel, you'll probably have to report it to eric instead, but at least I can help you narrow down the problem. - Noel 2009/7/24 Andrew Fant <fa...@mo...>: > Noel asked me to verify the code was working on the command line and to > post it to the group. > > The following code should be fed two sd formatted files from the command > line. It works fine from the command line but dies the previously > mentioned ugly death under eric. > > (yes, I know it needs refactoring. this was a cut and paste job to do a > one-off.) > > Andy > > #!/usr/bin/env python > > import pybel > import sys > import os.path > import numpy > import scipy > import scipy.stats > import string > import math > import matplotlib.pyplot as plt > > if len(sys.argv) == 3: > file1=sys.argv[1] > file2=sys.argv[2] > if not(os.path.isfile(file1)) or not(os.path.isfile(file2)): > print sys.argv[0],": input files must exist" > exit(64) > else: > print "Usage:",sys.argv[0]," file1 file2" > exit(128) > > basename1=string.split( (string.split(file1,'_',2)[0]),'.',2 )[0] > basename2=string.split( (string.split(file2,'_',2)[0]),'.',2 )[0] > > set1=[] > for molecule in pybel.readfile("sdf",file1): > set1.append(molecule) > > set2=[] > for molecule in pybel.readfile("sdf",file2): > set2.append(molecule) > > #generate data arrays > > > data1=[] > for molecule in set1: > mw=molecule.molwt > logp=molecule.calcdesc()['LogP'] > mr=molecule.calcdesc()['MR'] > tpsa=molecule.calcdesc()['TPSA'] > fp2=molecule.calcfp('FP2') > fp4=molecule.calcfp('FP4') > mumble=[mw,logp,mr,tpsa,fp2,fp4] > data1.append(mumble) > > data2=[] > for molecule in set2: > mw=molecule.molwt > logp=molecule.calcdesc()['LogP'] > mr=molecule.calcdesc()['MR'] > tpsa=molecule.calcdesc()['TPSA'] > fp2=molecule.calcfp('FP2') > fp4=molecule.calcfp('FP4') > mumble=[mw,logp,mr,tpsa,fp2,fp4] > data2.append(mumble) > > #Generate stats for mw,logP,mr, & tpsa for each set > > scratch1=numpy.empty((len(data1),4)) > kount=0 > for line in data1: > scratch1[kount,0]=line[0] > scratch1[kount,1]=line[1] > scratch1[kount,2]=line[2] > scratch1[kount,3]=line[3] > kount+=1 > > scratch2=numpy.empty((len(data2),4)) > kount=0 > for line in data2: > scratch2[kount,0]=line[0] > scratch2[kount,1]=line[1] > scratch2[kount,2]=line[2] > scratch2[kount,3]=line[3] > kount+=1 > > print "Statistical Summaries" > print "for",basename1 > print "n =",len(set1) > print "property mean sigma" > print "Mol. Wt ",numpy.mean(scratch1[:,0])," ",numpy.std(scratch1[:,0]) > print "LogP ",numpy.mean(scratch1[:,1])," ",numpy.std(scratch1[:,1]) > print "Molar Ref. ",numpy.mean(scratch1[:,2])," ",numpy.std(scratch1[:,2]) > print "TPSA ",numpy.mean(scratch1[:,3])," ",numpy.std(scratch1[:,3]) > print > print "for",basename2 > print "n =",len(set2) > print "property mean sigma" > print "Mol. Wt ",numpy.mean(scratch2[:,0])," ",numpy.std(scratch2[:,0]) > print "LogP ",numpy.mean(scratch2[:,1])," ",numpy.std(scratch2[:,1]) > print "Molar Ref. ",numpy.mean(scratch2[:,2])," ",numpy.std(scratch2[:,2]) > print "TPSA ",numpy.mean(scratch2[:,3])," ",numpy.std(scratch2[:,3]) > > cross_FP2_similar=numpy.empty((len(set1),len(set2))) > cross_FP4_similar=numpy.empty((len(set1),len(set2))) > for i in range(len(set1)): > for j in range(len(set2)): > cross_FP2_similar[i,j]=data1[i][4] | data2[j][4] > cross_FP4_similar[i,j]=data1[i][5] | data2[j][5] > > > ------------------------------------------------------------------------------ > > _______________________________________________ > OpenBabel-scripting mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > > |
From: Andrew F. <fa...@mo...> - 2009-07-28 18:31:43
Attachments:
generateerror.py
singlemol.sdf
|
OK. this is as simple as I can get it. Openbabel 2.2.2 Python 2.5.4 Eric 4.3.5 I'm willing to file it with the eric people too. I just started here on the probability of getting one of the developers to render an opinion. Andy Noel O'Boyle wrote: > OK, I guess I asked for that :-) > > Could you reduce it down to the shortest possible program that > reproduces the error? For example, a 2 or 3 line program (including > imports) would be ideal. You'll should also supply the input file, > e.g. a one-molecule sdf file would be ideal. > > You also need to supply the versions of your operating system, python, > eric, openbabel. > > Since this is an eric bug, rather than in openbabel, you'll probably > have to report it to eric instead, but at least I can help you narrow > down the problem. > > - Noel |