Closed gundelach closed 4 years ago
Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error: Could not determine trajectory '/Users/lg/OneDrive' format. Error: Could not set up trajectory '/Users/lg/OneDrive - University of Southampton/XTB/MobleyLab/cb7/cb7-1/amber/traj_sparse.crd'
It should work if you escape the spaces with a backslash \
, e.g. (in cpptraj syntax):
trajin "traj with space.nc"
will not work, but
trajin "traj\ with\ space.nc"
should.
1) If I run ipython from the working directory in which the trajectory file is located, it does not manage to read it but DOES manage to read the topology file in the same directory. The absolute path to the working directory contains white spaces.
traj = pt.iterload('./traj_sparse.crd','./cb7-1.prmtop') #### Loads topology but not trajectory, i.e zero frames in traj Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error: Could not determine trajectory '/Users/lg/OneDrive' format. Error: Could not set up trajectory '/Users/lg/OneDrive - University of Southampton/XTB/MobleyLab/cb7/cb7-1/amber/traj_sparse.crd'
2) I have copied the trajectory file to /Desktop and given pt.load the absolute path and it loads no problem. If I create a subfolder "/Desktop/test dir" it no longer works. If I pass the file path using backslash to escape white-spaces it still does not work. See three cases below
a) traj = pt.load('/Users/lg/Desktop/traj_sparse.crd',top='cb7-1.prmtop') ## Loads topology and frames into trajectory no problem
b) traj = pt.load('/Users/lg/Desktop/test dir/traj_sparse.crd',top='cb7-1.prmtop') ## frames no longer loaded into traj Error: '/Users/lennartgundelach/Desktop/test': No such file or directory Error: Could not set up trajectory '/Users/lennartgundelach/Desktop/test dir/traj_sparse.crd'
c) traj = pt.load('/Users/lg/Desktop/test\ dir/traj_sparse.crd',top='cb7-1.prmtop') ## frame STILL not loaded into traj ValueError: must provie a filename or list of filenames or file pattern
Finally what is strange is that only example c) create an error message in python. Example b), which does not work only produces errors in the Jupyter Lab terminal.
ValueError: must provie a filename or list of filenames or file pattern
@hainm This message indicates the issue is likely with the python layer, not the underlying cpptraj layer.
@gundelach You can test this by trying the following input with cpptraj:
parm cb7-1.prmtop
trajin "/Users/lg/Desktop/test\ dir/traj_sparse.crd"
list
ValueError: must provie a filename or list of filenames or file pattern
@hainm This message indicates the issue is likely with the python layer, not the underlying cpptraj layer.
Yeah, it's because pytraj
is using glob
to get a list of files based on the pattern.
https://github.com/Amber-MD/pytraj/blob/66e181535900dbac6befb357302a3bf8f6c6ceb3/pytraj/trajectory/trajectory_iterator.py#L213-L217
In [10]: !ls tz2*
tz2 white_space.nc tz2.parm7
In [11]: glob('./tz2\ white_space.nc')
Out[11]: []
In [12]: glob('./tz2*white_space.nc')
Out[12]: ['./tz2 white_space.nc']
@hainm Not sure if this makes a difference, but the issue I'm facing is more so that the absolute path to the file has whitespace, not that the name of the file itself does. But maybe fixing one thing will fix the other.
Thanks all for the responses.
thanks @gundelach. The fix is in master branch now. #1558
But maybe fixing one thing will fix the other.
yeah, should be fixed.
@gundelach
In [2]: pt.iterload("./a\ folder\ with\ whitespace/tz2.nc", "./tz2.parm7")
Out[2]:
pytraj.TrajectoryIterator, 101 frames:
Size: 0.000503 (GB)
<Topology: 223 atoms, 13 residues, 1 mols, non-PBC>
thank you for reporting the bug.
Hi, I have recently started using pytraj again, and updated pytraj via conda to version 2.0.5 but the same issue is still present when trying to load files from a directory that has whitespaces in its path.
Working directory: /Users/gundelach/OneDrive - University of Southampton/QMPBSA2/calculations/BRD4/visualization/mmpbsa_long/trajectories
Code: traj = pt.load('./trajectories/BRD4-1-no_water.crd', './trajectories/BRD4-1-no_water.prmtop')
Error: Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error during FileIO_Std::Read: Is a directory Error: Could not determine trajectory '/Users/gundelach/OneDrive' format. Error: Could not set up trajectory '/Users/gundelach/OneDrive - University of Southampton/QMPBSA2/calculations/BRD4/visualization/mmpbsa_long/trajectories/trajectories/BRD4-1-no_water.crd'
hi @gundelach: the fix is still in master branch and it's not released yet. http://amber-md.github.io/pytraj/latest/installation.html#from-source-code-easy-way-linux-osx
Ah, thanks for clarifying, my bad!
It appears that pytraj.iterload and pytraj.load have an issue with loading specifically the trajectory file (first argument) when the current working directory contains white spaces in the full path.
If the path to the location in which the trajectory/coord file is located has a white-space, no frames are loaded. If I copy the same file to a location where the path does not have a white-space, the frames are loaded no problem. Oddly the topology file loads just fine no matter the path. I tried this with multiple test directories and it happens every time.
Working on Mac, just installed pytraj via conda yesterday.