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

Removed some use of deprecated methods #825

Merged
merged 2 commits into from
Apr 19, 2016
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
4 changes: 2 additions & 2 deletions package/MDAnalysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@

Calculate the CA end-to-end distance (in angstroem)::
>>> import numpy as np
>>> coord = ca.coordinates()
>>> coord = ca.positions
>>> v = coord[-1] - coord[0] # last Ca minus first one
>>> np.sqrt(np.dot(v, v,))
10.938133

Define a function eedist():
>>> def eedist(atoms):
... coord = atoms.coordinates()
... coord = atoms.positions
... v = coord[-1] - coord[0]
... return sqrt(dot(v, v,))
...
Expand Down
14 changes: 7 additions & 7 deletions package/MDAnalysis/analysis/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def rotation_matrix(a, b, weights=None):
:meth:`MDAnalysis.core.AtomGroup.AtomGroup.rotate` to generate a rotated
selection, e.g. ::

>>> R = rotation_matrix(A.select_atoms('backbone').coordinates(),
>>> B.select_atoms('backbone').coordinates())[0]
>>> R = rotation_matrix(A.select_atoms('backbone').positions,
>>> B.select_atoms('backbone').positions)[0]
>>> A.atoms.rotate(R)
>>> A.atoms.write("rotated.pdb")

