Example #1
0
def color_op(surfaces, color = None):

    from Commands import parse_surfaces, parse_color
    surfs = parse_surfaces(surfaces)

    if color == 'byatom':
        from chimera import MSMSModel
        if [s for s in surfs if not isinstance(s, MSMSModel)]:
            raise CommandError, 'Cannot color byatom non-molecular surfaces'
    elif not color is None:
        color = parse_color(color)

    for surf in surfs:
        import SurfaceColor as sc
        sc.stop_coloring_surface(surf)
        if color == 'byatom':
            surf.colorMode = surf.ByAtom
        elif not color is None:
            import Surface
            Surface.set_coloring_method('static', surf)
            from chimera import MSMSModel
            if isinstance(surf, MSMSModel):
                surf.customRGBA = [color] * surf.vertexCount
            else:
                for p in surf.surfacePieces:
                    p.color = color
Example #2
0
def color_op(surfaces, color=None):

    from Commands import parse_surfaces, parse_color
    surfs = parse_surfaces(surfaces)

    if color == 'byatom':
        from chimera import MSMSModel
        if [s for s in surfs if not isinstance(s, MSMSModel)]:
            raise CommandError, 'Cannot color byatom non-molecular surfaces'
    elif not color is None:
        color = parse_color(color)

    for surf in surfs:
        import SurfaceColor as sc
        sc.stop_coloring_surface(surf)
        if color == 'byatom':
            surf.colorMode = surf.ByAtom
        elif not color is None:
            import Surface
            Surface.set_coloring_method('static', surf)
            from chimera import MSMSModel
            if isinstance(surf, MSMSModel):
                surf.customRGBA = [color] * surf.vertexCount
            else:
                for p in surf.surfacePieces:
                    p.color = color
Example #3
0
 def add_Surface(self, surf):
     if type(surf) == str:
         surf = Surface(surf)
     if self.reference_surface_name is None:
         self.reference_surface_name = surf.name
     surf.parent = self
     self.surfaces[surf.name] = surf
Example #4
0
 def __init__(self):
     pygame.init()
     self.s = Surface((0, 0), "Ball Fall", black)
     self.s.draw_surface()
     self.run_game = True
     self.score = 0
     self.d = database()
Example #5
0
    def __init__(self,
                 molecule,
                 category,
                 probeRadius=1.4,
                 allComponents=True,
                 vertexDensity=2.0):

        SurfaceModel.__init__(self)

        name = 'MSMS %s surface of %s' % (category, molecule.name)
        SurfaceModel.__setattr__(self, 'name', name)
        SurfaceModel.__setattr__(self, 'piecesAreSelectable', True)
        SurfaceModel.__setattr__(self, 'oneTransparentLayer', True)

        init = {
            'molecule': molecule,
            'colorMode': self.ByAtom,
            'visibilityMode': self.ByAtom,
            'density': vertexDensity,
            'probeRadius': probeRadius,
            'category': category,
            'allComponents': allComponents,
            'atomMap': None,  # vertex number to Atom
            'surface_piece': None,
            'srf': None,  # MSMS surface object
            'triData': None,  # MSMS triangle data
            'areaSES': 0.0,
            'areaSAS': 0.0,
            'calculationFailed': False,
        }
        self.__dict__.update(init)

        from _surface import SurfacePiece
        self.surface_piece_defaults = {
            'drawMode': self.Filled,
            'lineWidth': 1.0,
            'pointSize': 1.0,
            'useLighting': True,
            'twoSidedLighting': True,
            'smoothLines': False,
            'transparencyBlendMode': SurfacePiece.SRC_ALPHA_DST_1_MINUS_ALPHA,
        }

        self.update_surface()

        # Detect changes in atom color, atom surfaceColor, atom surfaceOpacity,
        #   molecule color, atom surfaceDisplay.
        from chimera import triggers as t
        self.molecule_handler = t.addHandler('Molecule', self.molecule_cb,
                                             None)

        # Detect when surface or molecule deleted.
        from chimera import addModelClosedCallback
        addModelClosedCallback(self, self.surface_closed_cb)
        addModelClosedCallback(self.molecule, self.molecule_closed_cb)

        import Surface
        Surface.set_coloring_method('msms', self, self.custom_coloring)
        Surface.set_visibility_method('msms', self, self.custom_visibility)
Example #6
0
class GFXEngine :

	"""
	This class draws the gfx
	"""

	def __init__ (self, lll, viewspace, mymap):
	
		self.lll = lll
		self.display = Display ()
		self.viewspace = viewspace
		self.mymap = mymap
		self.terrainset = TerrainSet ()
		
		# Test
		self.settsurf = Surface ()
		self.settsurf.loadFromFile ("gfx/protosettler.png")
		self.settsurf.cols = 16
		self.settsurf.rows = 16

		self.sprites = []
		
	def create_settler(self, x, y):
		""" Adds a settler to be drawn on the screen at position x, y and returns a reference to this settler. """

		sprite = Sprite (self.viewspace, self.settsurf)
		sprite.x = x
		sprite.y = y
		sprite.configAnimation (True, 0, 24, 25)
		self.sprites.append(sprite)
		return sprite

	
	def tick (self):
	
		"""
		tick() executes all actions which must be done by the GFX-Engine in one Game-Loop-cycle
		This is: clearing the screen, drawing all objects, showing the new game-frame
		"""
	
		self.display.clear ()
		self.draw ()
		for sprite in self.sprites:
			sprite.drawToDisplay (self.display)
		self.display.showFrame ()

	def draw (self):
	
		self.drawLandscape ()
	
	def drawLandscape (self):
	
		self.drawTerrain ()

	def drawTerrain (self):
	
		self.lll.view.DrawTerrain (self.mymap.terra.asCArray (), self.mymap.mapsize, TRIA_W, TRIA_H,
			TEX_FACTOR, self.terrainset.asCArray(), self.mymap.getVertarray().asCArray())
