[Tutor] Pandas Problem?

Stephen P. Molnar s.molnar at sbcglobal.net
Tue Sep 24 08:10:59 EDT 2019


I am using the Spyder3 IDE with Python 3.7.3 and have encountered, what 
to me at least, is a rather strange problem.

The code, at this point is:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  8 15:17:07 2017

@author: comp

"""
#import numpy as np
#import matplotlib.pyplot as plt
import pandas as pd

name = input("Enter Molecule ID: ")

print(name)

ligand_file = name+'_apo-1acl.RMSD'

print('Ligand file = ',ligand_file)

data = pd.read_table('ligand_file',skiprows = 7)

print(data)

The input file, in this example, 17-3_apo-1acl.RMSD is:

     RMSD TABLE
     __________

_____________________________________________________________________
      |      |      |           |         |                 |
Rank | Sub- | Run  | Binding   | Cluster | Reference       | Grep
      | Rank |      | Energy    | RMSD    | RMSD            | Pattern
_____|______|______|___________|_________|_________________|___________
    1      1      8       -7.23      0.00     93.07           RANKING
    1      2      9       -6.79      1.39     92.64           RANKING
    2      1     16       -7.18      0.00     93.19           RANKING
    3      1      2       -6.93      0.00     93.38           RANKING
    3      2     17       -6.84      0.23     93.45           RANKING
    4      1     15       -6.55      0.00     91.83           RANKING
    4      2      7       -6.34      0.33     91.77           RANKING
    5      1      5       -6.41      0.00     93.05           RANKING
    6      1      3       -6.36      0.00     92.84           RANKING
    6      2     10       -6.28      0.47     92.92           RANKING
    6      3      6       -6.27      0.43     92.82           RANKING
    6      4     18       -6.25      0.32     92.88           RANKING
    6      5     13       -6.24      0.96     92.75           RANKING
    6      6      1       -6.24      0.87     92.60           RANKING
    6      7     14       -6.21      0.51     92.90           RANKING
    6      8     11       -6.14      0.98     92.78           RANKING
    6      9     20       -6.11      0.71     92.67           RANKING
    6     10     19       -6.01      1.36     93.00           RANKING
    7      1     12       -6.30      0.00     93.28           RANKING
    8      1      4       -5.85      0.00     92.97           RANKING
_______________________________________________________________________

The output at this point is:

Enter Molecule ID: 17-3
17-3
Ligand file =  17-3_apo-1acl.RMSD
Traceback (most recent call last):

   File "<ipython-input-3-48de0a8fd907>", line 1, in <module>
runfile('/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/RMSDTable_3.py.', 
wdir='/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable')

   File 
"/usr/local/lib/python3.7/dist-packages/spyder_kernels/customize/spydercustomize.py", 
line 827, in runfile
     execfile(filename, namespace)

   File 
"/usr/local/lib/python3.7/dist-packages/spyder_kernels/customize/spydercustomize.py", 
line 110, in execfile
     exec(compile(f.read(), filename, 'exec'), namespace)

   File 
"/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/RMSDTable_3.py.", 
line 23, in <module>
     data = pd.read_table('ligand_file',skiprows = 7)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py", 
line 685, in parser_f
     return _read(filepath_or_buffer, kwds)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py", 
line 457, in _read
     parser = TextFileReader(fp_or_buf, **kwds)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py", 
line 895, in __init__
     self._make_engine(self.engine)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py", 
line 1135, in _make_engine
     self._engine = CParserWrapper(self.f, **self.options)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py", 
line 1917, in __init__
     self._reader = parsers.TextReader(src, **kwds)

   File "pandas/_libs/parsers.pyx", line 382, in 
pandas._libs.parsers.TextReader.__cinit__

   File "pandas/_libs/parsers.pyx", line 689, in 
pandas._libs.parsers.TextReader._setup_parser_source

FileNotFoundError: [Errno 2] File b'ligand_file' does not exist: 
b'ligand_file'


However, if I change the data = line to:

data = pd.read_table('13-7_apo-1acl.RMSD',skiprows = 7)

The output is:

runfile('/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/RMSDTable_3.py.', 
wdir='/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable')

Enter Molecule ID: 13-7
13-7
Ligand file =  13-7_apo-1acl.RMSD
_____|______|______|___________|_________|_________________|___________
0      1      1      8       -7.23      0.00 9...
1      1      2      9       -6.79      1.39 9...
2      2      1     16       -7.18      0.00 9...
3      3      1      2       -6.93      0.00 9...
4      3      2     17       -6.84      0.23 9...
5      4      1     15       -6.55      0.00 9...
6      4      2      7       -6.34      0.33 9...
7      5      1      5       -6.41      0.00 9...
8      6      1      3       -6.36      0.00 9...
9      6      2     10       -6.28      0.47 9...
10     6      3      6       -6.27      0.43 9...
11     6      4     18       -6.25      0.32 9...
12     6      5     13       -6.24      0.96 9...
13     6      6      1       -6.24      0.87 9...
14     6      7     14       -6.21      0.51 9...
15     6      8     11       -6.14      0.98 9...
16     6      9     20       -6.11      0.71 9...
17     6     10     19       -6.01      1.36 9...
18     7      1     12       -6.30      0.00 9...
19     8      1      4       -5.85      0.00 9...
20 ______________________________________________...

I have used the ligand_file = line in other Python script that has 
worked without any errors.

Google has not been a solution in his case.  Pointers towards wolutions 
to this problem will be much appreciated.

Thanks in advance.

-- 
Stephen P. Molnar, Ph.D.            Life is a fuzzy set
http://www.Molecular-Modeling.net   Multivariate and stochastic
614.312.7528 (c)
Skype:  smolnar1



More information about the Tutor mailing list