Expand Down Expand Up @@ -356,8 +356,8 @@ def alignto(mobile, reference, select="all", mass_weighted=False,
ref_com = ref_atoms.center_of_geometry()
mobile_com = mobile_atoms.center_of_geometry()

ref_coordinates = ref_atoms.coordinates() - ref_com
mobile_coordinates = mobile_atoms.coordinates() - mobile_com
ref_coordinates = ref_atoms.positions - ref_com
mobile_coordinates = mobile_atoms.positions - mobile_com

old_rmsd = rms.rmsd(mobile_coordinates, ref_coordinates)

Expand Down Expand Up @@ -494,10 +494,10 @@ def rms_fit_trj(traj, reference, select='all', filename=None, rmsdfile=None, pre

# reference centre of mass system
ref_com = ref_atoms.center_of_mass()
ref_coordinates = ref_atoms.coordinates() - ref_com
ref_coordinates = ref_atoms.positions - ref_com

# allocate the array for selection atom coords
traj_coordinates = traj_atoms.coordinates().copy()
traj_coordinates = traj_atoms.positions.copy()

# RMSD timeseries
nframes = len(frames)
Expand All @@ -516,7 +516,7 @@ def rms_fit_trj(traj, reference, select='all', filename=None, rmsdfile=None, pre
# shift coordinates for rotation fitting
# selection is updated with the time frame
x_com = traj_atoms.center_of_mass().astype(np.float32)
traj_coordinates[:] = traj_atoms.coordinates() - x_com
traj_coordinates[:] = traj_atoms.positions - x_com

# Need to transpose coordinates such that the coordinate array is
# 3xN instead of Nx3. Also qcp requires that the dtype be float64
Expand Down
4 changes: 2 additions & 2 deletions package/MDAnalysis/analysis/contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def __init__(self, *args, **kwargs):

# compute reference contacts
dref = MDAnalysis.lib.distances.distance_array(
self.references[0].coordinates(), self.references[1].coordinates())
self.references[0].positions, self.references[1].positions)
self.qref = self.qarray(dref)
self.nref = self.qref.sum()

Expand Down Expand Up @@ -682,7 +682,7 @@ def run(self, store=True, force=False, start=0, stop=None, step=1, **kwargs):
for ts in self.universe.trajectory[start:stop:step]:
frame = ts.frame
# use pre-allocated distance array to save a little bit of time
MDAnalysis.lib.distances.distance_array(A.coordinates(), B.coordinates(), result=self.d)
MDAnalysis.lib.distances.distance_array(A.positions, B.positions, result=self.d)
self.qarray(self.d, out=self.q)
n1, q1 = self.qN(self.q, out=self._qtmp)
self.qavg += self.q
Expand Down
12 changes: 6 additions & 6 deletions package/MDAnalysis/analysis/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def current_coordinates():
group = u.select_atoms(atomselection)

def current_coordinates():
return group.coordinates()
return group.positions

coord = current_coordinates()
logger.info("Selected {0:d} atoms out of {1:d} atoms ({2!s}) from {3:d} total.".format(coord.shape[0], len(u.select_atoms(atomselection)), atomselection, len(u.atoms)))
Expand Down Expand Up @@ -596,14 +596,14 @@ def notwithin_coordinates(cutoff=cutoff):
ns_w = NS.AtomNeighborSearch(solvent) # build kd-tree on solvent (N_w > N_protein)
solvation_shell = ns_w.search_list(protein, cutoff) # solvent within CUTOFF of protein
group = MDAnalysis.core.AtomGroup.AtomGroup(set_solvent - set(solvation_shell)) # bulk
return group.coordinates()
return group.positions
else:
def notwithin_coordinates(cutoff=cutoff):
# acts as '<solvent> WITHIN <cutoff> OF <protein>'
# must update every time step
ns_w = NS.AtomNeighborSearch(solvent) # build kd-tree on solvent (N_w > N_protein)
group = ns_w.search_list(protein, cutoff) # solvent within CUTOFF of protein
return group.coordinates()
return group.positions
else:
# slower distance matrix based (calculate all with all distances first)
dist = np.zeros((len(solvent), len(protein)), dtype=np.float64)
Expand All @@ -616,8 +616,8 @@ def notwithin_coordinates(cutoff=cutoff):
aggregatefunc = np.any

def notwithin_coordinates(cutoff=cutoff):
s_coor = solvent.coordinates()
p_coor = protein.coordinates()
s_coor = solvent.positions
p_coor = protein.positions
# Does water i satisfy d[i,j] > r for ALL j?
d = MDAnalysis.analysis.distances.distance_array(s_coor, p_coor, box=box, result=dist)
return s_coor[aggregatefunc(compare(d, cutoff), axis=1)]
Expand Down Expand Up @@ -751,7 +751,7 @@ def __init__(self, pdb, delta=1.0, atomselection='resname HOH and name O',
"""
u = MDAnalysis.as_Universe(pdb)
group = u.select_atoms(atomselection)
coord = group.coordinates()
coord = group.positions
logger.info("Selected {0:d} atoms ({1!s}) out of {2:d} total.".format(coord.shape[0], atomselection, len(u.atoms)))
smin = np.min(coord, axis=0) - padding
smax = np.max(coord, axis=0) + padding
Expand Down
4 changes: 2 additions & 2 deletions package/MDAnalysis/analysis/gnm.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def generate_kirchoff(self):
the cutoff. Returns the resulting matrix
'''
#ca = self.u.select_atoms(self.selection)
positions = self.ca.coordinates()
positions = self.ca.positions

natoms = len(positions)

Expand Down Expand Up @@ -320,7 +320,7 @@ def __init__(self, universe, selection='protein', cutoff=4.5, ReportVector=None,
def generate_kirchoff(self):
natoms = len(self.ca.atoms)
nresidues = len(self.ca.residues)
positions = self.ca.coordinates()
positions = self.ca.positions
[res_positions, grid, low_x, low_y, low_z] = generate_grid(positions, self.cutoff)
residue_index_map = [resnum for [resnum, residue] in enumerate(self.ca.residues) for atom in residue]
matrix = np.zeros((nresidues, nresidues), "float")
Expand Down
4 changes: 2 additions & 2 deletions package/MDAnalysis/analysis/helanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def helanal_trajectory(universe, selection="name CA", start=None, end=None, begi
if trajectory.time > finish:
break

ca_positions = ca.coordinates()
ca_positions = ca.positions
twist, bending_angles, height, rnou, origins, local_helix_axes, local_screw_angles = \
main_loop(ca_positions, ref_axis=ref_axis)

Expand Down Expand Up @@ -515,7 +515,7 @@ def helanal_main(pdbfile, selection="name CA", start=None, end=None, ref_axis=No
logger.info("Analysing %d/%d residues", ca.n_atoms, universe.atoms.n_residues)

twist, bending_angles, height, rnou, origins, local_helix_axes, local_screw_angles = \
main_loop(ca.coordinates(), ref_axis=ref_axis)
main_loop(ca.positions, ref_axis=ref_axis)

#TESTED- origins are correct
#print current_origin
Expand Down
10 changes: 5 additions & 5 deletions package/MDAnalysis/analysis/nuclinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ def phase_cp(universe, seg, i):
atom4 = universe.select_atoms(" atom {0!s} {1!s} C3\' ".format(seg, i))
atom5 = universe.select_atoms(" atom {0!s} {1!s} C4\' ".format(seg, i))

data1 = atom1.coordinates()
data2 = atom2.coordinates()
data3 = atom3.coordinates()
data4 = atom4.coordinates()
data5 = atom5.coordinates()
data1 = atom1.positions
data2 = atom2.positions
data3 = atom3.positions
data4 = atom4.positions
data5 = atom5.positions

r0 = (data1 + data2 + data3 + data4 + data5) * (1.0 / 5.0)
r1 = data1 - r0
Expand Down
4 changes: 2 additions & 2 deletions package/MDAnalysis/analysis/rms.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def run(self, start=None, stop=None, step=None,
ref_coordinates_T_64 = ref_coordinates.T.astype(np.float64)

# allocate the array for selection atom coords
traj_coordinates = traj_atoms.coordinates().copy()
traj_coordinates = traj_atoms.positions.copy()

if self.groupselections_atoms:
# Only carry out a rotation if we want to calculate secondary
Expand All @@ -468,7 +468,7 @@ def run(self, start=None, stop=None, step=None,
# shift coordinates for rotation fitting
# selection is updated with the time frame
x_com = traj_atoms.center_of_mass().astype(np.float32)
traj_coordinates[:] = traj_atoms.coordinates() - x_com
traj_coordinates[:] = traj_atoms.positions - x_com

rmsd[k, :2] = ts.frame, trajectory.time

Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/coordinates/CRD.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def write(self, selection, frame=None):
frame = 0 # should catch cases when we are analyzing a single PDB (?)

atoms = selection.atoms # make sure to use atoms (Issue 46)
coor = atoms.coordinates() # can write from selection == Universe (Issue 49)
coor = atoms.positions # can write from selection == Universe (Issue 49)
with util.openany(self.filename, 'w') as self.crd:
self._TITLE("FRAME " + str(frame) + " FROM " + str(u.trajectory.filename))
self._TITLE("")
Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/coordinates/PDBQT.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def write(self, selection, frame=None):
self.TITLE("FRAME " + str(frame) + " FROM " + str(u.trajectory.filename))
self.CRYST1(self.convert_dimensions_to_unitcell(u.trajectory.ts))
atoms = selection.atoms # make sure to use atoms (Issue 46)
coor = atoms.coordinates() # can write from selection == Universe (Issue 49)
coor = atoms.positions # can write from selection == Universe (Issue 49)

# check if any coordinates are illegal (coordinates are already in Angstroem per package default)
if not self.has_valid_coordinates(self.pdb_coor_limits, coor):
Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/coordinates/PQR.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def write(self, selection, frame=None):
frame = 0 # should catch cases when we are analyzing a single frame(?)

atoms = selection.atoms # make sure to use atoms (Issue 46)
coordinates = atoms.coordinates() # can write from selection == Universe (Issue 49)
coordinates = atoms.positions # can write from selection == Universe (Issue 49)
if self.convert_units:
self.convert_pos_to_native(coordinates) # inplace because coordinates is already a copy

Expand Down
Loading