Example #7
0
	def __init__ (self):
	
		self.tcount = len(TERRAIN_TEXTURE_FILES)
		self.data = []
		for terrafilename in TERRAIN_TEXTURE_FILES :
			newsurf = Surface ()
			newsurf.loadFromFile (TERRAIN_PNG_DIR +"/"+ terrafilename, True)
			self.data.append (newsurf)
		self.carr = None
Example #8
0
def colorMSMSSurface(s, color):
	if s.colorMode == s.Custom or s.molecule is None:
		import Surface
		Surface.set_coloring_method('static', s, None)
		s.customColors = s.vertexCount * [color]
	elif s.colorMode == s.ByMolecule:
		s.molecule.surfaceColor = color
	elif s.colorMode == s.ByAtom:
		for a in s.atoms:
			a.surfaceColor = color
Example #9
0
def colorMSMSSurface(s, color):
    if s.colorMode == s.Custom or s.molecule is None:
        import Surface
        Surface.set_coloring_method('static', s, None)
        s.customColors = s.vertexCount * [color]
    elif s.colorMode == s.ByMolecule:
        s.molecule.surfaceColor = color
    elif s.colorMode == s.ByAtom:
        for a in s.atoms:
            a.surfaceColor = color
Example #10
0
    def __setattr__(self, attrname, value):

        if attrname in ('drawMode', 'lineWidth', 'pointSize', 'useLighting',
                        'twoSidedLighting', 'smoothLines',
                        'transparencyBlendMode'):
            # SurfacePiece attributes
            if value == getattr(self, attrname):
                return
        elif attrname in ('colorMode', 'visibilityMode', 'density',
                          'probeRadius', 'category', 'allComponents'):
            if value == getattr(self, attrname):
                return
            self.__dict__[attrname] = value
        elif attrname not in ('customColors', 'customRGBA'):
            SurfaceModel.__setattr__(self, attrname, value)
            return

        if attrname in ('density', 'probeRadius', 'category', 'allComponents'):
            self.update_surface()
        else:
            p = self.surface_piece
            if p is None or p.__destroyed__:
                return
            if attrname == 'drawMode':
                style = {
                    self.Filled: p.Solid,
                    self.Mesh: p.Mesh,
                    self.Dot: p.Dot,
                }[value]
                p.displayStyle = style
            elif attrname == 'lineWidth':
                p.lineThickness = value
            elif attrname == 'pointSize':
                p.dotSize = value
            elif attrname in ('useLighting', 'twoSidedLighting', 'smoothLines',
                              'transparencyBlendMode'):
                setattr(p, attrname, value)
            elif attrname == 'colorMode':
                if value != self.Custom:
                    import Surface
                    Surface.set_coloring_method('msms', self,
                                                self.custom_coloring)
                    self.update_coloring()
            elif attrname == 'visibilityMode':
                if value == self.ByAtom:
                    import Surface
                    Surface.set_visibility_method('msms', self,
                                                  self.custom_visibility)
                    self.update_visibility()
            elif attrname == 'customColors':
                self.set_custom_colors(value)
            elif attrname == 'customRGBA':
                self.set_custom_rgba(value)

        self.report_change(self.change_reason[attrname])
Example #11
0
    def __setattr__(self, attrname, value):

        if attrname in ('drawMode', 'lineWidth', 'pointSize', 'useLighting',
                        'twoSidedLighting', 'smoothLines',
                        'transparencyBlendMode'):
            # SurfacePiece attributes
            if value == getattr(self, attrname):
                return
        elif attrname in ('colorMode', 'visibilityMode',
                          'density', 'probeRadius',
                          'category', 'allComponents'):
            if value == getattr(self, attrname):
                return
            self.__dict__[attrname] = value
        elif attrname not in ('customColors', 'customRGBA'):
            SurfaceModel.__setattr__(self, attrname, value)
            return

        if attrname in ('density', 'probeRadius', 'category', 'allComponents'):
            self.update_surface()
        else:
            p = self.surface_piece
            if p is None or p.__destroyed__:
                return
            if attrname == 'drawMode':
                style = {self.Filled: p.Solid,
                         self.Mesh: p.Mesh,
                         self.Dot:  p.Dot,
                         }[value]
                p.displayStyle = style
            elif attrname == 'lineWidth':
                p.lineThickness = value
            elif attrname == 'pointSize':
                p.dotSize = value
            elif attrname in ('useLighting', 'twoSidedLighting', 'smoothLines',
                              'transparencyBlendMode'):
                setattr(p, attrname, value)
            elif attrname == 'colorMode':
                if value != self.Custom:
                    import Surface
                    Surface.set_coloring_method('msms', self,
                                                self.custom_coloring)
                    self.update_coloring()
            elif attrname == 'visibilityMode':
                if value == self.ByAtom:
                    import Surface
                    Surface.set_visibility_method('msms', self,
                                                  self.custom_visibility)
                    self.update_visibility()
            elif attrname == 'customColors':
                self.set_custom_colors(value)
            elif attrname == 'customRGBA':
                self.set_custom_rgba(value)

        self.report_change(self.change_reason[attrname])
Example #12
0
    def __init__(self, molecule, category, probeRadius = 1.4,
                 allComponents = True, vertexDensity = 2.0):

        SurfaceModel.__init__(self)

        name = 'MSMS %s surface of %s' % (category, molecule.name)
        SurfaceModel.__setattr__(self, 'name', name)
        SurfaceModel.__setattr__(self, 'piecesAreSelectable', True)
        SurfaceModel.__setattr__(self, 'oneTransparentLayer', True)

        init = {
            'molecule': molecule,
            'colorMode': self.ByAtom,
            'visibilityMode': self.ByAtom,
            'density': vertexDensity,
            'probeRadius': probeRadius,
            'category': category,
            'allComponents': allComponents,
            'atomMap': None,            # vertex number to Atom
            'surface_piece': None,
            'srf': None,                # MSMS surface object
            'triData': None,            # MSMS triangle data
            'areaSES': 0.0,
            'areaSAS': 0.0,
	    'calculationFailed': False,
            }
        self.__dict__.update(init)

        from _surface import SurfacePiece
        self.surface_piece_defaults = {
            'drawMode': self.Filled,
            'lineWidth': 1.0,
            'pointSize': 1.0,
            'useLighting': True,
            'twoSidedLighting': True,
            'smoothLines': False,
            'transparencyBlendMode': SurfacePiece.SRC_ALPHA_DST_1_MINUS_ALPHA,
            }

        self.update_surface()

        # Detect changes in atom color, atom surfaceColor, atom surfaceOpacity,
        #   molecule color, atom surfaceDisplay.
        from chimera import triggers as t
        self.molecule_handler = t.addHandler('Molecule', self.molecule_cb, None)

        # Detect when surface or molecule deleted.
        from chimera import addModelClosedCallback
        addModelClosedCallback(self, self.surface_closed_cb)
        addModelClosedCallback(self.molecule, self.molecule_closed_cb)

        import Surface
        Surface.set_coloring_method('msms', self, self.custom_coloring)
        Surface.set_visibility_method('msms', self, self.custom_visibility)
Example #13
0
def adjustSurfacePieceTransparency(p, opacity, frac=1):

    rgba = list(p.color)
    rgba[3] = frac * opacity + (1 - frac) * rgba[3]
    p.color = tuple(rgba)
    vrgba = p.vertexColors
    if not vrgba is None:
        import Surface
        Surface.set_coloring_method('static', p.model, None)
        vrgba[:, 3] *= 1 - frac
        vrgba[:, 3] += frac * opacity
        p.vertexColors = vrgba
Example #14
0
def adjustSurfacePieceTransparency(p, opacity, frac = 1):

	rgba = list(p.color)
	rgba[3] = frac*opacity + (1-frac)*rgba[3]
	p.color = tuple(rgba)
	vrgba = p.vertexColors
	if not vrgba is None:
		import Surface
		Surface.set_coloring_method('static', p.model, None)
		vrgba[:,3] *= 1-frac
		vrgba[:,3] += frac*opacity
		p.vertexColors = vrgba
Example #15
0
def distance(operation,
             object1,
             object2,
             multiple=False,
             show=False,
             color=(0, 1, 1, 1)):

    a1 = object1.atoms()
    import Surface as s
    s1 = s.selected_surface_pieces(object1, include_outline_boxes=False)

    if len(a1) == 0 and len(s1) == 0:
        raise CommandError('No atoms or surfaces specified')

    a2 = object2.atoms()
    s2 = s.selected_surface_pieces(object2, include_outline_boxes=False)

    if len(a2) == 0 and len(s2) == 0:
        raise CommandError('No target atoms or surfaces')

    # Remove near stuff.
    if a1:
        a2 = list(set(a2).difference(a1))
    if s1:
        s2 = list(set(s2).difference(s1))

    name2 = object_name(a2, s2)
    xyz2 = point_array(a2, s2)

    if show:
        from Commands import parse_color
        color = parse_color(color)
        from _surface import SurfaceModel
        surf = SurfaceModel()
        surf.name = 'Distance measurement'
        from chimera import openModels
        openModels.add([surf])
    else:
        surf = None

    if multiple:
        pairs = [([a], []) for a in a1] + [([], [s]) for s in s1]
    else:
        pairs = [(a1, s1)]

    for a, s in pairs:
        name = object_name(a, s)
        xyz = point_array(a, s)
        report_distance(xyz, xyz2, name, name2, surf, color)
Example #16
0
def spine(operation,
          regions,
          spacing=None,
          tipLength=None,
          color=None,
          showDiameter=False):

    sel = parse_object_specifier(regions, 'segmentation region')

    import Surface
    plist = Surface.selected_surface_pieces(sel, include_outline_boxes=False)
    from Segger.regions import Segmentation
    rlist = [
        p.region for p in plist
        if (hasattr(p, 'region') and isinstance(p.model, Segmentation))
    ]
    if len(rlist) == 0:
        raise CommandError('No segmentation regions specified: "%s"' % regions)

    if not (spacing is None or isinstance(spacing,
                                          (int, float)) and spacing > 0):
        raise CommandError('spacing must be positive numeric value')
    if not (tipLength is None or isinstance(tipLength,
                                            (int, float)) and tipLength > 0):
        raise CommandError('tipLength must be positive numeric value')

    if not color is None:
        from Commands import parse_color
        color = parse_color(color)

    if showDiameter:
        from _surface import SurfaceModel
        diam_model = SurfaceModel()
        diam_model.name = 'Diameters'
        from chimera import openModels
        openModels.add([diam_model], sameAs=rlist[0].segmentation)
    else:
        diam_model = None

    import spine
    from chimera import replyobj
    from PathLength import path_length
    for r in rlist:
        mset = spine.trace_spine(r, spacing, tipLength, color)
        slen = path_length([l.bond for l in mset.links()])
        r.set_attribute('spine length', slen)
        msg = 'Spine length for region %d is %.4g' % (r.rid, slen)
        dmax, dmin = spine.measure_diameter(r, mset, diam_model)
        if not dmax is None:
            r.set_attribute('diameter1', dmax)
            r.set_attribute('diameter2', dmin)
            msg += ', diameters %.4g, %.4g' % (dmax, dmin)
        kave, kmin, kmax = spine.measure_curvature(mset)
        if not kmax is None:
            r.set_attribute('curvature average', kave)
            r.set_attribute('curvature minimum', kmin)
            r.set_attribute('curvature maximum', kmax)
            msg += ', curvature %.4g (ave), %.4g (max), %.4g (min)' % (
                kave, kmax, kmin)
        replyobj.info(msg + '\n')
def runAll(mol, surface, molClass):
    resultPath(mol, molClass)
    au_a = 4.06  # Lattice constant of gold
    relative_coverage = 1.0
    Density = 21.6 * relative_coverage  # Angstroms^2/chain
    GOLD_Obj = Surface.Surface(
        data.getSurface(surface))  # Make gold "Surface Object"
    Mol_Obj = Molecule.Molecule(mol, data.getMol(
        mol, molClass))  # Make Molecular objects
    Mol_Obj.UnConverged = True
    Box_Length = GOLD_Obj.Box_Length
    Area = Box_Length[0] * Box_Length[1]
    Num_SAMs = int(np.sqrt(Area / Density))
    Mol_Obj.Set_Up_FF(run_orca=True,
                      local=True)  # Parameterize Molecule Object
    OPLS.Assign_OPLS(Mol_Obj, ChelpG=False)  # Parameterize Molecule Object
    OPLS.Assign_OPLS(GOLD_Obj, ChelpG=False)  # Parametrize Au slab
    SAM_System = SAM.SAM(Mol_Obj, GOLD_Obj, Num_SAMs, Box_Length, mol)
    SAM_System.Gen_SAM()
    SAM_System.Write_LAMMPS_Data()
    SAM_System.Run_Lammps_Init()
    SAM_System.Run_Lammps_NPT(Temp_Out=400, time_steps=5000000)
    SAM_System.Run_Lammps_NPT(Temp_Out=400, time_steps=5000000)
    SAM_System.Run_Lammps_NPT(Temp_Out=300, time_steps=5000000)
    SAM_System.Run_Lammps_NPT(Temp_Out=300, time_steps=5000000)
    SAM_System.Run_Lammps_NPT(Temp_Out=300, time_steps=5000000)
    print "Aromodel.py complete for: " + mol + " molecule on " + surface + " surface!"
def parse_surface_pieces(spec):

    from chimera.specifier import evalSpec
    sel = evalSpec(spec)
    import Surface
    plist = Surface.selected_surface_pieces(sel)
    return plist
Example #19
0
def parse_surface_pieces(spec):

    from chimera.specifier import evalSpec
    sel = evalSpec(spec)
    import Surface
    plist = Surface.selected_surface_pieces(sel)
    return plist
  def mouse_drag_cb(self, v, e):

    if self.last_xy is None:
      self.last_xy = (e.x, e.y)
      return
    
    import Surface
    plist = Surface.selected_surface_pieces()
    if len(plist) == 0:
      from chimera.replyobj import status
      status('No surfaces selected for resizing')
      return

    dx, dy = (e.x - self.last_xy[0], self.last_xy[1] - e.y)
    delta = dx + dy
    self.last_xy = (e.x, e.y)

    shift_mask = 1
    shift = (e.state & shift_mask)
    if shift:
      factor_per_pixel = 1.001  # shift key held so scale by smaller amount
    else:
      factor_per_pixel = 1.01

    factor = factor_per_pixel ** delta
    for p in plist:
      scale_surface_piece(p, factor)
Example #21
0
def inertia(operation, objects, showEllipsoid = True, color = None,
            perChain = False):

    from chimera import specifier
    try:
        sel = specifier.evalSpec(objects)
    except:
        raise CommandError, 'Bad object specifier "%s"' % objects

    if not color is None:
        from Commands import parse_color
        color = parse_color(color)

    atoms = sel.atoms()
    if atoms:
        import inertia
        if perChain:
            xf = atoms[0].molecule.openState.xform
            mname = molecules_name(list(set([a.molecule for a in atoms])))
            s = inertia.surface_model(None, xf, 'ellipsoids ' + mname)
            for achain in atoms_by_chain(atoms):
                p = inertia.atoms_inertia_ellipsoid(achain, showEllipsoid,
                                                    color, s)
                if p:
                    p.oslName = achain[0].residue.id.chainId
        else:
            inertia.atoms_inertia_ellipsoid(atoms, showEllipsoid, color)

    import Surface
    plist = Surface.selected_surface_pieces(sel, include_outline_boxes = False)
    if plist:
        import inertia
        inertia.surface_inertia_ellipsoid(plist, showEllipsoid, color)
Example #22
0
    def __init__(self, lll, viewspace, mymap):

        self.lll = lll
        self.display = Display()
        self.viewspace = viewspace
        self.mymap = mymap
        self.terrainset = TerrainSet()

        self.units = []

        # Test
        self.settsurf = Surface()
        self.settsurf.loadFromFile("gfx/protosettler.png")
        self.settsurf.cols = 16
        self.settsurf.rows = 16
        """self.sett = Unit (self.viewspace, self.settsurf)
 def afunc(fname = function_name, sel = on_selection):
   import Surface
   f = getattr(Surface, fname)
   if sel:
     f(Surface.selected_surface_pieces())
   else:
     f()
 def afunc(fname=function_name, sel=on_selection):
     import Surface
     f = getattr(Surface, fname)
     if sel:
         f(Surface.selected_surface_pieces())
     else:
         f()
 def selected_surface_pieces(self):
         plist = Surface.selected_surface_pieces()
         if len(plist) > 0:
                 return plist
         plist = []
         for m in openModels.list(modelTypes = [SurfaceModel]):
                 plist.extend(m.surfacePieces)
         return plist
Example #26
0
def split_selected_surfaces(session, in_place=True):

    import Surface
    plist = Surface.selected_surface_pieces()
    if plist:
        pplist = split_surfaces(plist, session, in_place)
        from chimera.replyobj import status
        status('%d surface pieces' % len(pplist))
Example #27
0
def selectedSurfacePieces(excludeMSMS = False, noneReturnsAll = True,
			  implied = False):
	import Surface
	if noneReturnsAll and selection.currentEmpty():
		plist = Surface.all_surface_pieces()
	else:
		plist = Surface.selected_surface_pieces()
		if implied and surfacesWithAtomsAndBonds():
			atoms = selAtoms(noneReturnsAll)
			bonds = selBonds(noneReturnsAll)
			pset = set(plist)
			pab = atomAndBondSurfacePieces(atoms, bonds)
			plist.extend([p for p in pab if p not in pset])
	if excludeMSMS:
		plist = [p for p in plist
			 if (not isinstance(p.model, chimera.MSMSModel)
			     or p.model.molecule is None)]
	return plist
Example #28
0
def main():
    Script, Mult = sys.argv
    Density = 0.01
    Mult = int(Mult)
    File_List = glob.glob('*.data')
    print len(File_List)
    print File_List
    Mol_Temp_List = []
    Mol_Temp_List.append(Surface.Surface('alkane-monolayer_2.lammps'))
    i = 0
    Total_Mass = 0.0
    MW = 0.0
    for File in File_List:
        Mol_Temp_List.append(DA_Polymer.DA_Polymer(File))
        Total_Mass += Mol_Temp_List[i].MW
        MW = Mol_Temp_List[i].MW
        i += 1
    print i
    Avogadro = 6.0221413e23
    Comp_List = np.ones(i + 2, dtype=int)
    Comp_List = Comp_List * Mult
    Comp_List[0] = 1
    Total_Mols = float(i * Mult + 1) / Avogadro
    Molar_Volume = MW / Density
    Volume = Molar_Volume * Total_Mols

    #Name = File_List[0].split('.')[1].split('_')[0] + "_%s" % i*Mult

    Name = os.getcwd().split('/')[-1] + "_%s" % int(i * Mult)
    print Name
    DA_System = System.System(Mol_Temp_List, Comp_List, Box_Length, Name)
    DA_System.Gen_Rand()
    DA_System.Write_LAMMPS_Data()
    DA_System.Run_Lammps_Init()

    DA_System.Temperature = 800
    DA_System.Run_Lammps_NPT(GPU=True)
    DA_System.Run_Lammps_NPT(GPU=True)
    #System.Run_Glass_Transition(DA_System, -100, Ramp_Steps = 1000000, Equil_Steps = 1000000, T_End = 600)
    DA_System.Run_Lammps_NPT(GPU=True)
    DA_System.Run_Lammps_NPT(GPU=True)
    DA_System.Run_Lammps_NPT(GPU=True)
    DA_System.Temperature = 600
    DA_System.Run_Lammps_NPT(GPU=True)
    DA_System.Run_Lammps_NPT(GPU=True)
    DA_System.Run_Lammps_NPT(GPU=True)
    DA_System.Run_Lammps_NPT(GPU=True)
    DA_System.Run_Lammps_NPT(GPU=True)
    DA_System.Run_Lammps_NPT(GPU=True)
    System.Run_Glass_Transition(DA_System,
                                20,
                                Ramp_Steps=100000,
                                Equil_Steps=100000,
                                T_End=100)
Example #29
0
def selectedSurfacePieces(excludeMSMS=False,
                          noneReturnsAll=True,
                          implied=False):
    import Surface
    if noneReturnsAll and selection.currentEmpty():
        plist = Surface.all_surface_pieces()
    else:
        plist = Surface.selected_surface_pieces()
        if implied and surfacesWithAtomsAndBonds():
            atoms = selAtoms(noneReturnsAll)
            bonds = selBonds(noneReturnsAll)
            pset = set(plist)
            pab = atomAndBondSurfacePieces(atoms, bonds)
            plist.extend([p for p in pab if p not in pset])
    if excludeMSMS:
        plist = [
            p for p in plist if (not isinstance(p.model, chimera.MSMSModel)
                                 or p.model.molecule is None)
        ]
    return plist
Example #30
0
def adjustMSMSTransparency(s, atoms, opacity, aopacity):

	if s.colorMode == s.Custom:
		# Change transparency of just the atom vertices.
		vrgba = s.customRGBA
		if vrgba is None:
			return
		if s.atomMap is None:
			vrgba[:,3] = opacity
		else:
			aset = set(atoms)
			av = [i for i,a in enumerate(s.atomMap) if a in aset]
			vrgba[av,3] = opacity
		import Surface
		Surface.set_coloring_method('static', s, None)
		s.customRGBA = vrgba
	elif s.colorMode == s.ByMolecule:
		s.molecule.surfaceOpacity = aopacity
	else:
		for a in atoms:
			a.surfaceOpacity = aopacity
Example #31
0
def adjustMSMSTransparency(s, atoms, opacity, aopacity):

    if s.colorMode == s.Custom:
        # Change transparency of just the atom vertices.
        vrgba = s.customRGBA
        if vrgba is None:
            return
        if s.atomMap is None:
            vrgba[:, 3] = opacity
        else:
            aset = set(atoms)
            av = [i for i, a in enumerate(s.atomMap) if a in aset]
            vrgba[av, 3] = opacity
        import Surface
        Surface.set_coloring_method('static', s, None)
        s.customRGBA = vrgba
    elif s.colorMode == s.ByMolecule:
        s.molecule.surfaceOpacity = aopacity
    else:
        for a in atoms:
            a.surfaceOpacity = aopacity
Example #32
0
    def test_blend_curve(self):
        # Create C0 BlendPoint at origin
        b1 = Surface.BlendPoint()
        # Create G1 BlendPoint
        b2 = Surface.BlendPoint([vec(10, 3, 6), vec(2, 5, 6)])
        # BlendCurve between the two BlendPoints
        bc = Surface.BlendCurve(b1, b2)
        # Compute the interpolating BezierCurve
        curve1 = bc.compute()

        # Create G2 BlendPoint at the end of previous BlendCurve
        b1 = Surface.BlendPoint(curve1.toShape(), 1, 2)
        # Create G1 BlendPoint
        b2 = Surface.BlendPoint([vec(5, 6, 2), vec(2, 5, 6)])

        bc = Surface.BlendCurve(b1, b2)
        # Compute the interpolating BezierCurve
        curve2 = bc.compute()

        d1 = curve1.getD2(1)
        d2 = curve2.getD2(0)

        self.assertEqual(len(d1), len(d2))
        self.assertAlmostCoincide(d1[0], d2[0])
        self.assertAlmostCoincide(d1[1], d2[1])
        self.assertAlmostCoincide(d1[2], d2[2])
Example #33
0
    def setupUi(self):
        self.view = QGraphicsView(self)
        self.view.setMouseTracking(True)
        self.vl = QVBoxLayout(self)
        self.vl.addWidget(self.view)

        self.surface = Surface.Surface(QRectF(0, 0, 800, 800), self)
        self.surface.dragStarted.connect(self.onDragStarted)
        self.surface.dragging.connect(self.onDragging)
        self.surface.dragEnded.connect(self.onDragEnded)
        self.surface.scaled.connect(self.onScaled)
        self.view.setScene(self.surface)
        self.surface.setScale(10)
Example #34
0
def regions_arg(s):

    from chimera.specifier import evalSpec
    sel = evalSpec(s)
    import Surface
    plist = Surface.selected_surface_pieces(sel)
    from Segger import Region
    rlist = [
        p.region for p in plist
        if hasattr(p, 'region') and isinstance(p.region, Region)
    ]
    if len(rlist) == 0:
        raise CommandError, 'No segmentation regions specified'
    return rlist
def volume_area(operation, surface):

    from _surface import SurfaceModel
    slist = [s for s in surface if isinstance(s, SurfaceModel)]
    if len(slist) == 0:
        raise CommandError, 'No surfaces specified'

    import Surface
    plist = Surface.surface_pieces(slist)

    import MeasureVolume as m
    op = operation[0]
    m.report_volume_and_area(plist,
                             report_volume=(op == 'v'),
                             report_area=(op == 'a'))
Example #36
0
def volume_area(operation, surface):

    from _surface import SurfaceModel
    slist = [s for s in surface if isinstance(s, SurfaceModel)]
    if len(slist) == 0:
        raise CommandError, 'No surfaces specified'

    import Surface
    plist = Surface.surface_pieces(slist)

    import MeasureVolume as m
    op = operation[0]
    m.report_volume_and_area(plist,
                             report_volume = (op == 'v'),
                             report_area = (op == 'a'))
Example #37
0
	def __init__ (self, lll, viewspace, mymap):
	
		self.lll = lll
		self.display = Display ()
		self.viewspace = viewspace
		self.mymap = mymap
		self.terrainset = TerrainSet ()
		
		# Test
		self.settsurf = Surface ()
		self.settsurf.loadFromFile ("gfx/protosettler.png")
		self.settsurf.cols = 16
		self.settsurf.rows = 16

		self.sprites = []
Example #38
0
def contact_area(operation,
                 surf1,
                 surf2,
                 distance,
                 show=True,
                 color=(1, 0, 0, 1),
                 offset=1,
                 slab=None,
                 smooth=False,
                 optimize=True):

    plist = []
    import Surface
    for spec in (surf1, surf2):
        s = parse_object_specifier(spec, 'surface')
        p = Surface.selected_surface_pieces(s, include_outline_boxes=False)
        if len(p) == 0:
            raise CommandError('%s has no surface pieces' % spec)
        elif len(p) > 1:
            raise CommandError('%s has %d surface pieces, require 1' %
                               (spec, len(p)))
        plist.append(p[0])
    p1, p2 = plist

    from Commands import parse_color
    color = parse_color(color)
    if not show:
        color = None

    from Commands import check_number
    check_number(offset, 'offset')

    if not slab is None:
        if isinstance(slab, (float, int)):
            slab = (-0.5 * slab, 0.5 * slab)
        else:
            from Commands import parse_floats
            slab = parse_floats(slab, 'slab', 2)
        offset = None

    import contactarea as c
    area = c.contact_area(p1, p2, distance, color, offset, slab, smooth,
                          optimize)

    from chimera import replyobj
    replyobj.info('Contact area on %s within distance %.4g\nof %s = %.4g\n' %
                  (p1.model.name, distance, p2.model.name, area))
    replyobj.status('Contact area = %.4g' % area)
    def generateSurfaces(self, n):
        self.mesh.compute_triangle_normals()
        self.triangleNormals = np.asarray(self.mesh.triangle_normals)

        self.isTriangleFree = [True for i in self.triangles]

        p = len(self.triangles)
        randomSeeds = [randint(0, p - 1)]
        for i in range(n - 1):
            q = randint(0, p - 1)
            while q in randomSeeds:
                q = randint(0, p - 1)
            randomSeeds.append(q)

        for t in randomSeeds:
            self.isTriangleFree[t] = False

        self.surfaces = [Surface(self, q) for q in randomSeeds]
def inertia(operation,
            objects,
            showEllipsoid=True,
            color=None,
            perChain=False):

    from chimera import specifier
    try:
        sel = specifier.evalSpec(objects)
    except:
        raise CommandError, 'Bad object specifier "%s"' % objects

    if not color is None:
        from Commands import parse_color
        color = parse_color(color)

    atoms = sel.atoms()
    if atoms:
        import inertia
        if perChain:
            xf = atoms[0].molecule.openState.xform
            mname = molecules_name(list(set([a.molecule for a in atoms])))
            s = inertia.surface_model(None, xf, 'ellipsoids ' + mname)
            for achain in atoms_by_chain(atoms):
                p = inertia.atoms_inertia_ellipsoid(achain, showEllipsoid,
                                                    color, s)
                if p:
                    p.oslName = achain[0].residue.id.chainId
        else:
            inertia.atoms_inertia_ellipsoid(atoms, showEllipsoid, color)

    import Surface
    plist = Surface.selected_surface_pieces(sel, include_outline_boxes=False)
    if plist:
        import inertia
        inertia.surface_inertia_ellipsoid(plist, showEllipsoid, color)
bdo = bd.BarrelData()
# Set True for inter-lines:
bdo.loadAnalysisData = False
bdo.loadDivisions = False
# If loadGuidance is True, then expt id map will be plotted:
bdo.loadGuidance = False
bdo.loadHexFlags = True
bdo.loadSimData = True
bdo.loadTimeStep = ti
bdo.load(logdirname)

#maxa = np.max (bdo.a, axis=0)

# Plot a surface
import Surface as surf
sf = surf.Surface(12, 11)
sf.associate(bdo)

# Plot a single field using a colour map
sf.z = 2.0 * bdo.a[0, :, 0]  # 13 is barrel/barreloid C4, 0 is barrel alpha
sf.showScalebar = False
sf.showAxes = False
sf.sb1 = [-1.3, -0.8]
sf.sb2 = [-0.3, -0.8]
sf.sbtext = '1 mm'
sf.sbtpos = [-1.1, -1.1]
sf.sblw = 5
sf.sbfs = 48
sf.showNames = False
sf.showBoundaries = False
sf.cmap = plt.cm.Greys
Example #42
0
class GFXEngine:
    """
	This class draws the gfx
	"""
    def __init__(self, lll, viewspace, mymap):

        self.lll = lll
        self.display = Display()
        self.viewspace = viewspace
        self.mymap = mymap
        self.terrainset = TerrainSet()

        self.units = []

        # Test
        self.settsurf = Surface()
        self.settsurf.loadFromFile("gfx/protosettler.png")
        self.settsurf.cols = 16
        self.settsurf.rows = 16
        """self.sett = Unit (self.viewspace, self.settsurf)
		self.sett.x = 100
		self.sett.y = 100
		self.sett.configAnimation (True, 0, 24, 25)"""

    def tick(self):
        """
		tick() executes all actions which must be done by the GFX-Engine in one Game-Loop-cycle
		This is: clearing the screen, drawing all objects, showing the new game-frame
		"""

        self.display.clear()
        self.draw()
        for sprite in self.units:
            sprite.drawToDisplay(self.display)
        #self.sett.drawToDisplay (self.display)
        self.display.showFrame()

    def createSettler(self, x, y):
        """ 
		Adds a settler to be drawn on the screen at position x, y and returns a reference to this settler.
		"""
        unit = Unit(self.viewspace, self.settsurf, x, y)
        #unit.x = x
        #unit.y = y
        unit.configAnimation(True, 0, 24, 25)
        self.units.append(unit)
        return unit

    def draw(self):

        self.drawLandscape()

    def drawLandscape(self):

        self.drawTerrain()

    def drawTerrain(self):

        self.lll.view.DrawTerrain(self.mymap.terra.asCArray(),
                                  self.mymap.mapsize, TRIA_W, TRIA_H,
                                  TEX_FACTOR, self.terrainset.asCArray(),
                                  self.mymap.getVertarray().asCArray())
Example #43
0
                screen.blit(text, textpos)
                textbox.draw(screen)
                textbox1.draw(screen)
                pygame.display.update()
                pygame.time.delay(2000)
                stop2=False
                while not stop2:
                    screen.fill(color1)
                    events2 = pygame.event.get()
                    textbox2.draw(screen)
                    textbox2.update(events2)
                    pygame.display.update()
                    if(textbox2.value.lower()=='w'):
                        stop2=True
                        pygame.quit()
                        Surface.mainfunction()
                    elif(textbox2.value.lower()=='r'):
                        stop2=True
                        pygame.quit()
                        Render.mainfunction()

    screen.fill(color1)
    textbox.update(events)
    textbox.draw(screen)
    screen.blit(text1, textpos1)
    screen.blit(text2, textpos2)
    pygame.display.update()

pygame.quit()
quit()
Example #44
0
def content():
    # Get target x/y hex to show trace for and the time step to show the
    # map for from the arguments:
    if len(sys.argv) < 3:
        print('Provide logdirname and time index (in sim steps) on cmd line.')
        exit(1)
    logdirname = sys.argv[1].rstrip('/')
    print('basename: {0}'.format(os.path.basename(logdirname)))
    # time index
    ti = int(sys.argv[2])

    # Read the data
    rdo = rd.RettecData()
    rdo.debug = True
    # Set True for inter-lines:
    rdo.loadAnalysisData = False
    rdo.loadDivisions = False
    # If loadGuidance is True, then expt barrel adjacency measure can be calculated in computeAdjacencyMeasure()
    rdo.loadGuidance = True
    rdo.loadSimData = True
    rdo.loadTimeStep = ti
    rdo.loadHexFlags = True
    rdo.load(logdirname)
    ##rdo.computeAdjacencyMeasure()

    # Compute max of c
    maxc = np.max(rdo.c, axis=0)

    # Either use the precomputed ID map: ONLY GOOD IF dr was computed!!
    #c_id = rdo.id_c[:,0]
    # or compute it here:
    c_id_int = np.argmax(rdo.c, axis=0)
    c_id = c_id_int[:, 0].astype(np.float32) / np.float32(rdo.N)

    # Compute the colour map
    colmap = np.zeros([rdo.nhex, 3], dtype=float)
    ii = 0
    for oneid in c_id:
        colmap[ii] = rdo.gammaColour_byid[oneid]
        ii = ii + 1

    # Plot a surface
    import Surface as surf
    sf = surf.Surface(12, 11)
    sf.associate(rdo)

    sf.c = colmap  # assign the colour map computed above
    if ti < 5000:
        sf.showScalebar = True
    else:
        sf.showScalebar = False
    sf.showAxes = False
    sf.sb1 = [-1.3, -0.9]
    sf.sb2 = [-0.3, -0.9]
    sf.sbtext = ''
    sf.sbtpos = [-1.1, -1.1]
    sf.sblw = 5
    sf.sbfs = 48
    if ti > 12000:
        sf.showNames = True
    else:
        sf.showNames = False
    ##sf.domcentres = rdo.domcentres[0]
    col = sc.Colour()
    sf.boundarylw = 1.0
    sf.boundaryColour = col.black
    sf.boundaryOuterHexColour = col.gray50
    sf.showBoundaries = False
    if sf.showBoundaries == True:
        sf.domdivision = rdo.domdivision
    sf.textid = False
    sf.plotPoly()

    # Add two contours, for different levels of localization
    #sf.addContour (maxc[:,0], 0.8, 'white', 1.0);
    #sf.addContour (maxc[:,0], 0.4, 'grey', 1.6);

    # Or single contour for each field
    do_contour = 0
    if do_contour:
        for ii in range(0, rdo.N):
            c = rdo.c[ii, :, 0]
            sf.addContour(c, 0.5, 'white', 1.0, ii, False)

    sf.addOuterBoundary()

    mapname = 'plots/{0}_c_id_{1:06d}.png'.format(os.path.basename(logdirname),
                                                  ti)
    plt.savefig(mapname, dpi=300, transparent=True)

    plt.show()
Example #45
0
    spacing=10,
    colour=(255, 255, 0),
    size=keypad_lane_1.size,
    elements=(keypad_button_3, keypad_button_6, keypad_button_9),
)

housing_frame = Frame(
    position=((current_res[0] / 2) - 100, (current_res[1] / 2) - 100),
    direction="right",
    stacked=True,
    spacing=10,
    size=(keypad_lane_1.width * 3 + 20, keypad_lane_1.height),
    elements=(keypad_lane_1, keypad_lane_2, keypad_lane_3),
)

main_surface = Surface([housing_frame], current_res)


# ----Main Loop---- #


count = 0
while running:

    main_surface.fill([0, 0, 0])

    count += 1
    if count < 3:
        for frame in Frame.all_frames:
            frame.reassign_element_positions()
Example #46
0
def zonable_surface_models():

    import Surface as s
    return s.surface_models()
Example #47
0
 def loadFile(self):
     fileName = QtGui.QFileDialog.getOpenFileName(self, 'Open file', './',
                                                  'Surface Template(*.nv)')
     self.surface = Surface()
     self.surface.LoadIn(fileName)
     self.sceneManager.rootNode.localObjectDict['Surface'] = self.surface