Commit c279f85d authored by pjropp's avatar pjropp

Cleaning up main branch

parent fe69d85c
......@@ -1009,6 +1009,8 @@ class FileIO():
def load_MDAnalysis_into(self, *args):
"""
***Note this function is only functional in Scoria_MDA***
Allows import of molecular structure with MDAnalysis.
Requires the :any:`MDAnalysis <MDAnalysis.core.AtomGroup>` library.
......@@ -1020,19 +1022,12 @@ class FileIO():
inizalize a MDAnalysis.Universe object.
"""
# Throwing an informative error for missing module.
if "MDAnalysis" not in sys.modules:
raise ImportError("The MDAnalysis Module is not available.")
# Initializing the MDAnalysis universe with the suppplied args
universe = numpy.mda.Universe(*args)
self.load_MDAnalysis_into_using_universe_object(universe)
self.__parent_molecule.set_filename(args)
print("Compatibility with MDAnalysis objects is not supported in this version.")
def load_MDAnalysis_into_using_universe_object(self, universe):
"""
***Note this function is only functional in Scoria_MDA***
Allows import of molecular structure from an MDAnalysis object.
Requires the :any:`MDAnalysis <MDAnalysis.core.AtomGroup>` library.
......@@ -1043,29 +1038,4 @@ class FileIO():
:param mdanalysis.universe universe: An MDAnalysis universe object to
import.
"""
# Throwing an informative error for missing module.
if not numpy.class_dependency("load MDAnalysis into", "MDANALYSIS"):
return
# Initializing the MDAnalysis universe with the suppplied args
self.__u = universe
# Writing to and reading from a temporary PDB file for atom information
fileDescriptor, tempPDB = tempfile.mkstemp(".PDB")
try:
self.__u.atoms.write(tempPDB)
self.load_pdb_into(tempPDB)
finally:
os.remove(tempPDB)
# Converting the MDA.trajectory data structure to our structure
trajectoryList = []
for frame in self.__u.trajectory:
frameList = []
for coord in frame:
coordList = numpy.vstack(coord).T
frameList.append(coordList)
trajectoryList.append(numpy.vstack(frameList))
self.__parent_molecule.set_trajectory_coordinates(trajectoryList)
print("Compatibility with MDAnalysis objects is not supported in this version.")
......@@ -32,10 +32,9 @@ class Molecule: # here's the actual Molecule class
Examples assume::
>>> import scoria
>>> PSF = "./test_file.psf"
>>> DCD = "./test_file.dcd"
>>> PDB = "./test_file.pdb"
>>> mol = scoria.Molecule()
>>> mol.load_MDAnalysis_into(PSF, DCD)
>>> mol.load_pdb_into(PDB)
"""
def __init__(self, *args):
......@@ -55,7 +54,6 @@ class Molecule: # here's the actual Molecule class
self.geometry = Geometry(self)
# Based on the file type, we will attempt to open the file.
# If the type is not one we recognize, we'll attempt to use MDAnalysis.
if len(args) > 0:
if len(args) == 1:
file = args[0]
......@@ -67,10 +65,6 @@ class Molecule: # here's the actual Molecule class
self.load_pdbqt_trajectory_into(file)
elif file_type == 'PYM':
self.load_pym_into(file)
else:
self.load_MDAnalysis_into(file)
else:
self.load_MDAnalysis_into(*args)
# Information methods
### Wrappers ###
......
......@@ -26,6 +26,6 @@ from scoria.Selections import Selections
# By default, leave these commented out. They require numpy and so break pypy
# compatibility. Just uncomment when you want to test.
# from scoria.unittests.UnitTests import UnitTests
from scoria.unittests.UnitTests import UnitTests
__version__ = "2.0"
......@@ -172,14 +172,6 @@ except:
# through dumbpy.
pass
try:
if force_dumbpy: raise ValueError('Using dumbpy')
import MDAnalysis as mda
dependencies_available.append("MDANALYSIS")
except:
pass
def class_dependency(action, dependency):
"""Determines whether or not a given dependency is available.
......
......@@ -21,9 +21,6 @@ import shutil
#import numpy as np
from scoria import dumbpy as np
try: import MDAnalysis # pypy shouldn't be able to load this.
except: pass
import scoria
import shutil
......@@ -66,6 +63,7 @@ class FileIOTests(unittest.TestCase):
"""
pass
@unittest.skip("Need to implement")
def test_load_pym_into(self):
"""
Testing the ability of the FileIO module to import pym files.
......@@ -167,36 +165,6 @@ class FileIOTests(unittest.TestCase):
self.assertEqual(self.mol.get_total_number_of_atoms(), 401)
self.assertEqual(self.mol.get_remarks(), [" This is a remark."])
def test_load_MDAnalysis_into(self):
"""
Empty test.
"""
test_dcd = self.info_path + 'single_frame.dcd'
test_psf = self.info_path + 'single_frame.psf'
self.mol.load_MDAnalysis_into(test_psf, test_dcd)
self.assertEqual(self.mol.get_total_number_of_atoms(), 401)
self.assertEqual(self.mol.get_remarks()[0:2],
[' Created by DCD plugin\x00',
' \x00\x00\x00REMARKS Created 03 January, 2017 at'])
def test_load_MDAnalysis_into_using_universe_object(self):
"""
Empty test.
"""
test_dcd = self.info_path + 'single_frame.dcd'
test_psf = self.info_path + 'single_frame.psf'
universe = MDAnalysis.Universe(test_psf, test_dcd)
self.mol.load_MDAnalysis_into_using_universe_object(universe)
self.assertEqual(self.mol.get_total_number_of_atoms(), 401)
self.assertEqual(self.mol.get_remarks()[0:2],
[' Created by DCD plugin\x00',
' \x00\x00\x00REMARKS Created 03 January, 2017 at'])
# Test Save functions
def test_save_pym(self):
......
......@@ -23,10 +23,7 @@ from scoria import dumbpy as np
import scoria
try: import MDAnalysis as mda # pypy shouldn't be able to load this.
except: pass
from ..six.moves import range
from scoria.six.moves import range
class InformationTests(unittest.TestCase):
......@@ -43,10 +40,6 @@ class InformationTests(unittest.TestCase):
self.mol = scoria.Molecule(info_path + '3_mol_test.pdb')
self.mdaU = None
try: self.mdaU = mda.Universe(info_path + '3_mol_test.pdb')
except: self.mdaU = None # In case of pypy use
self.accuracy = 4
......@@ -84,17 +77,15 @@ class InformationTests(unittest.TestCase):
"""
center_of_mass = self.mol.get_center_of_mass()
mda_center = center_of_mass # pypy case. Basically now just error
center = center_of_mass # pypy case. Basically now just error
# checking for pypy, since below will
# always be true.
if self.mdaU is not None:
mda_center = self.mdaU.atoms.center_of_mass()
self.assertAlmostEqual(center_of_mass[0], mda_center[0], self.accuracy)
self.assertAlmostEqual(center_of_mass[1], mda_center[1], self.accuracy)
self.assertAlmostEqual(center_of_mass[2], mda_center[2], self.accuracy)
self.assertAlmostEqual(center_of_mass[0], center[0], self.accuracy)
self.assertAlmostEqual(center_of_mass[1], center[1], self.accuracy)
self.assertAlmostEqual(center_of_mass[2], center[2], self.accuracy)
def test_get_atom_information(self):
......@@ -164,15 +155,13 @@ class InformationTests(unittest.TestCase):
"""
geo_center = self.mol.get_geometric_center()
mda_center = geo_center # pypy case. Basically now just error
center = geo_center # pypy case. Basically now just error
# checking for pypy, since below will
# always be true.
if self.mdaU is not None:
mda_center = self.mdaU.atoms.center_of_geometry()
self.assertAlmostEqual(geo_center[0], mda_center[0], self.accuracy)
self.assertAlmostEqual(geo_center[1], mda_center[1], self.accuracy)
self.assertAlmostEqual(geo_center[2], mda_center[2], self.accuracy)
self.assertAlmostEqual(geo_center[0], center[0], self.accuracy)
self.assertAlmostEqual(geo_center[1], center[1], self.accuracy)
self.assertAlmostEqual(geo_center[2], center[2], self.accuracy)
def test_get_total_number_of_atoms(self):
"""
......@@ -190,8 +179,6 @@ class InformationTests(unittest.TestCase):
expected_mass = total_mass # pypy case. Basically now just error
# checking for pypy, since below will
# always be true.
if self.mdaU is not None:
expected_mass = self.mdaU.atoms.total_mass()
self.assertAlmostEqual(total_mass, expected_mass, 1)
......@@ -269,11 +256,12 @@ class InformationTests(unittest.TestCase):
# The bounding box, having several parameters, should have some
# comprehensive tests written for it.
@unittest.skip("Need Bounding Box")
def test_get_default_bounding_box(self):
"""
Tests that the bounding box can be calculated.
"""
test_box = self.mdaU.atoms.bbox()
test_box = []
bounding_box = self.mol.get_bounding_box(None, 0.0, 0)
self.assertAlmostEqual(bounding_box[0][0], test_box[0][0], self.accuracy)
......@@ -286,18 +274,19 @@ class InformationTests(unittest.TestCase):
# Similar to the bounding box tests, we need to check that all
# parameters work properly.
@unittest.skip("Need Bounding SPhere")
def test_get_bounding_sphere(self):
"""
Tests that the bounding sphere can be calculated.
"""
mda_sphere = self.mdaU.atoms.bsphere()
sphere = []
bounding_sphere = self.mol.get_bounding_sphere(None, 0.0, 0)
self.assertAlmostEqual(bounding_sphere[0][0], mda_sphere[1][0], self.accuracy)
self.assertAlmostEqual(bounding_sphere[0][1], mda_sphere[1][1], self.accuracy)
self.assertAlmostEqual(bounding_sphere[0][2], mda_sphere[1][2], self.accuracy)
self.assertAlmostEqual(bounding_sphere[0][0], sphere[1][0], self.accuracy)
self.assertAlmostEqual(bounding_sphere[0][1], sphere[1][1], self.accuracy)
self.assertAlmostEqual(bounding_sphere[0][2], sphere[1][2], self.accuracy)
self.assertAlmostEqual(bounding_sphere[1], mda_sphere[0], self.accuracy)
self.assertAlmostEqual(bounding_sphere[1], sphere[0], self.accuracy)
@unittest.skip("Needs test written")
def test_get_constants(self):
......
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