Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ Enhancements
explicit in the topology (Issue #2468, PR #2775)

Changes
* removes deprecated `as_Universe` function from MDAnalysis.core.universe,
as a result :class:`MDAnalysis.analysis.leaflet.LeafletFinder` now only
accepts Universes for its `universe` argument (Issue #2920)
* deprecated NumPy type aliases have been replaced with their actual types
(see upstream NumPy PR 14882), and our pytest configuration will raise an
error for any violation when testing with development NumPy builds
Expand Down
4 changes: 2 additions & 2 deletions package/MDAnalysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@

"""

__all__ = ['Universe', 'as_Universe', 'Writer', 'fetch_mmtf',
__all__ = ['Universe', 'Writer', 'fetch_mmtf',
'AtomGroup', 'ResidueGroup', 'SegmentGroup']

import logging
Expand Down Expand Up @@ -202,7 +202,7 @@
from . import units

# Bring some often used objects into the current namespace
from .core.universe import Universe, as_Universe, Merge
from .core.universe import Universe, Merge
from .core.groups import AtomGroup, ResidueGroup, SegmentGroup
from .coordinates.core import writer as Writer

Expand Down
13 changes: 8 additions & 5 deletions package/MDAnalysis/analysis/leaflet.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ class LeafletFinder(object):

Parameters
----------
universe : Universe or str
:class:`MDAnalysis.Universe` or a file name (e.g., in PDB or
GRO format)
universe : Universe
:class:`~MDAnalysis.core.universe.Universe` object.
select : AtomGroup or str
A AtomGroup instance or a
:meth:`Universe.select_atoms` selection string
Expand All @@ -119,7 +118,8 @@ class LeafletFinder(object):
consecutively, starting at 0. To obtain the atoms in the input structure
use :meth:`LeafletFinder.groups`::

L = LeafletFinder(PDB, 'name P*')
u_PDB = mda.Universe(PDB)
L = LeafletFinder(u_PDB, 'name P*')
leaflet0 = L.groups(0)
leaflet1 = L.groups(1)

Expand All @@ -132,12 +132,15 @@ class LeafletFinder(object):

leaflet0.residues.atoms


.. versionchanged:: 1.0.0
Changed `selection` keyword to `select`
.. versionchanged:: 2.0.0
The universe keyword no longer accepts non-Universe arguments. Please
create a :class:`~MDAnalysis.core.universe.Universe` first.
"""

def __init__(self, universe, select, cutoff=15.0, pbc=False, sparse=None):
universe = core.universe.as_Universe(universe)
self.universe = universe
self.selectionstring = select
if isinstance(self.selectionstring, core.groups.AtomGroup):
Expand Down
26 changes: 0 additions & 26 deletions package/MDAnalysis/core/universe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1324,32 +1324,6 @@ def from_smiles(cls, smiles, sanitize=True, addHs=True,
return cls(mol, **kwargs)


# TODO: what is the point of this function???
def as_Universe(*args, **kwargs):
"""Return a universe from the input arguments.

1. If the first argument is a universe, just return it::

as_Universe(universe) --> universe

2. Otherwise try to build a universe from the first or the first
and second argument::

as_Universe(PDB, **kwargs) --> Universe(PDB, **kwargs)
as_Universe(PSF, DCD, **kwargs) --> Universe(PSF, DCD, **kwargs)
as_Universe(*args, **kwargs) --> Universe(*args, **kwargs)

Returns
-------
:class:`~MDAnalysis.core.groups.Universe`
"""
if len(args) == 0:
raise TypeError("as_Universe() takes at least one argument (%d given)" % len(args))
elif len(args) == 1 and isinstance(args[0], Universe):
return args[0]
return Universe(*args, **kwargs)


def Merge(*args):
"""Create a new new :class:`Universe` from one or more
:class:`~MDAnalysis.core.groups.AtomGroup` instances.
Expand Down
7 changes: 5 additions & 2 deletions testsuite/MDAnalysisTests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,26 @@

import MDAnalysis as mda


def test_Universe():
assert mda.Universe is mda.core.universe.Universe

def test_as_Universe():
assert mda.as_Universe is mda.core.universe.as_Universe

def test_fetch_mmtf():
assert mda.fetch_mmtf is mda.coordinates.MMTF.fetch_mmtf


def test_Writer():
assert mda.Writer is mda.coordinates.core.writer


def test_AtomGroup():
assert mda.AtomGroup is mda.core.groups.AtomGroup


def test_ResidueGroup():
assert mda.ResidueGroup is mda.core.groups.ResidueGroup


def test_SegmentGroup():
assert mda.SegmentGroup is mda.core.groups.SegmentGroup