def main(): usage = """ python random_subgraph_radius_of_gyration.py file.cg """ num_args= 0 parser = OptionParser(usage=usage) #parser.add_option('-o', '--options', dest='some_option', default='yo', help="Place holder for a real option", type='str') parser.add_option('-i', '--iterations', dest='iterations', default=1, help="The number of iterations to perform", type='int') #parser.add_option('-u', '--useless', dest='uselesss', default=False, action='store_true', help='Another useless option') (options, args) = parser.parse_args() if len(args) < num_args: parser.print_help() sys.exit(1) cg = ftmc.CoarseGrainRNA(args[0]) for i in range(options.iterations): sg = cg.random_subgraph() stems = [s for s in sg if s[0] == 's'] if len(stems) == 0: continue coords = [] for s in stems: coords += [cg.coords[s][0]] coords += [cg.coords[s][1]] rmsd = ftmd.radius_of_gyration(coords) total_length = sum([len(list(cg.define_residue_num_iterator(d))) for d in sg]) print(total_length, rmsd)
def main(): usage = """ python random_subgraph_radius_of_gyration.py file.cg """ num_args= 0 parser = OptionParser(usage=usage) #parser.add_option('-o', '--options', dest='some_option', default='yo', help="Place holder for a real option", type='str') parser.add_option('-i', '--iterations', dest='iterations', default=1, help="The number of iterations to perform", type='int') #parser.add_option('-u', '--useless', dest='uselesss', default=False, action='store_true', help='Another useless option') (options, args) = parser.parse_args() if len(args) < num_args: parser.print_help() sys.exit(1) cg = ftmc.CoarseGrainRNA(args[0]) for i in range(options.iterations): sg = cg.random_subgraph() stems = [s for s in sg if s[0] == 's'] if len(stems) == 0: continue coords = [] for s in stems: coords += [cg.coords[s][0]] coords += [cg.coords[s][1]] rmsd = ftmd.radius_of_gyration(coords) total_length = sum([len(list(cg.define_residue_num_iterator(d))) for d in sg]) print total_length, rmsd
def test_gyration_tensor_vs_rog(self): a1 = np.array([[1., 1., 1.], [0., 0., 0.], [-1., -1., -1.], [-2, -2, -2]]) rog = ftmd.radius_of_gyration(a1) g_tensor = ftmd.gyration_tensor(a1, diagonalize=True) print(rog, g_tensor) #the first invariant is the rog self.assertAlmostEqual( g_tensor[0, 0] + g_tensor[1, 1] + g_tensor[2, 2], rog**2)
def test_gyration_tensor_vs_rog(self): a1 = np.array([[1., 1., 1.], [0., 0., 0.], [-1., -1., -1.], [-2, -2, -2]]) rog = ftmd.radius_of_gyration(a1) g_tensor = ftmd.gyration_tensor(a1, diagonalize=True) print(rog, g_tensor) # the first invariant is the rog self.assertAlmostEqual( g_tensor[0, 0] + g_tensor[1, 1] + g_tensor[2, 2], rog**2)
def main(): usage = """ python cg_rmsd.py file1.cg Calculate the ROG of a coarse grain models. """ num_args = 1 parser = OptionParser(usage=usage) #parser.add_option('-o', '--options', dest='some_option', default='yo', help="Place holder for a real option", type='str') #parser.add_option('-u', '--useless', dest='uselesss', default=False, action='store_true', help='Another useless option') (options, args) = parser.parse_args() if len(args) < num_args: parser.print_help() sys.exit(1) cg1 = ftmc.CoarseGrainRNA(args[0]) coords = cg1.get_ordered_stem_poss() print ftmd.radius_of_gyration(coords)
def main(): usage = """ python cg_rmsd.py file1.cg Calculate the ROG of a coarse grain models. """ num_args= 1 parser = OptionParser(usage=usage) #parser.add_option('-o', '--options', dest='some_option', default='yo', help="Place holder for a real option", type='str') #parser.add_option('-u', '--useless', dest='uselesss', default=False, action='store_true', help='Another useless option') (options, args) = parser.parse_args() if len(args) < num_args: parser.print_help() sys.exit(1) cg1 = ftmc.CoarseGrainRNA(args[0]) coords = cg1.get_ordered_stem_poss() print ftmd.radius_of_gyration(coords)
def _get_descriptor(self, descriptor, domain=None): """ :param ensemble: an Ensemble or EnsembleView object :param descriptor: A STRING. One of AVAILABLE_DESCRIPTORS :param domain: An iterable of cg element names or None (whole cg) :returns: A np.array """ if descriptor not in self.AVAILABLE_DESCRIPTORS: raise ValueError("Descriptor {} not available.".format(descriptor)) if descriptor == "rog": if domain: return np.array([ ftmd.radius_of_gyration( cg.get_poss_for_domain(domain, "vres")) for cg in self ]) else: return np.array([cg.radius_of_gyration() for cg in self]) elif descriptor == "anisotropy": if domain: return np.array([ ftmd.anisotropy(cg.get_poss_for_domain(domain, "vres")) for cg in self ]) else: return np.array([ ftmd.anisotropy(cg.get_ordered_stem_poss()) for cg in self ]) elif descriptor == "asphericity": if domain: return np.array([ ftmd.asphericity(cg.get_poss_for_domain(domain, "vres")) for cg in self ]) else: return np.array([ ftmd.asphericity(cg.get_ordered_stem_poss()) for cg in self ])
def _get_descriptor(self, descriptor, domain=None): """ :param ensemble: an Ensemble or EnsembleView object :param descriptor: A STRING. One of AVAILABLE_DESCRIPTORS :param domain: An iterable of cg element names or None (whole cg) :returns: A np.array """ if descriptor not in self.AVAILABLE_DESCRIPTORS: raise ValueError("Descriptor {} not available.".format(descriptor)) if descriptor == "rog": if domain: return np.array([ftmd.radius_of_gyration(cg.get_poss_for_domain(domain, "vres")) for cg in self]) else: return np.array([cg.radius_of_gyration() for cg in self]) elif descriptor == "anisotropy": if domain: return np.array([ftmd.anisotropy(cg.get_poss_for_domain(domain, "vres")) for cg in self]) else: return np.array([ftmd.anisotropy(cg.get_ordered_stem_poss()) for cg in self]) elif descriptor == "asphericity": if domain: return np.array([ftmd.asphericity(cg.get_poss_for_domain(domain, "vres")) for cg in self]) else: return np.array([ftmd.asphericity(cg.get_ordered_stem_poss()) for cg in self])
def test_radius_of_gyration(self): a = np.array([[1., 1., 1.], [0., 0., 0.], [-1., -1., -1.]]) r = ftmd.radius_of_gyration(a) self.assertGreater(r, 0) self.assertAlmostEqual(r, math.sqrt(2))
def update(self, sm, step): rog = ftur.radius_of_gyration(sm.bg.get_ordered_stem_poss()) self.history[0].append(rog) return "{:6.2f} A".format(rog)
def update(self, sm, step): rog=ftur.radius_of_gyration(sm.bg.get_ordered_stem_poss()) self.history[0].append(rog) return "{:6.2f} A".format(rog)
def test_radius_of_gyration(self): a = np.array([[1., 1., 1.], [0., 0., 0.], [-1., -1., -1.]]) r = ftmd.radius_of_gyration(a) self.assertGreater(r, 0) self.assertAlmostEqual(r, math.sqrt(2))