MDAnalysis / pmda

Parallel algorithms for MDAnalysis
https://www.mdanalysis.org/pmda/
Other
31 stars 22 forks source link

AttributeError: Atom has no attribute indices. Do you mean index #157

Closed Dan-Burns closed 2 years ago

Dan-Burns commented 2 years ago

Trying to parallelize the Hole Analysis calculation assuming that I can have n slices of the trajectory being processed simultaneously with a function like

def hole_calc(atomgroup,ts):

    PDB_HOLE = f'hole_frame_{ts.frame}.pdb'
    # write the frame to pdb
    atomgroup.write(PDB_HOLE)
    hole_u = mda.Universe(PDB_HOLE)

    # Get the pore Center Atoms
    center_resis = hole_u.select_atoms('resnum 675 and name CA')

    center_coords = np.mean(center_resis.positions,axis=0)

    profiles = hole2.hole(PDB_HOLE, executable=hole_exe,
                          cpoint=center_coords,
                          cvect=[0,0,1],
                          keep_files=False)
    os.remove(PDB_HOLE)

    return {'rxn_coord':profiles[0]['rxn_coord'], 
            'radius': profiles[0]['radius'], 
            'cen_line_D':profiles[0]['cen_line_D']
            }

Using this as the function inside of:

NewAnalysis(ParallelAnalysisBase)

def _single_frame(self, ts, agroups):
        # REQUIRED
        # called for every frame. ``ts`` contains the current time step
        # and ``agroups`` a tuple of atomgroups that are updated to the
        # current frame. Return result of `some_function` for a single
        # frame

        return {ts.frame: hole_calc(agroups[0], ts)}

and calling it with:

test = HoleParallel(u.select_atoms('all'),None).run()

I get the following error:

test = HoleParallel(u.select_atoms('protein'),None).run() Traceback (most recent call last): File "", line 1, in File "HoleParallel.py", line 57, in init super(HoleParallel, self).init(atomgroup.universe, File "conda_environments/miniconda3/envs/mdanalysis/lib/python3.9/site-packages/pmda/parallel.py", line 213, in init self._indices = [ag.indices for ag in atomgroups] File "conda_environments/miniconda3/envs/mdanalysis/lib/python3.9/site-packages/pmda/parallel.py", line 213, in self._indices = [ag.indices for ag in atomgroups] File "conda_environments/miniconda3/envs/mdanalysis/lib/python3.9/site-packages/MDAnalysis/core/groups.py", line 4142, in getattr return super(Atom, self).getattr(attr) File "conda_environments/miniconda3/envs/mdanalysis/lib/python3.9/site-packages/MDAnalysis/core/groups.py", line 4016, in getattr raise AttributeError(err.format(selfcls=selfcls, attr=attr, AttributeError: Atom has no attribute indices. Do you mean index .... '''

Currently version of MDAnalysis: 2.2

Dan-Burns commented 2 years ago

changing line 216 in parallel.py to self._indices = [list(atomgroups.indices)] made it run but lots of errors followed.

raise ApplicationError(proc.returncode, MDAnalysis.exceptions.ApplicationError: [Errno 2] HOLE failure (/work/LAS/potoyan-lab/Dan/SOFTWARE/hole2/exe/hole). Check output hole.out

Probably going to be faster running it without parallel implementation in the short term.

orbeckst commented 2 years ago

We haven't updated PMDA to work with MDA 2.0 yet #148 so that's probably creating problems.