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

Clustering ensemble of in memory universes #32

Open
fluver opened this issue Mar 2, 2020 · 0 comments
Open

Clustering ensemble of in memory universes #32

fluver opened this issue Mar 2, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@fluver
Copy link

fluver commented Mar 2, 2020

Expected behavior

Given a list of in-memory universe objects c = MDAnalysis.analysis.encore.clustering.cluster.cluster(us) should return a ClustersCollection.

Actual behavior

Call fails with
TypeError: Cannot determine file format for file 'None'. You can set the format explicitly with 'Universe(..., format=FORMAT)'.

Code to reproduce the behavior

def create_subverse(pdb, xtc, selection):
    big_u = load_trj(pdb, xtc)
    goi = big_u.select_atoms(selection)
    subu = mda.Merge(goi).load_new(
                AnalysisFromFunction(lambda ag: ag.positions.copy(),
                                    goi).run().results,
                format=MemoryReader)
    return(subu)

us = [create_subverse(pdb='../small.pdb', xtc=f'../windows/{r}/trj.cat.xtc', selection='segid A and backbone') for r in range(3)]
c = cluster(us)

Possible fix
merge_universes in MDAnalysis/analysis/encore/utils.py does not properly check if the filename property of the first universe in the list is set, the following code does.

if universes[0].filename:
        return mda.Universe(
            universes[0].filename,
            np.concatenate(tuple([e.trajectory.timeseries(order='fac') for e in universes]),
                        axis=0),
            format=MemoryReader)

elif universes[0].trajectory.format == 'MEMORY' and universes[0].filename == None:
        trj = np.concatenate([e.trajectory.timeseries(order='fac') for e in universes])
        o = mda.Merge(universes[0].atoms)
        o.load_new(trj, format=MemoryReader)
        return o

Alternative:

return mda.Merge(
    universes[0].atoms
    ).load_new(
        np.concatenate(
            [e.trajectory.timeseries(order='fac') for e in universes]), 
            format=MemoryReader
            )

Currently version of MDAnalysis

  • Which version are you using? (run python -c "import MDAnalysis as mda; print(mda.__version__)") -> 0.20.1
  • Which version of Python (python -V)? -> Python 3.6.7
  • Which operating system? -> Debian 8
@IAlibay IAlibay transferred this issue from MDAnalysis/mdanalysis Sep 6, 2023
@orbeckst orbeckst added the bug Something isn't working label Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants