[ase-users] Bug in Turbomole/coord read routine?

Tobias Risthaus tobias.risthaus at thch.uni-bonn.de
Tue Apr 24 12:46:27 CEST 2012


Hello everyone,

I'm kinda new to Python and ASE, but I believe to have found a bug in 
the read_turbomole routine for TM 2.1 coord files. When reading coord 
files generated by TM itself or the appropriate write routine of ASE, a 
ValueError (line 28 of trunk/ase/io/turbomole.py @ 2387) is always raised.

I think this is how the error arises:
The entire file appears to be read into the lines variable, which is 
subsequently scanned for '$coord'. However, the readline() and 
readlines() method appear to always add a newline character to the line, 
which means that '$coord' can never be part of the data, but possibly 
'$coord\n'. Note that scanning for '$coord\n' would not truly solve the 
issue because whitespace may be present on the same line as  '$coord'.

I fixed the problem in the following way:

#replace line 21 by the following two lines:
rawlines = f.readlines()
lines = [ s.strip() for s in [ s.replace("\n","") for s in rawlines ] ]

which should strip whitespace and newline characters from the end of the 
lines. This worked for the few testcases I used. I have attached the 
fixed read_turbomole snippet.

Cheers,
Tobias Risthaus
-- 
Tobias Risthaus
tobias.risthaus at thch.uni-bonn.de
Mulliken Center for Theoretical Chemistry
Institut für Physikalische und Theoretische Chemie
Universität Bonn, Beringstr. 4, D-53115 Bonn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: snippet.py
Type: text/x-python
Size: 1764 bytes
Desc: not available
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20120424/0b951166/attachment.py>


More information about the ase-users mailing list