Ejemplo n.º 1
0
 def test_rmsd_to_same(self):
     a1 = np.array([[1., 1., 1.], [0., 0., 0.], [-1., -1., -1.]])
     a2 = np.array([[1., 2., 1.], [0., -1., 0.], [-1., -1., -1.]])
     self.assertAlmostEqual(ftme.drmsd(a1, a1), 0)
     self.assertAlmostEqual(ftme.drmsd(a2, a2), 0)
     self.assertAlmostEqual(ftme.rmsd(a1, a1), 0)
     self.assertAlmostEqual(ftme.rmsd(a2, a2), 0)
Ejemplo n.º 2
0
 def test_rmsd_to_same(self):
     a1 = np.array([[1., 1., 1.], [0., 0., 0.], [-1., -1., -1.]])
     a2 = np.array([[1., 2., 1.], [0., -1., 0.], [-1., -1., -1.]])
     self.assertAlmostEqual(ftme.drmsd(a1, a1), 0)
     self.assertAlmostEqual(ftme.drmsd(a2, a2), 0)
     self.assertAlmostEqual(ftme.rmsd(a1, a1), 0)
     self.assertAlmostEqual(ftme.rmsd(a2, a2), 0)
Ejemplo n.º 3
0
 def update(self, sm, step):
     if not self.silent:
         curr_vress=sm.bg.get_ordered_virtual_residue_poss()
         if self.mode=="RMSD":
           rmsd=ftme.rmsd(self._reference, curr_vress)
         elif self.mode=="dRMSD":
           rmsd=ftme.drmsd(self._reference, curr_vress)
         if self.best_cgs.can_insert_right((None, rmsd)):
             self.best_cgs.insert_right((sm.bg.to_cg_string(),rmsd))
         if step % 10 == 0:
             for i, bg in enumerate(self.best_cgs):
                 with open(os.path.join(conf.Configuration.sampling_output_dir,
                           'best_rmsd{:d}.coord'.format(i)), 'w') as f:
                     f.write(bg[0])
         if self._showMinMax:
             if rmsd>self._maxRMSD:
                 self._maxRMSD=rmsd
             if self._showMinMax==True:
                 if rmsd<self._minRMSD:
                     self._minRMSD=rmsd
                 self.history[1].append( self._minRMSD )
             self.history[0].append( rmsd )
             self.history[-1].append( self._maxRMSD )
             if self._showMinMax=="max":
                   return "{:6.3f} A\t{:6.3f} A".format(rmsd, self._maxRMSD)
             else:
                 return "{:6.3f} A\t{:6.3f} A\t{:6.3f} A".format(rmsd, self._minRMSD, self._maxRMSD)
         else:
             self.history[0].append( rmsd )
             return "{:6.3f} A".format(rmsd)
     else:
         return
Ejemplo n.º 4
0
 def update(self, sm, step):
     if not self.silent:
         if self.res_ids:
             curr_vress = []
             for res in self.res_ids:
                 curr_vress.append(
                     sm.bg.get_virtual_residue(res,
                                               allow_single_stranded=True))
             curr_vress = np.array(curr_vress)
         else:
             curr_vress = sm.bg.get_ordered_virtual_residue_poss()
         if self.mode == "RMSD":
             try:
                 rmsd = ftme.rmsd(self._reference, curr_vress)
             except Exception as e:
                 self.res_ids = set(self.reference_cg.seq._seqids) & set(
                     sm.bg.seq._seqids)
                 self._reference = []
                 curr_vress = []
                 for res in self.res_ids:
                     curr_vress.append(
                         sm.bg.get_virtual_residue(
                             res, allow_single_stranded=True))
                     self._reference.append(
                         self.reference_cg.get_virtual_residue(
                             res, allow_single_stranded=True))
                 curr_vress = np.array(curr_vress)
                 self._reference = np.array(self._reference)
                 log.error("Calculating rmsd between %s and %s",
                           self._reference, curr_vress)
                 rmsd = ftme.rmsd(self._reference, curr_vress)
         elif self.mode == "dRMSD":
             rmsd = ftme.drmsd(self._reference, curr_vress)
         if self.best_cgs.can_insert_right((None, rmsd)):
             self.best_cgs.insert_right((sm.bg.to_cg_string(), rmsd))
         if step % 10 == 0:
             for i, bg in enumerate(self.best_cgs):
                 with open(
                         os.path.join(
                             conf.Configuration.sampling_output_dir,
                             'best_rmsd{:d}.coord'.format(i)), 'w') as f:
                     f.write(bg[0])
         if self._showMinMax:
             if rmsd > self._maxRMSD:
                 self._maxRMSD = rmsd
             if self._showMinMax == True:
                 if rmsd < self._minRMSD:
                     self._minRMSD = rmsd
                 self.history[1].append(self._minRMSD)
             self.history[0].append(rmsd)
             self.history[-1].append(self._maxRMSD)
             if self._showMinMax == "max":
                 return "{:6.3f} A\t{:6.3f} A".format(rmsd, self._maxRMSD)
             else:
                 return "{:6.3f} A\t{:6.3f} A\t{:6.3f} A".format(
                     rmsd, self._minRMSD, self._maxRMSD)
         else:
             self.history[0].append(rmsd)
             return "{:6.3f} A".format(rmsd)
     else:
         return
Ejemplo n.º 5
0
 def test_drmsd(self):
     a1 = np.array([[1., 1., 1.], [0., 0., 0.], [-1., -1., -1.]])
     a2 = np.array([[1., 2., 1.], [0., -1., 0.], [-1., -1., -1.]])
     r = ftme.drmsd(a1, a2)
     self.assertGreater(r, 0)
Ejemplo n.º 6
0
 def test_drmsd(self):
     a1 = np.array([[1., 1., 1.], [0., 0., 0.], [-1., -1., -1.]])
     a2 = np.array([[1., 2., 1.], [0., -1., 0.], [-1., -1., -1.]])
     r = ftme.drmsd(a1, a2)
     self.assertGreater(r, 0)