Esempio n. 1
0
    def align_to(self, target, selection='', template_aligned=None):
        if not template_aligned:
            if not selection:
                selection = 'chain ' + ','.join(target.list_chains().keys())
            aligned = self.template.select(selection)
        else:
            aligned = template_aligned
        pieces = ranges([self.template.atoms.index(a) for a in aligned])

        t = target.to_matrix()
        t_com = np.average(t, 0)
        t = np.subtract(t, t_com)

        shape = self.coordinates.shape
        for model in self.coordinates.reshape(-1, len(self.template), 3):
            query = np.concatenate(
                [model[piece[0]:piece[1]] for piece in pieces])
            q_com = np.average(query, 0)
            q = np.subtract(query, q_com)
            np.copyto(
                model,
                np.add(
                    np.dot(np.subtract(model, q_com),
                           kabsch(t, q, concentric=True)), t_com))
 def test_can_generate_ranges_from_several_ranges(self):
     val = self.simpilfy(u.ranges({
         'units': '2GOZ|1|A|A|3:2GOZ|1|A|A|5,2GOZ|1|B|A|8:2GOZ|1|B|A|50'
     }))
     ans = ('2GOZ', 1, [('A', 3, 5), ('B', 8, 50)])
     self.assertEquals(ans, val)
 def test_can_generate_ranges_from_a_range(self):
     val = self.simpilfy(u.ranges({'units': '2GOZ|1|A|A|3:2GOZ|1|A|A|5'}))
     ans = ('2GOZ', 1, [('A', 3, 5)])
     self.assertEquals(ans, val)
 def test_can_generate_ranges_from_several_single(self):
     val = self.simpilfy(u.ranges({
         'units': '2GOZ|1|A|A|3,2GOZ|1|A|A|4,2GOZ|1|A|A|5'
     }))
     ans = ('2GOZ', 1, [('A', 3, 3), ('A', 4, 4), ('A', 5, 5)])
     self.assertEquals(ans, val)
 def test_can_generate_range_from_one_single(self):
     val = self.simpilfy(u.ranges({'units': '2GOZ|1|A|A|3'}))
     ans = ('2GOZ', 1, [('A', 3, 3)])
     self.assertEquals(ans, val)