Beispiel #1
0
class DockingResult(object):
    """Represents a LightDock docking result line"""
    def __init__(self,
                 id_swarm=0,
                 id_glowworm=0,
                 receptor_id=0,
                 ligand_id=0,
                 luciferin=0.0,
                 num_neighbors=0,
                 vision_range=0.0,
                 pose=None,
                 rmsd=-1.0,
                 pdb_file='',
                 contacts=0,
                 scoring=0.0):
        self.id_swarm = id_swarm
        self.id_glowworm = id_glowworm
        self.receptor_id = receptor_id
        self.ligand_id = ligand_id
        self.luciferin = luciferin
        self.num_neighbors = num_neighbors
        self.vision_range = vision_range
        self.pose = pose
        self.translation = np.array(pose[:3])
        self.rotation = Quaternion(pose[3], pose[4], pose[5],
                                   pose[6]).normalize()
        self.coord = DockingResult.pose_repr(pose)
        self.rmsd = rmsd
        self.pdb_file = pdb_file
        self.contacts = contacts
        self.scoring = scoring

    def __str__(self):
        return "%5d %6d %60s %6d %6d %11.5f %5d %7.3f %8.3f %16s %6d %8.3f" % (
            self.id_swarm, self.id_glowworm, self.coord, self.receptor_id,
            self.ligand_id, self.luciferin, self.num_neighbors,
            self.vision_range, self.rmsd, self.pdb_file, self.contacts,
            self.scoring)

    def distance_trans(self, other):
        return np.linalg.norm(self.translation - other.translation)

    def distance_rot(self, other):
        return self.rotation.distance(other.rotation)

    @staticmethod
    def pose_repr(coord):
        fields = [("%5.3f" % c) for c in coord]
        return "(%s)" % (', '.join(fields))
Beispiel #2
0
class DockingResult(object):
    """Represents a LightDock docking result line"""
    def __init__(self, id_cluster=0, id_glowworm=0, receptor_id=0, ligand_id=0, luciferin=0.0,
                 num_neighbors=0, vision_range=0.0, pose=None, rmsd=-1.0,
                 pdb_file='', contacts=0, scoring=0.0):
        self.id_cluster = id_cluster
        self.id_glowworm = id_glowworm
        self.receptor_id = receptor_id
        self.ligand_id = ligand_id
        self.luciferin = luciferin
        self.num_neighbors = num_neighbors
        self.vision_range = vision_range
        self.pose = pose
        self.translation = np.array(pose[:3])
        self.rotation = Quaternion(pose[3], pose[4], pose[5], pose[6]).normalize()
        self.coord = DockingResult.pose_repr(pose)
        self.rmsd = rmsd
        self.pdb_file = pdb_file
        self.contacts = contacts
        self.scoring = scoring

    def __str__(self):
        return "%5d %6d %60s %6d %6d %11.5f %5d %7.3f %8.3f %16s %6d %8.3f" % (self.id_cluster,
                                                                               self.id_glowworm,
                                                                               self.coord,
                                                                               self.receptor_id,
                                                                               self.ligand_id,
                                                                               self.luciferin,
                                                                               self.num_neighbors,
                                                                               self.vision_range,
                                                                               self.rmsd,
                                                                               self.pdb_file,
                                                                               self.contacts,
                                                                               self.scoring)

    def distance_trans(self, other):
        return np.linalg.norm(self.translation - other.translation)

    def distance_rot(self, other):
        return self.rotation.distance(other.rotation)

    @staticmethod
    def pose_repr(coord):
        fields = [("%5.3f" % c) for c in coord]
        return "(%s)" % (', '.join(fields))
    def test_distance_composite_rotation(self):
        q1 = Quaternion(1.0, 0, 0, 0)
        q2 = Quaternion(0.5, 0.5, 0.5, 0.5)

        assert_almost_equals(0.75, q1.distance(q2))
    def test_distance_is_half(self):
        q1 = Quaternion(0.707106781, 0.0, 0.707106781, 0.0)
        q2 = Quaternion(0, 0, 1.0, 0)

        assert_almost_equals(0.5, q1.distance(q2))
    def test_distance_is_one(self):
        q1 = Quaternion(0.707106781, 0.0, 0.707106781, 0.0)
        q2 = Quaternion(0.707106781, 0.0, -0.707106781, 0.0)

        assert_almost_equals(1.0, q1.distance(q2))
    def test_distance_is_zero(self):
        q = Quaternion(0.707106781, 0.0, 0.707106781, 0.0)

        assert_almost_equals(0.0, q.distance(q))
Beispiel #7
0
    def test_distance_composite_rotation(self):
        q1 = Quaternion(1.0, 0, 0, 0)
        q2 = Quaternion(0.5, 0.5, 0.5, 0.5)

        assert_almost_equals(0.75, q1.distance(q2))
Beispiel #8
0
    def test_distance_is_half(self):
        q1 = Quaternion(0.707106781, 0.0, 0.707106781, 0.0)
        q2 = Quaternion(0, 0, 1.0, 0)

        assert_almost_equals(0.5, q1.distance(q2))
Beispiel #9
0
    def test_distance_is_one(self):
        q1 = Quaternion(0.707106781, 0.0, 0.707106781, 0.0)
        q2 = Quaternion(0.707106781, 0.0, -0.707106781, 0.0)

        assert_almost_equals(1.0, q1.distance(q2))
Beispiel #10
0
    def test_distance_is_zero(self):
        q = Quaternion(0.707106781, 0.0, 0.707106781, 0.0)

        assert_almost_equals(0.0, q.distance(q))