Commit f2e793ac authored by Jason Swails's avatar Jason Swails
Browse files

-More changes to the API to use camelCase everywhere in the public classes.

- Add a docstring to element.Element.getByMass describing what it does
- Add a new element virtualsite with atomic number 0 (and alias it to extrapoint
  and lonepair)
parent b3ac09e1
......@@ -387,7 +387,7 @@ class CharmmPsfFile(object):
line = psf.readline().strip()
return pointers, data
def write_psf(self, dest, vmd=False):
def writePsf(self, dest, vmd=False):
"""
Writes a PSF file from the stored molecule
......@@ -400,7 +400,7 @@ class CharmmPsfFile(object):
VMD prints it in (i.e., no NUMLP/NUMLPH or MOLNT sections)
Example:
>>> cs = CharmmPsfFile('testfiles/test.psf')
>>> cs.write_psf('testfiles/test2.psf')
>>> cs.writePsf('testfiles/test2.psf')
"""
# See if this is an extended format
ext = 'EXT' in self.flags
......@@ -556,7 +556,7 @@ class CharmmPsfFile(object):
if own_handle:
dest.close()
def load_parameters(self, parmset):
def loadParameters(self, parmset):
"""
Loads parameters from a parameter set that was loaded via CHARMM RTF,
PAR, and STR files.
......@@ -684,7 +684,7 @@ class CharmmPsfFile(object):
if types_are_int:
for atom in self.atom_list: atom.type_to_int()
def set_coordinates(self, positions, velocities=None):
def setCoordinates(self, positions, velocities=None):
"""
This method loads the coordinates and velocity information from an
external object or passed data.
......@@ -719,7 +719,7 @@ class CharmmPsfFile(object):
self.positions = positions
def set_box(self, lengths, angles=None):
def setBox(self, lengths, angles=None):
"""
Sets the periodic box boundary conditions.
......@@ -731,9 +731,9 @@ class CharmmPsfFile(object):
is not None
"""
if len(lengths) != 3:
raise ValueError('set_box requires 3 box lengths')
raise ValueError('setBox requires 3 box lengths')
if angles is not None and len(angles) != 3:
raise ValueError('set_box requires 3 box angles')
raise ValueError('setBox requires 3 box angles')
if angles is None:
angles = [90.0, 90.0, 90.0] * u.degrees
self.box_vectors = _box_vectors_from_lengths_angles(
......@@ -938,7 +938,7 @@ class CharmmPsfFile(object):
# back up the dihedral list
dihedral_list = self.dihedral_list
# Load the parameter set
self.load_parameters(params.condense())
self.loadParameters(params.condense())
hasbox = self.topology.getUnitCellDimensions() is not None
# Set the cutoff distance in nanometers
cutoff = None
......@@ -1403,7 +1403,7 @@ class CharmmPsfFile(object):
return self._velocities
@property
def box_lengths(self):
def boxLengths(self):
""" Return tuple of 3 units """
if self.box_vectors is not None:
return (self.box_vectors[0][0], self.box_vectors[0][1],
......
......@@ -95,11 +95,15 @@ class Element(object):
@staticmethod
def getByMass(mass):
"""
Get the element whose mass is CLOSEST to the requested mass. This method
should not be used for repartitioned masses
"""
# Assume masses are in daltons if they are not units
if not is_quantity(mass):
mass = mass * daltons
diff = mass
best_guess = 'EP'
best_guess = Element._elements_by_atomic_number[0]
for key in Element._elements_by_atomic_number:
element = Element._elements_by_atomic_number[key]
......@@ -133,15 +137,14 @@ class Element(object):
return '<Element %s>' % self.name
# This is for backward compatibility.
def get_by_symbol(symbol):
s = symbol.strip().upper()
return Element._elements_by_symbol[s]
get_by_symbol = Element.getBySymbol
def _pickle_element(element):
return (get_by_symbol, (element.symbol,))
copy_reg.pickle(Element, _pickle_element)
virtualsite = Element( 0, "virtual site", "EP", 0.0*daltons)
hydrogen = Element( 1, "hydrogen", "H", 1.007947*daltons)
deuterium = Element( 1, "deuterium", "D", 2.01355321270*daltons)
helium = Element( 2, "helium", "He", 4.003*daltons)
......@@ -264,3 +267,5 @@ ununhexium = Element(116, "ununhexium", "Uuh", 292*daltons)
# relational operators will work with any chosen name
sulphur = sulfur
aluminium = aluminum
extrapoint = virtualsite
lonepair = virtualsite
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment