def __init__(self): super(TnpBox, self).__init__() tnp_proto = Tnp(ball_radius=5, n_chains=5, chain_length=8) pattern = mb.Grid3DPattern(3, 3, 3) pattern.scale(100) rnd = random.Random() rnd.seed(1928) for pos in pattern: tnp = clone(tnp_proto) mb.rotate_around_x(tnp, rnd.uniform(0, 2 * pi)) mb.rotate_around_y(tnp, rnd.uniform(0, 2 * pi)) mb.rotate_around_z(tnp, rnd.uniform(0, 2 * pi)) mb.translate(tnp, pos) self.add(tnp)
def __init__(self, c1_pos=None, rotate_random=True): super(C10, self).__init__() num_particles = 10 for index in range(num_particles): self.add(C(), label='C[$]') if c1_pos is not None: mb.translate(self['C'][0], c1_pos) if rotate_random is True: mb.rotate_around_x(self['C'][0], random.uniform(0, 2 * math.pi)) mb.rotate_around_y(self['C'][0], random.uniform(0, 2 * math.pi)) mb.rotate_around_z(self['C'][0], random.uniform(0, 2 * math.pi)) for index in range(num_particles - 1): mb.force_overlap(move_this=self['C'][index + 1], from_positions=self['C'][index + 1]['down'], to_positions=self['C'][index]['up'])
def main(): from mbuild.utils.io import get_fn from mbuild.lib.moieties import H2O water = H2O() ecerns = mb.load(get_fn('ecer2.pdb')) chol = mb.load(get_fn('cg-chol.pdb')) # Orient along the z-direction. mb.rotate_around_x(chol, -135.0*np.pi/180) mb.rotate_around_y(chol, -45.0*np.pi/180) lipids = [(ecerns, 0.5), (chol, 0.5)] bilayer = Bilayer(lipids, n_lipids_x=15, n_lipids_y=15, area_per_lipid=1.4, solvent=water, ref_atoms=[1, 6], spacing_z=0.7, solvent_per_lipid=20, mirror=False) bilayer.save(filename='bilayer.pdb') return bilayer
def __init__(self, alpha=0): super(MPC, self).__init__() # Look for data file in same directory as this python module. mb.load('mpc.pdb', compound=self, relative_to_module=self.__module__) # Transform the coordinate system of mpc such that the two carbon atoms # that are part of the backbone are on the y axis, c_backbone at the origin. C_top = self[37] # this can be achieved with the following alternative syntax: # C_top = self.labels["atom[37]"] # C_top = self.labels["atom"][37] C_bottom = self[1] mb.y_axis_transform(self, new_origin=C_top, point_on_y_axis=C_bottom) # Add top port. self.add(mb.Port(anchor=C_top), label='up') mb.translate(self['up'], C_top.pos - (C_top.pos - C_bottom.pos)*1.50) # Add bottom port self.add(mb.Port(anchor=C_bottom), 'down') mb.rotate_around_y(self['down'], alpha) mb.translate(self['down'], C_bottom.pos - (C_bottom.pos - C_top.pos)*1.50)