ProDy icon indicating copy to clipboard operation
ProDy copied to clipboard

trimPDBEnsemble doesn't work when inputs to buildPDBEnsemble are sele

Open jamesmkrieger opened this issue 3 years ago • 3 comments

with the following code (from the scipion plugin) applied to some spike structures, we get the following error:

            ens = prody.buildPDBEnsemble([tar.select(self.selstr.get()) for tar in self.tars],
                                          ref=ref,
                                          seqid=self.seqid.get(),
                                          overlap=self.overlap.get(),
                                          match_func=match_func,
                                          atommaps=atommaps)

            ens = prody.trimPDBEnsemble(ens, 1.)
ValueError                                Traceback (most recent call last)
Input In [6], in <module>
----> 1 ens = trimPDBEnsemble(ens, occupancy=1.)

File /mnt/c/Users/james/code/scipion3_new/software/em/ProDy/prody/ensemble/functions.py:281, in trimPDBEnsemble(pdb_ensemble, occupancy, **kwargs)
    279 select = atoms[indices]
    280 trimmed.setAtoms(atoms)
--> 281 trimmed.setAtoms(select)
    283 coords = copy(pdb_ensemble._coords)
    284 if coords is not None:

File /mnt/c/Users/james/code/scipion3_new/software/em/ProDy/prody/ensemble/ensemble.py:265, in Ensemble.setAtoms(self, atoms)
    263     ag = atoms
    264 if ag.numAtoms() != n_atoms:
--> 265     raise ValueError('size mismatch between this ensemble ({0} atoms) and atoms ({1} atoms)'
    266                     .format(n_atoms, ag.numAtoms()))
    267 self._atoms = ag
    268 self._indices, _ = sliceAtoms(self._atoms, atoms)

ValueError: size mismatch between this ensemble (2955 atoms) and atoms (24015 atoms)

I think we need to use getAtomGroup somewhere for generating and/or applying the indices. Perhaps, we could/should also use trimmed.select with a selstr based on them too.

jamesmkrieger avatar Feb 15 '23 18:02 jamesmkrieger

This doesn't happen when the reference is an index

jamesmkrieger avatar Dec 18 '23 17:12 jamesmkrieger

In fact, a lot of things aren't made to handle that. All the get functions that use indices (getMSA, getCoords, getCoordsets, etc.) have problems and loadEnsemble does too

jamesmkrieger avatar Dec 18 '23 18:12 jamesmkrieger

Hi @jamesmkrieger, are there any remaining things to be fixed related to this issue?

AnthonyBogetti avatar Mar 10 '25 20:03 AnthonyBogetti