Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 19999

Python MDanalysis package: PermissionError: [Errno 1] Operation not permitted

$
0
0

I'm trying to load my Molecular Dynamics trajectories (.nc Amber file format) into Python using the package MDAnalysis. I'm using the following code:

    clusters = 1085    list_trajectories = []    for i in range(clusters):        list_trajectories.append(os.path.join(path_trajectories, f'cluster_{i}/prod/dry.CL_00.nc'))    u = Universe(topology, list_trajectories)    ag = u.atoms

However, this gives me a PermissionError: [Errno 1] Operation not permitted: '/home/path_to_trajectories/2P49_clusters/cluster_138/prod/dry.CL_00.nc' error (I pasted the whole error message below).

I checked the permissions, and they are the same (-rw-r-----) for cluster_138 as they are for all the other clusters which apparently could be loaded before that number.

Also, the error message isn't always the same:

  • when I try to load less trajectories (only up until clusters = 400) it works almost all the times
  • sometimes when rerunning the same code snipped, it fails the second time
  • sometimes it shows the error message for another cluster number (e.g. cluster_490)

So I was thinking it could maybe be a memory issue? But I'm really running out of ideas. Any help is appreciated. Thanks in advance!

The complete error message is:

PermissionError                           Traceback (most recent call last)Cell In[8], line 108 for i in range(clusters):9     list_trajectories.append(os.path.join(path_old_trajectories, f'2P49_clusters/cluster_{i}/prod/dry.CL_00.nc'))---> 10 u = Universe(topology, list_trajectories, in_memory=False)File ~/miniforge3/envs/alessia_spib/lib/python3.12/site-packages/MDAnalysis/core/universe.py:375, in Universe.init(self, topology, all_coordinates, format, topology_format, transformations, guess_bonds, vdwradii, fudge_factor, lower_bound, in_memory, in_memory_step, *coordinates, **kwargs)370 coordinates = _resolve_coordinates(self.filename, *coordinates,371                                    format=format,372                                    all_coordinates=all_coordinates)374 if coordinates:--> 375     self.load_new(coordinates, format=format, in_memory=in_memory,376                 in_memory_step=in_memory_step, **kwargs)378 if transformations:379     if callable(transformations):File ~/miniforge3/envs/alessia_spib/lib/python3.12/site-packages/MDAnalysis/core/universe.py:580, in Universe.load_new(self, filename, format, in_memory, in_memory_step, **kwargs)577 # supply number of atoms for readers that cannot do it for themselves578 kwargs['n_atoms'] = self.atoms.n_atoms--> 580 self.trajectory = reader(filename, format=format, **kwargs)581 if self.trajectory.n_atoms != len(self.atoms):582     raise ValueError("The topology and {form} trajectory files don't"583                      " have the same number of atoms!\n"584                      "Topology number of atoms {top_n_atoms}\n"(...)588                          fname=filename,589                          trj_n_atoms=self.trajectory.n_atoms))File ~/miniforge3/envs/alessia_spib/lib/python3.12/site-packages/MDAnalysis/lib/util.py:2553, in store_init_arguments.<locals>.wrapper(self, *args, **kwargs)2551             else:2552                 self._kwargs[key] = arg-> 2553 return func(self, *args, **kwargs)File ~/miniforge3/envs/alessia_spib/lib/python3.12/site-packages/MDAnalysis/coordinates/chain.py:270, in ChainReader.init(self, filenames, skip, dt, continuous, convert_units, **kwargs)268 if dt is not None:269     kwargs['dt'] = dt--> 270 self.readers = [core.reader(filename, convert_units=convert_units, **kwargs)271                 for filename in filenames]272 self.filenames = np.array([fn[0] if isinstance(fn, tuple) else fn273                                                 for fn in filenames])274 # pointer to "active" trajectory index into self.readersFile ~/miniforge3/envs/alessia_spib/lib/python3.12/site-packages/MDAnalysis/coordinates/core.py:82, in reader(filename, format, **kwargs)80     Reader = get_reader_for(filename, format=format)81 try:---> 82     return Reader(filename, **kwargs)83 except ValueError:84     errmsg = f'Unable to read {filename} with {Reader}.'File ~/miniforge3/envs/alessia_spib/lib/python3.12/site-packages/MDAnalysis/lib/util.py:2553, in store_init_arguments.<locals>.wrapper(self, *args, **kwargs)2551             else:2552                 self._kwargs[key] = arg-> 2553 return func(self, *args, **kwargs)File ~/miniforge3/envs/alessia_spib/lib/python3.12/site-packages/MDAnalysis/coordinates/TRJ.py:446, in NCDFReader.init(self, filename, n_atoms, mmap, **kwargs)443 super(NCDFReader, self).init(filename, **kwargs)445 # ensure maskandscale is off so we don't end up double scaling--> 446 self.trjfile = NCDFPicklable(self.filename,447                              mmap=self._mmap,448                              maskandscale=False)450 # AMBER NetCDF files should always have a convention451 try:File ~/miniforge3/envs/alessia_spib/lib/python3.12/site-packages/scipy/io/_netcdf.py:247, in netcdf_file.init(self, filename, mode, mmap, version, maskandscale)245 self.filename = filename246 omode = 'r+' if mode == 'a' else mode--> 247 self.fp = open(self.filename, '%sb' % omode)248 if mmap is None:249     # Mmapped files on PyPy cannot be usually closed250     # before the GC runs, so it's better to use mmap=False251     # as the default.252     mmap = (not IS_PYPY)PermissionError: [Errno 1] Operation not permitted: '/home/path_to_trajectories/2P49_clusters/cluster_138/prod/dry.CL_00.nc'

Viewing all articles
Browse latest Browse all 19999

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>