# YASARA MACRO # TOPIC: 4. Assembly of mega- and gigastructures # TITLE: Packing library # REQUIRES: Dynamics # AUTHOR: Elmar Krieger & Kornel Ozvoldik # LICENSE: GPL # DESCRIPTION: This macro provides a function library for assembling giant structures with millions to billions of atoms # INJECT A GENOME INTO A GROWING MEMBRANE BUD # =========================================== # To create a realistically folded genome, it is shifted into a growing membrane bud # during a course grained MD simulation. 'radius' is the final radius of the bud. # The genome must have been created with BuildGenome and no other objects may be active. # If 'turned', the genome is turned around (in case NiceOri chooses the wrong direction) def InjectGenome radius,turned global Pi # Orient genome along the X-axis NiceOriAll Pos 0,0,50 if turned Rotate X=180 Rotate Y=180 # Get the width and position along X, place the genome start at the center genlenx,_,_,genposx = GroupBox all,CoordSys=Global MoveAll (-genposx+genlenx/2) # Create a cell large enough for the bud cubelen=2.*radius+10 Cell (cubelen) Boundary Wall MoveObj SimCell,X=(-cubelen/2) plane = ShowBox Width=(cubelen*2),Height=10,Depth=(cubelen*3),LeftCol=Gray MoveObj (plane),X=(-cubelen/8),Y=(-cubelen/2-5) LightSource CellShadow=Yes # The bud eccentricity, it is moved a bit off center so that the injected genome does to bump straight into the other side budecc=4 # Determine tesselation level of the sphere that represents the membrane bud. # The larger 'radius', the more vertices (and ultimatly atoms) do we need to make sure # that the genome cannot escape through holes when the sphere reaches its final size. sphere = ShowSphere (radius),Red,Level=(0+log (sqr radius)*0.6) # Turn the polygon mesh into atoms that can serve as a boundary during the MD simulation bud = BuildMesh (sphere),Element=Sphere12,Bonds=No DelObj (sphere) Style Ball HideAtom Obj (bud) GlobalZ<50 # Scale the bud down and place it at the cell wall startscale=0.3e0 scale=startscale ScaleObj (bud),X=(scale),Y=(scale),Z=(scale) MoveObj (bud),X=(-scale*radius),Y=(budecc),Z=(-budecc) # Calculate position of bud center in cell coordinates budpos=(cubelen-scale*radius),(cubelen*0.5+budecc),(cubelen*0.5-budecc) # Calculate start volume, the factor (4/3)*Pi is not included since it cancels out startvol=cube (startscale*radius) # Initially everything is fixed FixAll # Initialize simulation ForceField NOVA Longrange None Cutoff 3 TimeStep 2,0.5 SimSteps 10,10 Temp 298K TempCtrl Rescale ChargeAtom all,0 Sim On # Shift the genome in shift=0.05 Console off Pos X=-22,Z=195 Brake 4000 ColorMol Obj 1,blue,cyan ColorAtom PRNA NRNA RNA,Grey HUD Sim # We start by moving all molecules except the growing bud movelist()=ListMol Obj !(bud) #SaveMPG /data/coronamovie2.mp4,1024,720,fps=30,Skip=159,Menu=Yes,JustMacro=Yes lastshot=-1 for i=0. to genlenx step shift Wait 4 MoveMol (join movelist),X=(-shift) if 0+i*0.25!=0+(i+shift)*0.25 # We moved by 4 A, time to adjust the bud # Calculate the new bud scaling factor vol=startvol+(cube radius-startvol)*(i/genlenx) #print 'Vol=(0.00+vol), StartVol=(0.00+startvol), curt=(0.00+curt vol), (0.000+i/genlenx)' newscale=curt vol/radius change=newscale/scale #print 'Scale=(0.000+scale), NewScale=(0.000+newscale), Change=(0.000+change)' # Move the bud center to 0/0/0, scale it, and move it back where it belongs MoveAtom Obj (bud),(-budpos) ScaleObj (bud),X=(change),Y=(change),Z=(change) budpos1=budpos1-(newscale-scale)*radius print (budpos) MoveAtom Obj (bud),(budpos) scale=newscale # Get a new list of automatically moving molecules fixedlist()=ListMol fixed localX>=(cubelen-5) and not Obj (bud) # Free atoms that are new inside the bud FreeMol not (join fixedlist) and not Obj (bud) # Short steepest descent to avoid simulation failures due to overlaps ShowMessage 'Steepest descent minimization at pos (0.00+i)...' TempCtrl SteepDes # Wait until convergence (the maximum speed increases again) lastspeedmax=1e99 while 1 Wait 1 print 'SpeedMax=(speedmax), Last=(lastspeedmax)' if speedmax>lastspeedmax or !speedmax break lastspeedmax=speedmax TempCtrl Rescale # Save single snapshots shot=0+(i*50/genlenx) if shot!=lastshot lastshot=shot SavePNG '/data/coronamovie_(shot).png',Menu=yes freeatoms=CountAtom !fixed density=(0.+freeatoms)/(4.*Pi*cube (scale*radius)/3.) ShowMessage '(100.00*i/genlenx)% completed, (0.000+density)/(SimWarnings)...' Sim Pause #SaveMPG off