Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Dan-Burns opened this issue Jul 29, 2022 · 2 comments
Closed

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

Dan-Burns opened this issue Jul 29, 2022 · 2 comments

Comments

@Dan-Burns
Copy link

Dan-Burns commented Jul 29, 2022

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
Copy link
Author

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
Copy link
Member

orbeckst commented Aug 1, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants