Difference between revisions of "Team:Exeter/Modelling BM01"
Line 5: | Line 5: | ||
This HTML was auto-generated from MATLAB code. | This HTML was auto-generated from MATLAB code. | ||
To make changes, update the MATLAB code and republish this document. | To make changes, update the MATLAB code and republish this document. | ||
− | --><title> | + | --><title>BM_07_09_insilicobinding</title><meta name="generator" content="MATLAB 8.5"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2015-09-19"><meta name="DC.source" content="BM_07_09_insilicobinding.m"><style type="text/css"> |
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outine:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0} | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outine:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0} | ||
Line 65: | Line 65: | ||
− | </style></head><body><div class="content"><h2>Contents</h2><div><ul><li><a href="#1"> | + | </style></head><body><div class="content"><h2>Contents</h2><div><ul><li><a href="#1">BM_07_09</a></li><li><a href="#2">Setting our deafault parameters and variables</a></li><li><a href="#3">The coordinate generation and the main loop</a></li><li><a href="#4">Generation of the inital starting points, calls startpoint.</a></li><li><a href="#5">Coordinate generation and confinement checking</a></li><li><a href="#7">Bouncing</a></li><li><a href="#9">Startpoint</a></li><li><a href="#10">Checking function</a></li><li><a href="#11">Joining function</a></li><li><a href="#12">Splitter function</a></li><li><a href="#13">Plotting function</a></li><li><a href="#14">Bouncing function</a></li><li><a href="#15">Counting function</a></li><li><a href="#16">Code needed to produce a .gif file of the simulation output</a></li><li><a href="#18">End Of The Code</a></li></ul></div><h2>BM_07_09<a name="1"></a></h2><p>Our final code for the simulation of our cell free kit. This is after the restructure implimented after meetings with both Jonathan Fieldsend and the lab team. There are still improvements and optimisations to be made these are discussed below. More information can be found at <a href="https://2015.igem.org/Team:Exeter/Modeling">https://2015.igem.org/Team:Exeter/Modeling</a>. The function take inputs of: * t - Number of toeholds * r - Number of RNA's * N - Number of time steps * T - temperature -> this is the parameter scanning variable It outputs GFPcount, this depends on the parameter scanning variable choosen.</p><pre class="codeinput"><span class="keyword">function</span> [GFPcount] = BM_07_09_insilicobinding(t,r,N,T) |
</pre><h2>Setting our deafault parameters and variables<a name="2"></a></h2><p>These are the parameters used for the basic setup of Brownian motion as well as the contianment to a tube. Containment changed to a cylinder to emulate the lab, they are using a well plate now. All units are SI units unless otherwise stated.</p><pre class="codeinput"> rng(<span class="string">'shuffle'</span>); | </pre><h2>Setting our deafault parameters and variables<a name="2"></a></h2><p>These are the parameters used for the basic setup of Brownian motion as well as the contianment to a tube. Containment changed to a cylinder to emulate the lab, they are using a well plate now. All units are SI units unless otherwise stated.</p><pre class="codeinput"> rng(<span class="string">'shuffle'</span>); | ||
Line 75: | Line 75: | ||
d_r=1.7e-8; <span class="comment">% of RNA</span> | d_r=1.7e-8; <span class="comment">% of RNA</span> | ||
d_c=5.1e-8; <span class="comment">% of toehold-RNA complex</span> | d_c=5.1e-8; <span class="comment">% of toehold-RNA complex</span> | ||
− | D_t = kB * T / (3 * pi * eta * d_t); <span class="comment">%diffusion coefficient | + | D_t = kB * T / (3 * pi * eta * d_t); <span class="comment">%diffusion coefficient</span> |
− | D_r = kB * T / (3 * pi * eta * d_r); | + | D_r = kB * T / (3 * pi * eta * d_r); |
− | D_c = kB * T / (3 * pi * eta * d_c); | + | D_c = kB * T / (3 * pi * eta * d_c); |
p_t = sqrt(2*D_t*tau); | p_t = sqrt(2*D_t*tau); | ||
p_r = sqrt(2*D_r*tau); | p_r = sqrt(2*D_r*tau); | ||
p_c = sqrt(2*D_c*tau); | p_c = sqrt(2*D_c*tau); | ||
− | <span class="comment">%CONFINEMENT - height can be changed depending on the volume of | + | <span class="comment">%CONFINEMENT - height can be changed depending on the volume of the solution (rather than the total possible volume of the eppendorf)</span> |
− | + | A = (3.5e-10)*2; <span class="comment">%binding distance, default at 1e-7, real world value .5e-10</span> | |
− | A = | + | |
− | cylinder_radius=3.34e- | + | cylinder_radius=3.34e-6; <span class="comment">%radius of F-Well plate well in metres (3.34e-3metres) %changed</span> |
− | tube_height_max= | + | tube_height_max=7.13e-7; <span class="comment">%height of F-Well plate well to fill i billionth of 50microlitres (1.426e-3metres)</span> |
− | tube_height_min=- | + | tube_height_min=-7.13e-7; |
− | cone_height=18e-3; | + | <span class="comment">%Changeable to suit the container of your system</span> |
+ | <span class="comment">%Total height is split in half, with one half above the positive xy plane and one half below</span> | ||
+ | cone_height=18e-3; <span class="comment">%unused</span> | ||
+ | |||
<span class="comment">%GIF stuff</span> | <span class="comment">%GIF stuff</span> | ||
− | theta = 0; <span class="comment">% changes the viewing angle | + | theta = 0; <span class="comment">% changes the viewing angle</span> |
− | <span class="comment">%Figure Stuff | + | <span class="comment">%Figure Stuff</span> |
<span class="comment">% figure()</span> | <span class="comment">% figure()</span> | ||
<span class="comment">% %axis([-0.00005 0.00005 -0.00005 0.00005 -0.00005 0.00005]);</span> | <span class="comment">% %axis([-0.00005 0.00005 -0.00005 0.00005 -0.00005 0.00005]);</span> | ||
Line 128: | Line 131: | ||
bouncepoints=points; | bouncepoints=points; | ||
</pre><h2>The coordinate generation and the main loop<a name="3"></a></h2><p>The coordinates are now generated on the fly at every time step, this prevents the need to pass around large matrices. This is also the main loop at which every required function is called at each time step.</p><pre class="codeinput"> <span class="comment">%The main for loop -> loops over all the time steps</span> | </pre><h2>The coordinate generation and the main loop<a name="3"></a></h2><p>The coordinates are now generated on the fly at every time step, this prevents the need to pass around large matrices. This is also the main loop at which every required function is called at each time step.</p><pre class="codeinput"> <span class="comment">%The main for loop -> loops over all the time steps</span> | ||
+ | |||
<span class="keyword">for</span> j=1:N | <span class="keyword">for</span> j=1:N | ||
</pre><h2>Generation of the inital starting points, calls startpoint.<a name="4"></a></h2><pre class="codeinput"> <span class="keyword">if</span> j==1 | </pre><h2>Generation of the inital starting points, calls startpoint.<a name="4"></a></h2><pre class="codeinput"> <span class="keyword">if</span> j==1 | ||
[coords, startposition] = startpoint(); | [coords, startposition] = startpoint(); | ||
+ | <span class="comment">% c_joined=zeros(1,c);</span> | ||
+ | <span class="comment">% c_split=zeros(1,c);</span> | ||
check=zeros(c,3); | check=zeros(c,3); | ||
<span class="keyword">else</span> | <span class="keyword">else</span> | ||
Line 147: | Line 153: | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="comment">%calling checkxy to check x and y</span> | <span class="comment">%calling checkxy to check x and y</span> | ||
− | [coords,bouncepoints]=checkxy(cylinder_radius, <span class=" | + | [coords,bouncepoints]=checkxy(cylinder_radius, coords, i, bouncepoints); |
− | + | <span class="comment">%</span> | |
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
Line 159: | Line 165: | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="comment">% checking against the height of the tube.</span> | <span class="comment">% checking against the height of the tube.</span> | ||
+ | |||
<span class="keyword">if</span> coords(3,i)>=tube_height_max | <span class="keyword">if</span> coords(3,i)>=tube_height_max | ||
coords(3,i)=tube_height_max; | coords(3,i)=tube_height_max; | ||
Line 165: | Line 172: | ||
coords(3,i)=tube_height_min; | coords(3,i)=tube_height_min; | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
− | + | <span class="comment">% %calling checkxy to check x and y</span> | |
− | [coords,bouncepoints]=checkxy(cylinder_radius, | + | [coords,bouncepoints]=checkxy(cylinder_radius, coords, i, bouncepoints); |
− | + | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
Line 184: | Line 190: | ||
coords(3,i)=tube_height_min; | coords(3,i)=tube_height_min; | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
− | + | <span class="comment">% %calling checkxy to check x and y</span> | |
− | [coords,bouncepoints]=checkxy(cylinder_radius, | + | [coords,bouncepoints]=checkxy(cylinder_radius, coords, i, bouncepoints); |
− | + | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
</pre><pre class="codeinput"> <span class="keyword">end</span> | </pre><pre class="codeinput"> <span class="keyword">end</span> | ||
− | + | <span class="keyword">for</span> q=1:c | |
<span class="keyword">if</span> check(q,3)==0 && check(q,1)==0 && check(q,2)==0 && j~=1 | <span class="keyword">if</span> check(q,3)==0 && check(q,1)==0 && check(q,2)==0 && j~=1 | ||
− | + | jointime=j; <span class="comment">%variable to make sure joiner and splitter dont happen in same time step</span> | |
− | + | [coords,check, startposition, points] = joiner(coords,check, startposition, points); | |
− | [coords,check, startposition, points] = joiner(coords, | + | |
− | + | ||
<span class="keyword">elseif</span> check(q,3)~=0 | <span class="keyword">elseif</span> check(q,3)~=0 | ||
check(q,3)=check(q,3)+1; | check(q,3)=check(q,3)+1; | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">if</span> check(q,1)~=0 && check(q,2)~=0 && j~=jointime | <span class="keyword">if</span> check(q,1)~=0 && check(q,2)~=0 && j~=jointime | ||
− | [coords, check, startposition, points] = splitter(q, | + | [coords, check, startposition, points] = splitter(q, coords, check, startposition, points); |
− | + | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
− | </pre><h2>Bouncing<a name=" | + | </pre><h2>Bouncing<a name="7"></a></h2><pre class="codeinput"> <span class="keyword">for</span> f=1:t+r+c |
<span class="keyword">if</span> f<t+r+1 | <span class="keyword">if</span> f<t+r+1 | ||
<span class="keyword">if</span> bouncepoints{j,f}==0 <span class="comment">%not a bouncer</span> | <span class="keyword">if</span> bouncepoints{j,f}==0 <span class="comment">%not a bouncer</span> | ||
matcoords=[coords(1,f),coords(2,f),coords(3,f)]; | matcoords=[coords(1,f),coords(2,f),coords(3,f)]; | ||
points{j,f}=matcoords; | points{j,f}=matcoords; | ||
− | + | <span class="comment">%couldn't have these statements on the same line for some reason</span> | |
+ | |||
<span class="keyword">elseif</span> bouncepoints{j,f}~=0 | <span class="keyword">elseif</span> bouncepoints{j,f}~=0 | ||
− | <span class="keyword">if</span> size(bouncepoints{j,f},2)==3 | + | <span class="keyword">if</span> size(bouncepoints{j,f},2)==3 <span class="comment">%couldn't have these statements on the same line for some reason</span> |
− | matcoords=[coords(1,f),coords(2,f),coords(3,f) | + | matcoords=[coords(1,f),coords(2,f),coords(3,f) bouncepoints{j,f}(1,1),bouncepoints{j,f}(1,2),bouncepoints{j,f}(1,3)]; |
− | + | ||
− | + | ||
points{j,f}=matcoords; | points{j,f}=matcoords; | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
Line 229: | Line 230: | ||
<span class="keyword">elseif</span> bouncepoints{j,g}~=0 | <span class="keyword">elseif</span> bouncepoints{j,g}~=0 | ||
<span class="keyword">if</span> size(bouncepoints{j,f},2)==3 | <span class="keyword">if</span> size(bouncepoints{j,f},2)==3 | ||
− | matcoords=[coords(1,f),coords(2,f),coords(3,f) | + | matcoords=[coords(1,f),coords(2,f),coords(3,f) bouncepoints{j,g}(1,1),bouncepoints{j,g}(1,2),bouncepoints{j,g}(1,3)]; |
− | + | ||
− | + | ||
points{j,g}=matcoords; | points{j,g}=matcoords; | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
Line 249: | Line 248: | ||
<span class="keyword">if</span> j==N | <span class="keyword">if</span> j==N | ||
+ | plotter(points); | ||
counter(points); | counter(points); | ||
finish=1; | finish=1; | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
</pre><pre class="codeinput"> <span class="keyword">end</span> | </pre><pre class="codeinput"> <span class="keyword">end</span> | ||
− | </pre><h2>Startpoint<a name=" | + | </pre><h2>Startpoint<a name="9"></a></h2><p>Creates a start point definitely inside the dimensions of container, this is randomly generated. A vector called startpositon is made so the particles are located around this.</p><pre class="codeinput"> <span class="keyword">function</span> [coords, startposition] = startpoint() |
− | <span class="comment">%each column is a toehold, with six rows,</span> | + | coords=zeros(6,(t+r+c)); <span class="comment">%each column is a toehold, with six rows, for current xyz and previous xyz</span> |
− | + | <span class="comment">% startposition=zeros(6,(t+r+c));</span> | |
− | + | <span class="comment">% coords=mat2dataset(coords);</span> | |
<span class="keyword">for</span> m=1:t+r | <span class="keyword">for</span> m=1:t+r | ||
− | coords(3,m)=(tube_height_min)+ | + | coords(3,m)=(tube_height_min)+((tube_height_max-tube_height_min)*rand(1)); |
− | + | coords(1,m)=(-cylinder_radius)+((cylinder_radius-(-cylinder_radius))*rand(1)); | |
− | + | coords(2,m)=(-cylinder_radius)+((cylinder_radius-(-cylinder_radius))*rand(1)); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
startposition=coords; | startposition=coords; | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
− | </pre><h2>Checking function<a name=" | + | </pre><h2>Checking function<a name="10"></a></h2><p>Checks the coordinates are within the boundaries of the eppendorf</p><pre class="codeinput"><span class="comment">%Function that checks whether the particle is inside of the tube</span> |
<span class="comment">%for its calculated z-coordinate at the point of contact in the</span> | <span class="comment">%for its calculated z-coordinate at the point of contact in the</span> | ||
<span class="comment">%tube (in cone: via line equation intersects of path and boundary</span> | <span class="comment">%tube (in cone: via line equation intersects of path and boundary</span> | ||
Line 285: | Line 274: | ||
<span class="keyword">function</span> [coords,bouncepoints]=checkxy(radius,coords,i,bouncepoints) | <span class="keyword">function</span> [coords,bouncepoints]=checkxy(radius,coords,i,bouncepoints) | ||
+ | <span class="comment">%Function that checks whether the particle is inside of the tube</span> | ||
+ | <span class="comment">%for its calculated z-coordinate at the point of contact in the</span> | ||
+ | <span class="comment">%tube (in cone: via line equation intersects of path and boundary</span> | ||
+ | <span class="comment">%// in cylinder: line equation of tube boundary).</span> | ||
+ | <span class="comment">%From this point of contact, the new X and Y coordinates are</span> | ||
+ | <span class="comment">%calculated for the "exit point" and then subsequently, the new</span> | ||
+ | <span class="comment">%resultant xyz can be calculated</span> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | <span class="keyword">if</span> (coords(1,i)^2)+(coords(2,i)^2)>=(radius^2) | |
− | <span class="keyword">if</span> coords(1,i) | + | <span class="comment">%red box in (Maths for exitx.png explains derivation)</span> |
− | + | <span class="comment">%setting exitX/Y at boundary of cylinder</span> | |
− | + | grad=abs((sqrt((coords(1,i)^2)+(coords(2,i)^2))-sqrt((coords(4,i)^2)+(coords(5,i)^2)))/(coords(3,i)-coords(6,i))); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | <span class="comment">%confirmed to be correct</span> | |
− | exitZ=lastZ-Gz; | + | <span class="keyword">if</span> coords(1,i)<0 |
− | + | exitX=-sqrt((radius^2)/((grad^2)+1)); | |
− | + | <span class="keyword">else</span> | |
+ | exitX=sqrt((radius^2)/((grad^2)+1)); | ||
+ | <span class="keyword">end</span> | ||
+ | <span class="keyword">if</span> coords(2,i)<0 | ||
+ | exitY=-(grad*sqrt(((radius^2)/((grad^2)+1)))); | ||
+ | <span class="keyword">else</span> | ||
+ | exitY=grad*sqrt(((radius^2)/((grad^2)+1))); | ||
+ | <span class="keyword">end</span> | ||
+ | |||
+ | Px=coords(1,i); | ||
+ | Py=coords(2,i); | ||
+ | lastx=coords(4,i); | ||
+ | lasty=coords(5,i); | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | trajectory_gradient=(Py-lasty)/(Px-lastx); <span class="comment">%m1</span> | ||
+ | tangent_gradient=(-exitX/exitY); <span class="comment">%m2</span> | ||
+ | theta_bounce=atan(trajectory_gradient); | ||
+ | phi_2=atan(tangent_gradient); | ||
+ | phi_1=theta_bounce-phi_2; | ||
+ | exitPDist=sqrt(((Px-lastx)^2)+((Py-lasty)^2)); | ||
+ | G_length=exitPDist*cos(phi_1); | ||
+ | Gx=exitX+(G_length*cos(phi_1)); | ||
+ | Gy=exitY+(G_length*cos(phi_1)); | ||
+ | Cx=Px-Gx; | ||
+ | Cy=Py-Gy; | ||
+ | newX=Px-(2*Cx); | ||
+ | newY=Py-(2*Cy); | ||
+ | |||
+ | perpendicular_gradient=(exitY/exitX); | ||
+ | <span class="comment">% shifted_perpendicular_line=(perpendicular_gradient*EX)-((exitY+Px)/exitX)+Py;</span> | ||
+ | |||
+ | <span class="comment">%z-intercept with boundary: (see book)</span> | ||
+ | prad=sqrt((coords(1,i)^2)+(coords(2,i)^2)); | ||
+ | lastrad=sqrt((coords(4,i)^2)+(coords(5,i)^2)); | ||
+ | Dr=prad-lastrad; | ||
+ | pZ=coords(3,i); | ||
+ | lastZ=coords(6,i); | ||
+ | Dz=pZ-lastZ; | ||
+ | Gr=radius-lastrad; | ||
+ | Gz=Gr*tan(acos(Dr/sqrt((Dr^2)+(Dz^2)))); | ||
+ | |||
+ | <span class="keyword">if</span> pZ<lastZ | ||
+ | exitZ=lastZ-Gz; | ||
+ | <span class="keyword">else</span> | ||
+ | exitZ=lastZ+Gz; | ||
+ | <span class="keyword">end</span> | ||
+ | <span class="comment">%write new points directly into points in a way that joiner and</span> | ||
+ | <span class="comment">%splitter can still work</span> | ||
+ | <span class="keyword">if</span> i<=t+r | ||
+ | bouncepoints{j,i}=[exitX exitY exitZ]; | ||
+ | <span class="keyword">elseif</span> i>t+r | ||
+ | bouncepoints{j,(2*i)-1}=[exitX exitY exitZ]; | ||
+ | <span class="keyword">end</span> | ||
+ | <span class="comment">%update for next point</span> | ||
+ | coords(1,i)=newX; | ||
+ | coords(2,i)=newY; | ||
+ | coords(3,i)=coords(3,i); | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
− | </pre><h2>Joining function<a name=" | + | </pre><h2>Joining function<a name="11"></a></h2><p>This function has a threshold for joining, a joining probability. If this is met the toehold and RNA's are joined. The check vector changes to indicate this, the toeholds and RNA's are spotted being made and a complex line is made instead. startingposition is also updated to indicate the new starting point of the complex line.</p><pre class="codeinput"> <span class="keyword">function</span> [coords, check, startposition, points] = joiner(coords, check, startposition, points) |
− | + | ||
colshift=0; | colshift=0; | ||
− | + | <span class="comment">%Joining probability calculated from in silico data of free energy of complex from NUPACK and</span> | |
− | <span class="keyword">if</span> | + | <span class="comment">%equation of polynomial fit to normalised curve gives probability</span> |
+ | <span class="comment">%of binding (or rather gives the threshold to enable a successful</span> | ||
+ | <span class="comment">%binding event which a randomly generated number is tested against)</span> | ||
+ | joinevent = (randi([1 10000000],1))/10000000; | ||
+ | Tempcorrection = T-273; | ||
+ | jointhreshold = ((4e-07)*(Tempcorrection^4)) - ((6e-05)*(Tempcorrection^3)) + (0.0023*(Tempcorrection^2)) - (0.0072*Tempcorrection) + 0.3745; | ||
+ | <span class="keyword">if</span> joinevent >= jointhreshold | ||
<span class="keyword">for</span> n=1:t | <span class="keyword">for</span> n=1:t | ||
<span class="keyword">for</span> m=t+1:r+t | <span class="keyword">for</span> m=t+1:r+t | ||
Line 363: | Line 370: | ||
<span class="keyword">else</span> | <span class="keyword">else</span> | ||
<span class="comment">% if ((((tx(j,k)-rx(j,m))^2)+((ty(j,k)-ry(j,m))^2)+((tz(j,k)-rz(j,m))^2))<=(A^2) || (check_r(1,m)~=0 && check_t(1,k)~=0)) && (j~=1) && delay(1,n)==0</span> | <span class="comment">% if ((((tx(j,k)-rx(j,m))^2)+((ty(j,k)-ry(j,m))^2)+((tz(j,k)-rz(j,m))^2))<=(A^2) || (check_r(1,m)~=0 && check_t(1,k)~=0)) && (j~=1) && delay(1,n)==0</span> | ||
− | + | <span class="keyword">if</span> (((coords(1,n)-coords(1,m))^2)+((coords(2,n)-coords(2,m))^2)+((coords(3,n)-coords(3,m))^2))<=(A^2) | |
− | <span class="keyword">if</span> (((coords(1,n)-coords(1,m))^2)+((coords(2,n)- | + | |
− | + | ||
− | + | ||
<span class="keyword">for</span> p=1:c | <span class="keyword">for</span> p=1:c | ||
<span class="keyword">if</span> check(p,1)~=0 && check(p,2)~=0 | <span class="keyword">if</span> check(p,1)~=0 && check(p,2)~=0 | ||
Line 372: | Line 376: | ||
<span class="keyword">else</span> | <span class="keyword">else</span> | ||
<span class="keyword">if</span> check(p,1)==0 && check(p,2)==0 | <span class="keyword">if</span> check(p,1)==0 && check(p,2)==0 | ||
− | coords(1,t+r+p)=(coords(1,n)+ | + | coords(1,t+r+p)=(coords(1,n)+coords(1,m))/2; |
− | + | coords(2,t+r+p)=(coords(2,n)+coords(2,m))/2; | |
− | coords(2,t+r+p)=(coords(2,n)+ | + | coords(3,t+r+p)=(coords(3,n)+coords(3,m))/2; |
− | + | startposition(1,t+r+p)=coords(1,t+r+p); | |
− | coords(3,t+r+p)=(coords(3,n)+ | + | startposition(2,t+r+p)=coords(2,t+r+p); |
− | + | startposition(3,t+r+p)=coords(3,t+r+p); | |
− | startposition(1,t+r+p)= | + | |
− | + | ||
− | startposition(2,t+r+p)= | + | |
− | + | ||
− | startposition(3,t+r+p)= | + | |
− | + | ||
check(p,1)=n; | check(p,1)=n; | ||
check(p,2)=m; | check(p,2)=m; | ||
Line 403: | Line 401: | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
− | </pre><h2>Splitter function<a name=" | + | </pre><h2>Splitter function<a name="12"></a></h2><p>Splitter is similar to joiner but the opposite happnens. If a threshold is reached the complex will split back into a toehold and RNA. These lines are now produced again, check is updated to reflect this and finally startposition is changed.</p><pre class="codeinput"> <span class="keyword">function</span> [coords, check, startposition, points] = splitter(q, coords, check, startposition, points) |
− | + | splitevent = (randi([1 10000000],1))/10000000; | |
− | + | Tempcorrection = T-273; | |
− | <span class="keyword">if</span> | + | splitthreshold = (-(4e-07)*(Tempcorrection^4)) + ((6e-05)*(Tempcorrection^3)) - (0.0023*(Tempcorrection^2)) + (0.0072*Tempcorrection) + 0.6255; |
+ | <span class="comment">%y=-4E-07x4 + 6E-05x3 - 0.0023x2 + 0.0072x + 0.6255</span> | ||
+ | |||
+ | |||
+ | <span class="keyword">if</span> splitevent<=splitthreshold | ||
<span class="keyword">if</span> check(q,1)~=0 && check(q,2)~=0 | <span class="keyword">if</span> check(q,1)~=0 && check(q,2)~=0 | ||
toehold=check(q,1); | toehold=check(q,1); | ||
Line 422: | Line 424: | ||
coords(2,toehold)=coords(2,t+r+q); | coords(2,toehold)=coords(2,t+r+q); | ||
coords(3,toehold)=coords(3,t+r+q); | coords(3,toehold)=coords(3,t+r+q); | ||
+ | |||
points{j,t+r+(2*q)}=[0,toehold,rna]; | points{j,t+r+(2*q)}=[0,toehold,rna]; | ||
Line 430: | Line 433: | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
− | </pre><h2>Plotting function<a name=" | + | </pre><h2>Plotting function<a name="13"></a></h2><pre class="codeinput"> <span class="keyword">function</span> [] = plotter(points) |
<span class="comment">%Conditions from plotting drawn from points array</span> | <span class="comment">%Conditions from plotting drawn from points array</span> | ||
<span class="keyword">for</span> row=1:N | <span class="keyword">for</span> row=1:N | ||
Line 436: | Line 439: | ||
<span class="comment">%startpoints</span> | <span class="comment">%startpoints</span> | ||
<span class="keyword">for</span> col=1:t+r | <span class="keyword">for</span> col=1:t+r | ||
− | plot3(points{row,col}(1,1), points{row,col}(1,2), | + | plot3(points{row,col}(1,1), points{row,col}(1,2), points{row,col}(1,3),<span class="string">'kx'</span>) |
− | + | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">else</span> | <span class="keyword">else</span> | ||
<span class="keyword">for</span> altcol=t+r+2:2:t+r+(2*c) | <span class="keyword">for</span> altcol=t+r+2:2:t+r+(2*c) | ||
− | <span class="keyword">if</span> points{row,altcol}(1,1)==1 && size(points{ | + | <span class="keyword">if</span> points{row,altcol}(1,1)==1 && size(points{row,altcol},2)==3 && row>1 |
− | + | ||
<span class="keyword">if</span> points{row-1,altcol}(1,1)==0 <span class="comment">%definitely joinpoint</span> | <span class="keyword">if</span> points{row-1,altcol}(1,1)==0 <span class="comment">%definitely joinpoint</span> | ||
<span class="comment">%plot blue using row-1 to row to joinpoint column, column selected from points{row,col}(1,2))</span> | <span class="comment">%plot blue using row-1 to row to joinpoint column, column selected from points{row,col}(1,2))</span> | ||
− | plot3([points{row-1,(points{row,altcol}(1,2))}(1,1), | + | plot3([points{row-1,(points{row,altcol}(1,2))}(1,1), points{row,altcol-1}(1,1)], [points{row-1,(points{row,altcol}(1,2))}(1,2), points{row,altcol-1}(1,2)], [points{row-1,(points{row,altcol}(1,2))}(1,3), points{row,altcol-1}(1,3)], <span class="string">'b'</span>) |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<span class="comment">%plot red using row-1 to row to joinpoint column, column selected from points{row,col}(1,2)</span> | <span class="comment">%plot red using row-1 to row to joinpoint column, column selected from points{row,col}(1,2)</span> | ||
− | plot3([points{row-1,(points{row,altcol}(1,3))}(1,1), | + | plot3([points{row-1,(points{row,altcol}(1,3))}(1,1), points{row,altcol-1}(1,1)], [points{row-1,(points{row,altcol}(1,3))}(1,2), points{row,altcol-1}(1,2)], [points{row-1,(points{row,altcol}(1,3))}(1,3), points{row,altcol-1}(1,3)], <span class="string">'r'</span>) |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<span class="comment">%plot circle at joinpoint</span> | <span class="comment">%plot circle at joinpoint</span> | ||
− | plot3(points{row,altcol-1}(1,1), | + | plot3(points{row,altcol-1}(1,1), points{row,altcol-1}(1,2), points{row,altcol-1}(1,3), <span class="string">'ko'</span>) |
− | + | ||
− | + | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">if</span> points{row-1,altcol}(1,1)==1 <span class="comment">%defintely splitpoint</span> | <span class="keyword">if</span> points{row-1,altcol}(1,1)==1 <span class="comment">%defintely splitpoint</span> | ||
<span class="comment">%do nothing</span> | <span class="comment">%do nothing</span> | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
− | <span class="keyword">elseif</span> (points{row,altcol}(1,1)==1 && | + | <span class="keyword">elseif</span> (points{row,altcol}(1,1)==1 && size(points{row,altcol},2)==1) || (points{row,altcol}(1,1)==0 && size(points{row,altcol},2)==3) |
− | + | ||
− | + | ||
− | + | ||
<span class="comment">%plot green from row-1 to row</span> | <span class="comment">%plot green from row-1 to row</span> | ||
<span class="keyword">if</span> size(points{row-1,altcol-1},2)==3 | <span class="keyword">if</span> size(points{row-1,altcol-1},2)==3 | ||
− | plot3([points{row-1,altcol-1}(1,1), | + | plot3([points{row-1,altcol-1}(1,1), points{row, altcol-1}(1,1)], [points{row-1,altcol-1}(1,2), points{row, altcol-1}(1,2)], [points{row-1,altcol-1}(1,3), points{row, altcol-1}(1,3)],<span class="string">'g'</span>) |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<span class="keyword">elseif</span> size(points{row,altcol-1},2)==6 <span class="comment">%Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary</span> | <span class="keyword">elseif</span> size(points{row,altcol-1},2)==6 <span class="comment">%Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary</span> | ||
bounceplot(points, row, altcol-1, <span class="string">'g'</span>) | bounceplot(points, row, altcol-1, <span class="string">'g'</span>) | ||
Line 483: | Line 464: | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">if</span> points{row,altcol}(1,1)==0 <span class="comment">%currently split</span> | <span class="keyword">if</span> points{row,altcol}(1,1)==0 <span class="comment">%currently split</span> | ||
− | <span class="keyword">if</span> size(points{row-1,altcol},2)==3 && | + | <span class="keyword">if</span> size(points{row-1,altcol},2)==3 && points{row-1,altcol}(1,1)==0 <span class="comment">%prevents incorrect plotting in the case of join/split in consecutive timesteps</span> |
− | + | ||
<span class="comment">%plot from split column to blue column</span> | <span class="comment">%plot from split column to blue column</span> | ||
− | plot3([points{row-1,altcol-1}(1,1), | + | plot3([points{row-1,altcol-1}(1,1), points{row,(points{row-1,altcol}(1,2))}(1,1)],[points{row-1,altcol-1}(1,2), points{row,(points{row-1,altcol}(1,2))}(1,2)],[points{row-1,altcol-1}(1,3), points{row,(points{row-1,altcol}(1,2))}(1,3)],<span class="string">'b'</span>) |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<span class="comment">%plot from split column to red column</span> | <span class="comment">%plot from split column to red column</span> | ||
− | plot3([points{row-1,altcol-1}(1,1), | + | plot3([points{row-1,altcol-1}(1,1), points{row,(points{row-1,altcol}(1,3))}(1,1)],[points{row-1,altcol-1}(1,2), points{row,(points{row-1,altcol}(1,3))}(1,2)],[points{row-1,altcol-1}(1,3), points{row,(points{row-1,altcol}(1,3))}(1,3)],<span class="string">'r'</span>) |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<span class="comment">%plot star at splitpoint</span> | <span class="comment">%plot star at splitpoint</span> | ||
− | plot3(points{row-1,altcol-1}(1,1), points | + | plot3(points{row-1,altcol-1}(1,1), points{row-1,altcol-1}(1,2), points{row-1,altcol-1}(1,3), <span class="string">'k*'</span>) |
− | + | ||
− | + | ||
<span class="comment">%plot</span> | <span class="comment">%plot</span> | ||
<span class="keyword">continue</span> <span class="comment">%might not be necessary</span> | <span class="keyword">continue</span> <span class="comment">%might not be necessary</span> | ||
Line 510: | Line 476: | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">for</span> col=1:t+r | <span class="keyword">for</span> col=1:t+r | ||
− | <span class="keyword">if</span> points{row,col}(1,1)~=points{row-1,col}(1,1) | + | <span class="keyword">if</span> points{row,col}(1,1)~=points{row-1,col}(1,1) && points{row,col}(1,2)~=points{row-1,col}(1,2) && points{row,col}(1,3)~=points{row-1,col}(1,3) |
− | + | ||
− | + | ||
− | + | ||
<span class="comment">% have to be specific due to 1x6 object when bouncing occurs</span> | <span class="comment">% have to be specific due to 1x6 object when bouncing occurs</span> | ||
<span class="keyword">if</span> size(points{row,altcol},2)~=3 | <span class="keyword">if</span> size(points{row,altcol},2)~=3 | ||
<span class="comment">%determine column in t or r for colour of line</span> | <span class="comment">%determine column in t or r for colour of line</span> | ||
<span class="keyword">if</span> col<=t <span class="comment">%plot blue for toeholds</span> | <span class="keyword">if</span> col<=t <span class="comment">%plot blue for toeholds</span> | ||
− | <span class="keyword">if</span> ((size(points{row-1,altcol},2)==3 | + | <span class="keyword">if</span> ((size(points{row-1,altcol},2)==3 && points{row-1,altcol}(1,1)==0) && points{row-1,altcol}(1,2)==col) |
− | + | ||
− | + | ||
<span class="comment">%if just split, don't plot from row-1 to row in t column since plotting from split point has just occurred</span> | <span class="comment">%if just split, don't plot from row-1 to row in t column since plotting from split point has just occurred</span> | ||
<span class="keyword">continue</span> | <span class="keyword">continue</span> | ||
− | <span class="keyword">elseif</span> points{row,altcol}==0 && size | + | <span class="keyword">elseif</span> points{row,altcol}==0 && size(points{row-1,altcol},2)~=3 |
− | + | ||
<span class="keyword">if</span> size(points{row-1,col},2)==3 | <span class="keyword">if</span> size(points{row-1,col},2)==3 | ||
− | plot3([points{row-1,col}(1,1), | + | plot3([points{row-1,col}(1,1), points{row,col}(1,1)], [points{row-1,col}(1,2), points{row,col}(1,2)], [points{row-1,col}(1,3), points{row,col}(1,3)],<span class="string">'b'</span>) |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<span class="keyword">elseif</span> size(points{row,col},2)==6 <span class="comment">%Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary</span> | <span class="keyword">elseif</span> size(points{row,col},2)==6 <span class="comment">%Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary</span> | ||
bounceplot(points, row, col, <span class="string">'b'</span>) | bounceplot(points, row, col, <span class="string">'b'</span>) | ||
Line 538: | Line 493: | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">if</span> col>t <span class="comment">%plot red for rna(trigger)</span> | <span class="keyword">if</span> col>t <span class="comment">%plot red for rna(trigger)</span> | ||
− | <span class="keyword">if</span> ((size(points{row-1,altcol},2)==3 | + | <span class="keyword">if</span> ((size(points{row-1,altcol},2)==3 && points{row-1,altcol}(1,1)==0) && points{row-1,altcol}(1,3)==col) |
− | + | ||
− | + | ||
<span class="comment">%if just split, don't plot from row-1 to row in r column since plotting from split point has just occurred</span> | <span class="comment">%if just split, don't plot from row-1 to row in r column since plotting from split point has just occurred</span> | ||
<span class="keyword">continue</span> | <span class="keyword">continue</span> | ||
− | <span class="keyword">elseif</span> points{row,altcol}==0 && size | + | <span class="keyword">elseif</span> points{row,altcol}==0 && size(points{row-1,altcol},2)~=3 |
− | + | ||
<span class="keyword">if</span> size(points{row-1,col},2)==3 | <span class="keyword">if</span> size(points{row-1,col},2)==3 | ||
− | plot3([points{row-1,col}(1,1), | + | plot3([points{row-1,col}(1,1), points{row,col}(1,1)], [points{row-1,col}(1,2), points{row,col}(1,2)], [points{row-1,col}(1,3), points{row,col}(1,3)],<span class="string">'r'</span>) |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<span class="keyword">elseif</span> size(points{row,col},2)==6 <span class="comment">%Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary</span> | <span class="keyword">elseif</span> size(points{row,col},2)==6 <span class="comment">%Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary</span> | ||
bounceplot(points, row, col, <span class="string">'r'</span>) | bounceplot(points, row, col, <span class="string">'r'</span>) | ||
Line 564: | Line 511: | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
− | </pre><h2>Bouncing function<a name=" | + | </pre><h2>Bouncing function<a name="14"></a></h2><pre class="codeinput"> <span class="keyword">function</span> [points] = bounceplot(points, row, col, style) |
+ | |||
+ | <span class="comment">% coordinate structure is now: row-1 = [lastX lastY lastZ]</span> | ||
+ | <span class="comment">% row = [newY exitZ newZ exitX newX exitY ]</span> | ||
− | plot3([points{row-1,col}(1,1) points{row,col}(1,4)], | + | plot3([points{row-1,col}(1,1) points{row,col}(1,4)], [points{row-1,col}(1,2) points{row,col}(1,5)], [points{row-1,col}(1,3) points{row,col}(1,6)],style) |
− | + | plot3([points{row,col}(1,4) points{row,col}(1,1)], [points{row,col}(1,5) points{row,col}(1,2)], [points{row,col}(1,6) points{row,col}(1,3)],style) | |
− | + | ||
− | plot3([points{row,col}(1,4) points{row,col}(1,1)], | + | |
− | + | ||
− | + | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
− | </pre><h2>Counting function<a name=" | + | </pre><h2>Counting function<a name="15"></a></h2><p>This function is related to the generation of a GFP output of our system, it is used in combination with the parameter scanning aspect of our simulation.</p><pre class="codeinput"> <span class="keyword">function</span> counter(points) |
− | + | <span class="comment">%simplfied status of each toehold and trigger drawn from points array</span> | |
<span class="keyword">for</span> jstatcol=1:t+r | <span class="keyword">for</span> jstatcol=1:t+r | ||
<span class="keyword">for</span> jstatrow=2:N | <span class="keyword">for</span> jstatrow=2:N | ||
− | <span class="keyword">if</span> points{jstatrow,jstatcol}(1)==points{jstatrow-1, | + | <span class="keyword">if</span> points{jstatrow,jstatcol}(1)==points{jstatrow-1,jstatcol}(1) && points{jstatrow,jstatcol}(2)==points{jstatrow-1,jstatcol}(2) && points{jstatrow,jstatcol}(3)==points{jstatrow-1,jstatcol}(3) |
− | + | ||
− | + | ||
− | + | ||
joinstatus(jstatrow,jstatcol)=1; | joinstatus(jstatrow,jstatcol)=1; | ||
<span class="comment">% if joinstatus{jstatrow-1,jstatcol}==0</span> | <span class="comment">% if joinstatus{jstatrow-1,jstatcol}==0</span> | ||
Line 601: | Line 544: | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
totalgreentime=totalgreen*tau; | totalgreentime=totalgreen*tau; | ||
− | GFPrate= | + | GFPrate=1.2; |
GFPcount=totalgreentime*GFPrate; | GFPcount=totalgreentime*GFPrate; | ||
<span class="comment">%GFPconc=GFPcount/eppendorfvolume;</span> | <span class="comment">%GFPconc=GFPcount/eppendorfvolume;</span> | ||
+ | <span class="comment">%GFPrate is calculated using E0040 Biobrick for GFP (720 base</span> | ||
+ | <span class="comment">%pairs/240 AA) Ribosome speed @ 200AA/min -> 240/200 = 1.2 GFP/min</span> | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
− | </pre><h2>Code needed to produce a .gif file of the simulation output<a name=" | + | </pre><h2>Code needed to produce a .gif file of the simulation output<a name="16"></a></h2><pre class="codeinput"> <span class="keyword">function</span> jiff(row) |
change = 360/N; <span class="comment">% the size of the angle change</span> | change = 360/N; <span class="comment">% the size of the angle change</span> | ||
<span class="comment">% gif utilities</span> | <span class="comment">% gif utilities</span> | ||
Line 624: | Line 569: | ||
imwrite(imind,cm,outfile,<span class="string">'gif'</span>,<span class="string">'DelayTime'</span>,0,<span class="string">'loopcount'</span>,inf); | imwrite(imind,cm,outfile,<span class="string">'gif'</span>,<span class="string">'DelayTime'</span>,0,<span class="string">'loopcount'</span>,inf); | ||
<span class="keyword">else</span> | <span class="keyword">else</span> | ||
− | imwrite(imind,cm,outfile,<span class="string">'gif'</span>,<span class="string">'DelayTime'</span>,0,<span class="string">'writemode'</span>, | + | imwrite(imind,cm,outfile,<span class="string">'gif'</span>,<span class="string">'DelayTime'</span>,0,<span class="string">'writemode'</span>,<span class="string">'append'</span>); |
− | + | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
<span class="keyword">end</span> | <span class="keyword">end</span> | ||
</pre><pre class="codeinput"><span class="keyword">end</span> | </pre><pre class="codeinput"><span class="keyword">end</span> | ||
− | </pre><h2>End Of The Code<a name=" | + | </pre><h2>End Of The Code<a name="18"></a></h2><p>This is the final simulation developed by the Univeristy Of Exeter iGEM team 2015. Developed mainly by Amy, Dan and Todd.</p><p class="footer"><br><a href="http://www.mathworks.com/products/matlab/">Published with MATLAB® R2015a</a><br></p></div><!-- |
##### SOURCE BEGIN ##### | ##### SOURCE BEGIN ##### | ||
− | %% | + | %% BM_07_09 |
% Our final code for the simulation of our cell free kit. This is after the | % Our final code for the simulation of our cell free kit. This is after the | ||
% restructure implimented after meetings with both Jonathan Fieldsend and | % restructure implimented after meetings with both Jonathan Fieldsend and | ||
Line 647: | Line 591: | ||
% choosen. | % choosen. | ||
− | function [GFPcount] = | + | function [GFPcount] = BM_07_09_insilicobinding(t,r,N,T) |
%% Setting our deafault parameters and variables | %% Setting our deafault parameters and variables | ||
% These are the parameters used for the basic setup of Brownian motion as | % These are the parameters used for the basic setup of Brownian motion as | ||
Line 654: | Line 598: | ||
% well plate now. | % well plate now. | ||
% All units are SI units unless otherwise stated. | % All units are SI units unless otherwise stated. | ||
− | + | ||
rng('shuffle'); | rng('shuffle'); | ||
Line 664: | Line 608: | ||
d_r=1.7e-8; % of RNA | d_r=1.7e-8; % of RNA | ||
d_c=5.1e-8; % of toehold-RNA complex | d_c=5.1e-8; % of toehold-RNA complex | ||
− | D_t = kB * T / (3 * pi * eta * d_t); %diffusion coefficient | + | D_t = kB * T / (3 * pi * eta * d_t); %diffusion coefficient |
− | D_r = kB * T / (3 * pi * eta * d_r); | + | D_r = kB * T / (3 * pi * eta * d_r); |
− | D_c = kB * T / (3 * pi * eta * d_c); | + | D_c = kB * T / (3 * pi * eta * d_c); |
p_t = sqrt(2*D_t*tau); | p_t = sqrt(2*D_t*tau); | ||
p_r = sqrt(2*D_r*tau); | p_r = sqrt(2*D_r*tau); | ||
p_c = sqrt(2*D_c*tau); | p_c = sqrt(2*D_c*tau); | ||
− | %CONFINEMENT - height can be changed depending on the volume of | + | %CONFINEMENT - height can be changed depending on the volume of the solution (rather than the total possible volume of the eppendorf) |
− | + | A = (3.5e-10)*2; %binding distance, default at 1e-7, real world value .5e-10 | |
− | A = | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | cylinder_radius=3.34e-6; %radius of F-Well plate well in metres (3.34e-3metres) %changed | ||
+ | tube_height_max=7.13e-7; %height of F-Well plate well to fill i billionth of 50microlitres (1.426e-3metres) | ||
+ | tube_height_min=-7.13e-7; | ||
+ | %Changeable to suit the container of your system | ||
+ | %Total height is split in half, with one half above the positive xy plane and one half below | ||
+ | cone_height=18e-3; %unused | ||
+ | |||
+ | |||
%GIF stuff | %GIF stuff | ||
− | theta = 0; % changes the viewing angle | + | theta = 0; % changes the viewing angle |
− | %Figure Stuff | + | %Figure Stuff |
% figure() | % figure() | ||
% %axis([-0.00005 0.00005 -0.00005 0.00005 -0.00005 0.00005]); | % %axis([-0.00005 0.00005 -0.00005 0.00005 -0.00005 0.00005]); | ||
Line 716: | Line 663: | ||
end | end | ||
bouncepoints=points; | bouncepoints=points; | ||
− | |||
%% The coordinate generation and the main loop | %% The coordinate generation and the main loop | ||
% The coordinates are now generated on the fly at every time step, this | % The coordinates are now generated on the fly at every time step, this | ||
Line 724: | Line 670: | ||
− | %The main for loop -> loops over all the time steps | + | %The main for loop -> loops over all the time steps |
− | for j=1:N | + | |
+ | for j=1:N | ||
%% Generation of the inital starting points, calls startpoint. | %% Generation of the inital starting points, calls startpoint. | ||
− | + | ||
− | if j==1 | + | if j==1 |
[coords, startposition] = startpoint(); | [coords, startposition] = startpoint(); | ||
+ | % c_joined=zeros(1,c); | ||
+ | % c_split=zeros(1,c); | ||
check=zeros(c,3); | check=zeros(c,3); | ||
else | else | ||
Line 736: | Line 685: | ||
% then checkxy is called to check whether it has left the | % then checkxy is called to check whether it has left the | ||
% cyclinder. | % cyclinder. | ||
− | + | ||
%Toehold | %Toehold | ||
for i=1:t | for i=1:t | ||
Line 751: | Line 700: | ||
end | end | ||
%calling checkxy to check x and y | %calling checkxy to check x and y | ||
− | [coords,bouncepoints]=checkxy(cylinder_radius, | + | [coords,bouncepoints]=checkxy(cylinder_radius, coords, i, bouncepoints); |
− | + | % | |
end | end | ||
end | end | ||
Line 763: | Line 712: | ||
end | end | ||
% checking against the height of the tube. | % checking against the height of the tube. | ||
+ | |||
if coords(3,i)>=tube_height_max | if coords(3,i)>=tube_height_max | ||
coords(3,i)=tube_height_max; | coords(3,i)=tube_height_max; | ||
Line 769: | Line 719: | ||
coords(3,i)=tube_height_min; | coords(3,i)=tube_height_min; | ||
end | end | ||
− | + | % %calling checkxy to check x and y | |
− | [coords,bouncepoints]=checkxy(cylinder_radius, | + | [coords,bouncepoints]=checkxy(cylinder_radius, coords, i, bouncepoints); |
− | + | ||
end | end | ||
end | end | ||
Line 788: | Line 737: | ||
coords(3,i)=tube_height_min; | coords(3,i)=tube_height_min; | ||
end | end | ||
− | + | % %calling checkxy to check x and y | |
− | [coords,bouncepoints]=checkxy(cylinder_radius, | + | [coords,bouncepoints]=checkxy(cylinder_radius, coords, i, bouncepoints); |
− | + | ||
end | end | ||
end | end | ||
end | end | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
for q=1:c | for q=1:c | ||
if check(q,3)==0 && check(q,1)==0 && check(q,2)==0 && j~=1 | if check(q,3)==0 && check(q,1)==0 && check(q,2)==0 && j~=1 | ||
− | + | jointime=j; %variable to make sure joiner and splitter dont happen in same time step | |
− | + | [coords,check, startposition, points] = joiner(coords,check, startposition, points); | |
− | [coords,check, startposition, points] = joiner(coords, | + | |
− | + | ||
elseif check(q,3)~=0 | elseif check(q,3)~=0 | ||
check(q,3)=check(q,3)+1; | check(q,3)=check(q,3)+1; | ||
end | end | ||
if check(q,1)~=0 && check(q,2)~=0 && j~=jointime | if check(q,1)~=0 && check(q,2)~=0 && j~=jointime | ||
− | [coords, check, startposition, points] = splitter(q, | + | [coords, check, startposition, points] = splitter(q, coords, check, startposition, points); |
− | + | ||
end | end | ||
end | end | ||
%% Bouncing | %% Bouncing | ||
% | % | ||
− | |||
for f=1:t+r+c | for f=1:t+r+c | ||
if f<t+r+1 | if f<t+r+1 | ||
Line 822: | Line 760: | ||
matcoords=[coords(1,f),coords(2,f),coords(3,f)]; | matcoords=[coords(1,f),coords(2,f),coords(3,f)]; | ||
points{j,f}=matcoords; | points{j,f}=matcoords; | ||
− | + | %couldn't have these statements on the same line for some reason | |
+ | |||
elseif bouncepoints{j,f}~=0 | elseif bouncepoints{j,f}~=0 | ||
− | if size(bouncepoints{j,f},2)==3 | + | if size(bouncepoints{j,f},2)==3 %couldn't have these statements on the same line for some reason |
− | matcoords=[coords(1,f),coords(2,f),coords(3,f) | + | matcoords=[coords(1,f),coords(2,f),coords(3,f) bouncepoints{j,f}(1,1),bouncepoints{j,f}(1,2),bouncepoints{j,f}(1,3)]; |
− | + | ||
− | + | ||
points{j,f}=matcoords; | points{j,f}=matcoords; | ||
end | end | ||
Line 842: | Line 779: | ||
elseif bouncepoints{j,g}~=0 | elseif bouncepoints{j,g}~=0 | ||
if size(bouncepoints{j,f},2)==3 | if size(bouncepoints{j,f},2)==3 | ||
− | matcoords=[coords(1,f),coords(2,f),coords(3,f) | + | matcoords=[coords(1,f),coords(2,f),coords(3,f) bouncepoints{j,g}(1,1),bouncepoints{j,g}(1,2),bouncepoints{j,g}(1,3)]; |
− | + | ||
− | + | ||
points{j,g}=matcoords; | points{j,g}=matcoords; | ||
end | end | ||
Line 862: | Line 797: | ||
if j==N | if j==N | ||
+ | plotter(points); | ||
counter(points); | counter(points); | ||
finish=1; | finish=1; | ||
Line 872: | Line 808: | ||
% A vector called startpositon is made so the particles are located around | % A vector called startpositon is made so the particles are located around | ||
% this. | % this. | ||
− | |||
function [coords, startposition] = startpoint() | function [coords, startposition] = startpoint() | ||
− | %each column is a toehold, with six rows, | + | coords=zeros(6,(t+r+c)); %each column is a toehold, with six rows, for current xyz and previous xyz |
− | + | % startposition=zeros(6,(t+r+c)); | |
− | + | % coords=mat2dataset(coords); | |
for m=1:t+r | for m=1:t+r | ||
− | coords(3,m)=(tube_height_min)+ | + | coords(3,m)=(tube_height_min)+((tube_height_max-tube_height_min)*rand(1)); |
− | + | coords(1,m)=(-cylinder_radius)+((cylinder_radius-(-cylinder_radius))*rand(1)); | |
− | + | coords(2,m)=(-cylinder_radius)+((cylinder_radius-(-cylinder_radius))*rand(1)); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
end | end | ||
startposition=coords; | startposition=coords; | ||
end | end | ||
− | + | ||
%% Checking function | %% Checking function | ||
% Checks the coordinates are within the boundaries of the eppendorf | % Checks the coordinates are within the boundaries of the eppendorf | ||
Line 908: | Line 832: | ||
function [coords,bouncepoints]=checkxy(radius,coords,i,bouncepoints) | function [coords,bouncepoints]=checkxy(radius,coords,i,bouncepoints) | ||
+ | %Function that checks whether the particle is inside of the tube | ||
+ | %for its calculated z-coordinate at the point of contact in the | ||
+ | %tube (in cone: via line equation intersects of path and boundary | ||
+ | %// in cylinder: line equation of tube boundary). | ||
+ | %From this point of contact, the new X and Y coordinates are | ||
+ | %calculated for the "exit point" and then subsequently, the new | ||
+ | %resultant xyz can be calculated | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | %confirmed to be correct | + | if (coords(1,i)^2)+(coords(2,i)^2)>=(radius^2) |
− | + | %red box in (Maths for exitx.png explains derivation) | |
− | + | %setting exitX/Y at boundary of cylinder | |
− | + | grad=abs((sqrt((coords(1,i)^2)+(coords(2,i)^2))-sqrt((coords(4,i)^2)+(coords(5,i)^2)))/(coords(3,i)-coords(6,i))); | |
− | + | ||
− | + | ||
− | + | %confirmed to be correct | |
− | + | if coords(1,i)<0 | |
− | + | exitX=-sqrt((radius^2)/((grad^2)+1)); | |
− | + | else | |
− | + | exitX=sqrt((radius^2)/((grad^2)+1)); | |
+ | end | ||
+ | if coords(2,i)<0 | ||
+ | exitY=-(grad*sqrt(((radius^2)/((grad^2)+1)))); | ||
+ | else | ||
+ | exitY=grad*sqrt(((radius^2)/((grad^2)+1))); | ||
+ | end | ||
+ | |||
+ | Px=coords(1,i); | ||
+ | Py=coords(2,i); | ||
+ | lastx=coords(4,i); | ||
+ | lasty=coords(5,i); | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | trajectory_gradient=(Py-lasty)/(Px-lastx); %m1 | ||
+ | tangent_gradient=(-exitX/exitY); %m2 | ||
+ | theta_bounce=atan(trajectory_gradient); | ||
+ | phi_2=atan(tangent_gradient); | ||
+ | phi_1=theta_bounce-phi_2; | ||
+ | exitPDist=sqrt(((Px-lastx)^2)+((Py-lasty)^2)); | ||
+ | G_length=exitPDist*cos(phi_1); | ||
+ | Gx=exitX+(G_length*cos(phi_1)); | ||
+ | Gy=exitY+(G_length*cos(phi_1)); | ||
+ | Cx=Px-Gx; | ||
+ | Cy=Py-Gy; | ||
+ | newX=Px-(2*Cx); | ||
+ | newY=Py-(2*Cy); | ||
+ | |||
+ | perpendicular_gradient=(exitY/exitX); | ||
+ | % shifted_perpendicular_line=(perpendicular_gradient*EX)-((exitY+Px)/exitX)+Py; | ||
+ | |||
+ | %z-intercept with boundary: (see book) | ||
+ | prad=sqrt((coords(1,i)^2)+(coords(2,i)^2)); | ||
+ | lastrad=sqrt((coords(4,i)^2)+(coords(5,i)^2)); | ||
+ | Dr=prad-lastrad; | ||
+ | pZ=coords(3,i); | ||
+ | lastZ=coords(6,i); | ||
+ | Dz=pZ-lastZ; | ||
+ | Gr=radius-lastrad; | ||
+ | Gz=Gr*tan(acos(Dr/sqrt((Dr^2)+(Dz^2)))); | ||
− | + | if pZ<lastZ | |
− | + | exitZ=lastZ-Gz; | |
− | + | else | |
− | + | exitZ=lastZ+Gz; | |
− | + | end | |
− | + | %write new points directly into points in a way that joiner and | |
− | + | %splitter can still work | |
− | + | if i<=t+r | |
− | + | bouncepoints{j,i}=[exitX exitY exitZ]; | |
− | + | elseif i>t+r | |
− | + | bouncepoints{j,(2*i)-1}=[exitX exitY exitZ]; | |
− | + | end | |
− | + | %update for next point | |
− | + | coords(1,i)=newX; | |
− | + | coords(2,i)=newY; | |
− | + | coords(3,i)=coords(3,i); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
end | end | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
Line 982: | Line 919: | ||
% complex line is made instead. | % complex line is made instead. | ||
% startingposition is also updated to indicate the new starting point of the | % startingposition is also updated to indicate the new starting point of the | ||
− | % complex line. | + | % complex line. |
− | + | function [coords, check, startposition, points] = joiner(coords, check, startposition, points) | |
− | function [coords, check, startposition, points] = joiner(coords, | + | |
− | + | ||
colshift=0; | colshift=0; | ||
− | + | %Joining probability calculated from in silico data of free energy of complex from NUPACK and | |
− | if | + | %equation of polynomial fit to normalised curve gives probability |
+ | %of binding (or rather gives the threshold to enable a successful | ||
+ | %binding event which a randomly generated number is tested against) | ||
+ | joinevent = (randi([1 10000000],1))/10000000; | ||
+ | Tempcorrection = T-273; | ||
+ | jointhreshold = ((4e-07)*(Tempcorrection^4)) - ((6e-05)*(Tempcorrection^3)) + (0.0023*(Tempcorrection^2)) - (0.0072*Tempcorrection) + 0.3745; | ||
+ | if joinevent >= jointhreshold | ||
for n=1:t | for n=1:t | ||
for m=t+1:r+t | for m=t+1:r+t | ||
Line 995: | Line 936: | ||
else | else | ||
% if ((((tx(j,k)-rx(j,m))^2)+((ty(j,k)-ry(j,m))^2)+((tz(j,k)-rz(j,m))^2))<=(A^2) || (check_r(1,m)~=0 && check_t(1,k)~=0)) && (j~=1) && delay(1,n)==0 | % if ((((tx(j,k)-rx(j,m))^2)+((ty(j,k)-ry(j,m))^2)+((tz(j,k)-rz(j,m))^2))<=(A^2) || (check_r(1,m)~=0 && check_t(1,k)~=0)) && (j~=1) && delay(1,n)==0 | ||
− | + | if (((coords(1,n)-coords(1,m))^2)+((coords(2,n)-coords(2,m))^2)+((coords(3,n)-coords(3,m))^2))<=(A^2) | |
− | if (((coords(1,n)-coords(1,m))^2)+((coords(2,n)- | + | |
− | + | ||
− | + | ||
for p=1:c | for p=1:c | ||
if check(p,1)~=0 && check(p,2)~=0 | if check(p,1)~=0 && check(p,2)~=0 | ||
Line 1,004: | Line 942: | ||
else | else | ||
if check(p,1)==0 && check(p,2)==0 | if check(p,1)==0 && check(p,2)==0 | ||
− | coords(1,t+r+p)=(coords(1,n)+ | + | coords(1,t+r+p)=(coords(1,n)+coords(1,m))/2; |
− | + | coords(2,t+r+p)=(coords(2,n)+coords(2,m))/2; | |
− | coords(2,t+r+p)=(coords(2,n)+ | + | coords(3,t+r+p)=(coords(3,n)+coords(3,m))/2; |
− | + | startposition(1,t+r+p)=coords(1,t+r+p); | |
− | coords(3,t+r+p)=(coords(3,n)+ | + | startposition(2,t+r+p)=coords(2,t+r+p); |
− | + | startposition(3,t+r+p)=coords(3,t+r+p); | |
− | startposition(1,t+r+p)= | + | |
− | + | ||
− | startposition(2,t+r+p)= | + | |
− | + | ||
− | startposition(3,t+r+p)= | + | |
− | + | ||
check(p,1)=n; | check(p,1)=n; | ||
check(p,2)=m; | check(p,2)=m; | ||
Line 1,040: | Line 972: | ||
% If a threshold is reached the complex will split back into a toehold and | % If a threshold is reached the complex will split back into a toehold and | ||
% RNA. These lines are now produced again, check is updated to reflect this | % RNA. These lines are now produced again, check is updated to reflect this | ||
− | % and finally startposition is changed. | + | % and finally startposition is changed. |
− | function [coords, check, startposition, points] = | + | function [coords, check, startposition, points] = splitter(q, coords, check, startposition, points) |
− | + | splitevent = (randi([1 10000000],1))/10000000; | |
− | + | Tempcorrection = T-273; | |
− | if | + | splitthreshold = (-(4e-07)*(Tempcorrection^4)) + ((6e-05)*(Tempcorrection^3)) - (0.0023*(Tempcorrection^2)) + (0.0072*Tempcorrection) + 0.6255; |
+ | %y=-4E-07x4 + 6E-05x3 - 0.0023x2 + 0.0072x + 0.6255 | ||
+ | |||
+ | |||
+ | if splitevent<=splitthreshold | ||
if check(q,1)~=0 && check(q,2)~=0 | if check(q,1)~=0 && check(q,2)~=0 | ||
toehold=check(q,1); | toehold=check(q,1); | ||
Line 1,061: | Line 997: | ||
coords(2,toehold)=coords(2,t+r+q); | coords(2,toehold)=coords(2,t+r+q); | ||
coords(3,toehold)=coords(3,t+r+q); | coords(3,toehold)=coords(3,t+r+q); | ||
+ | |||
points{j,t+r+(2*q)}=[0,toehold,rna]; | points{j,t+r+(2*q)}=[0,toehold,rna]; | ||
Line 1,072: | Line 1,009: | ||
%% Plotting function | %% Plotting function | ||
% | % | ||
− | |||
function [] = plotter(points) | function [] = plotter(points) | ||
%Conditions from plotting drawn from points array | %Conditions from plotting drawn from points array | ||
Line 1,079: | Line 1,015: | ||
%startpoints | %startpoints | ||
for col=1:t+r | for col=1:t+r | ||
− | plot3(points{row,col}(1,1), points{row,col}(1,2), | + | plot3(points{row,col}(1,1), points{row,col}(1,2), points{row,col}(1,3),'kx') |
− | + | ||
end | end | ||
else | else | ||
for altcol=t+r+2:2:t+r+(2*c) | for altcol=t+r+2:2:t+r+(2*c) | ||
− | if points{row,altcol}(1,1)==1 && size(points{ | + | if points{row,altcol}(1,1)==1 && size(points{row,altcol},2)==3 && row>1 |
− | + | ||
if points{row-1,altcol}(1,1)==0 %definitely joinpoint | if points{row-1,altcol}(1,1)==0 %definitely joinpoint | ||
%plot blue using row-1 to row to joinpoint column, column selected from points{row,col}(1,2)) | %plot blue using row-1 to row to joinpoint column, column selected from points{row,col}(1,2)) | ||
− | plot3([points{row-1,(points{row,altcol}(1,2))}(1,1), | + | plot3([points{row-1,(points{row,altcol}(1,2))}(1,1), points{row,altcol-1}(1,1)], [points{row-1,(points{row,altcol}(1,2))}(1,2), points{row,altcol-1}(1,2)], [points{row-1,(points{row,altcol}(1,2))}(1,3), points{row,altcol-1}(1,3)], 'b') |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
%plot red using row-1 to row to joinpoint column, column selected from points{row,col}(1,2) | %plot red using row-1 to row to joinpoint column, column selected from points{row,col}(1,2) | ||
− | plot3([points{row-1,(points{row,altcol}(1,3))}(1,1), | + | plot3([points{row-1,(points{row,altcol}(1,3))}(1,1), points{row,altcol-1}(1,1)], [points{row-1,(points{row,altcol}(1,3))}(1,2), points{row,altcol-1}(1,2)], [points{row-1,(points{row,altcol}(1,3))}(1,3), points{row,altcol-1}(1,3)], 'r') |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
%plot circle at joinpoint | %plot circle at joinpoint | ||
− | plot3(points{row,altcol-1}(1,1), | + | plot3(points{row,altcol-1}(1,1), points{row,altcol-1}(1,2), points{row,altcol-1}(1,3), 'ko') |
− | + | ||
− | + | ||
end | end | ||
if points{row-1,altcol}(1,1)==1 %defintely splitpoint | if points{row-1,altcol}(1,1)==1 %defintely splitpoint | ||
%do nothing | %do nothing | ||
end | end | ||
− | elseif (points{row,altcol}(1,1)==1 && | + | elseif (points{row,altcol}(1,1)==1 && size(points{row,altcol},2)==1) || (points{row,altcol}(1,1)==0 && size(points{row,altcol},2)==3) |
− | + | ||
− | + | ||
− | + | ||
%plot green from row-1 to row | %plot green from row-1 to row | ||
if size(points{row-1,altcol-1},2)==3 | if size(points{row-1,altcol-1},2)==3 | ||
− | plot3([points{row-1,altcol-1}(1,1), | + | plot3([points{row-1,altcol-1}(1,1), points{row, altcol-1}(1,1)], [points{row-1,altcol-1}(1,2), points{row, altcol-1}(1,2)], [points{row-1,altcol-1}(1,3), points{row, altcol-1}(1,3)],'g') |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
elseif size(points{row,altcol-1},2)==6 %Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary | elseif size(points{row,altcol-1},2)==6 %Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary | ||
bounceplot(points, row, altcol-1, 'g') | bounceplot(points, row, altcol-1, 'g') | ||
Line 1,126: | Line 1,040: | ||
end | end | ||
if points{row,altcol}(1,1)==0 %currently split | if points{row,altcol}(1,1)==0 %currently split | ||
− | if size(points{row-1,altcol},2)==3 && | + | if size(points{row-1,altcol},2)==3 && points{row-1,altcol}(1,1)==0 %prevents incorrect plotting in the case of join/split in consecutive timesteps |
− | + | ||
%plot from split column to blue column | %plot from split column to blue column | ||
− | plot3([points{row-1,altcol-1}(1,1), | + | plot3([points{row-1,altcol-1}(1,1), points{row,(points{row-1,altcol}(1,2))}(1,1)],[points{row-1,altcol-1}(1,2), points{row,(points{row-1,altcol}(1,2))}(1,2)],[points{row-1,altcol-1}(1,3), points{row,(points{row-1,altcol}(1,2))}(1,3)],'b') |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
%plot from split column to red column | %plot from split column to red column | ||
− | plot3([points{row-1,altcol-1}(1,1), | + | plot3([points{row-1,altcol-1}(1,1), points{row,(points{row-1,altcol}(1,3))}(1,1)],[points{row-1,altcol-1}(1,2), points{row,(points{row-1,altcol}(1,3))}(1,2)],[points{row-1,altcol-1}(1,3), points{row,(points{row-1,altcol}(1,3))}(1,3)],'r') |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
%plot star at splitpoint | %plot star at splitpoint | ||
− | plot3(points{row-1,altcol-1}(1,1), points | + | plot3(points{row-1,altcol-1}(1,1), points{row-1,altcol-1}(1,2), points{row-1,altcol-1}(1,3), 'k*') |
− | + | ||
− | + | ||
%plot | %plot | ||
continue %might not be necessary | continue %might not be necessary | ||
Line 1,153: | Line 1,052: | ||
end | end | ||
for col=1:t+r | for col=1:t+r | ||
− | if points{row,col}(1,1)~=points{row-1,col}(1,1) | + | if points{row,col}(1,1)~=points{row-1,col}(1,1) && points{row,col}(1,2)~=points{row-1,col}(1,2) && points{row,col}(1,3)~=points{row-1,col}(1,3) |
− | + | ||
− | + | ||
− | + | ||
% have to be specific due to 1x6 object when bouncing occurs | % have to be specific due to 1x6 object when bouncing occurs | ||
if size(points{row,altcol},2)~=3 | if size(points{row,altcol},2)~=3 | ||
%determine column in t or r for colour of line | %determine column in t or r for colour of line | ||
if col<=t %plot blue for toeholds | if col<=t %plot blue for toeholds | ||
− | if ((size(points{row-1,altcol},2)==3 | + | if ((size(points{row-1,altcol},2)==3 && points{row-1,altcol}(1,1)==0) && points{row-1,altcol}(1,2)==col) |
− | + | ||
− | + | ||
%if just split, don't plot from row-1 to row in t column since plotting from split point has just occurred | %if just split, don't plot from row-1 to row in t column since plotting from split point has just occurred | ||
continue | continue | ||
− | elseif points{row,altcol}==0 && size | + | elseif points{row,altcol}==0 && size(points{row-1,altcol},2)~=3 |
− | + | ||
if size(points{row-1,col},2)==3 | if size(points{row-1,col},2)==3 | ||
− | plot3([points{row-1,col}(1,1), | + | plot3([points{row-1,col}(1,1), points{row,col}(1,1)], [points{row-1,col}(1,2), points{row,col}(1,2)], [points{row-1,col}(1,3), points{row,col}(1,3)],'b') |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
elseif size(points{row,col},2)==6 %Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary | elseif size(points{row,col},2)==6 %Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary | ||
bounceplot(points, row, col, 'b') | bounceplot(points, row, col, 'b') | ||
Line 1,181: | Line 1,069: | ||
end | end | ||
if col>t %plot red for rna(trigger) | if col>t %plot red for rna(trigger) | ||
− | if ((size(points{row-1,altcol},2)==3 | + | if ((size(points{row-1,altcol},2)==3 && points{row-1,altcol}(1,1)==0) && points{row-1,altcol}(1,3)==col) |
− | + | ||
− | + | ||
%if just split, don't plot from row-1 to row in r column since plotting from split point has just occurred | %if just split, don't plot from row-1 to row in r column since plotting from split point has just occurred | ||
continue | continue | ||
− | elseif points{row,altcol}==0 && size | + | elseif points{row,altcol}==0 && size(points{row-1,altcol},2)~=3 |
− | + | ||
if size(points{row-1,col},2)==3 | if size(points{row-1,col},2)==3 | ||
− | plot3([points{row-1,col}(1,1), | + | plot3([points{row-1,col}(1,1), points{row,col}(1,1)], [points{row-1,col}(1,2), points{row,col}(1,2)], [points{row-1,col}(1,3), points{row,col}(1,3)],'r') |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
elseif size(points{row,col},2)==6 %Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary | elseif size(points{row,col},2)==6 %Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary | ||
bounceplot(points, row, col, 'r') | bounceplot(points, row, col, 'r') | ||
Line 1,207: | Line 1,087: | ||
end | end | ||
end | end | ||
− | |||
%% Bouncing function | %% Bouncing function | ||
% | % | ||
Line 1,213: | Line 1,092: | ||
function [points] = bounceplot(points, row, col, style) | function [points] = bounceplot(points, row, col, style) | ||
− | plot3([points{row-1,col}(1,1) points{row,col}(1,4)], | + | % coordinate structure is now: row-1 = [lastX lastY lastZ] |
− | + | % row = [newY exitZ newZ exitX newX exitY ] | |
− | + | ||
− | plot3([points{row,col}(1,4) points{row,col}(1,1)], | + | plot3([points{row-1,col}(1,1) points{row,col}(1,4)], [points{row-1,col}(1,2) points{row,col}(1,5)], [points{row-1,col}(1,3) points{row,col}(1,6)],style) |
− | + | plot3([points{row,col}(1,4) points{row,col}(1,1)], [points{row,col}(1,5) points{row,col}(1,2)], [points{row,col}(1,6) points{row,col}(1,3)],style) | |
− | + | ||
end | end | ||
Line 1,227: | Line 1,105: | ||
function counter(points) | function counter(points) | ||
− | + | %simplfied status of each toehold and trigger drawn from points array | |
for jstatcol=1:t+r | for jstatcol=1:t+r | ||
for jstatrow=2:N | for jstatrow=2:N | ||
− | if points{jstatrow,jstatcol}(1)==points{jstatrow-1, | + | if points{jstatrow,jstatcol}(1)==points{jstatrow-1,jstatcol}(1) && points{jstatrow,jstatcol}(2)==points{jstatrow-1,jstatcol}(2) && points{jstatrow,jstatcol}(3)==points{jstatrow-1,jstatcol}(3) |
− | + | ||
− | + | ||
− | + | ||
joinstatus(jstatrow,jstatcol)=1; | joinstatus(jstatrow,jstatcol)=1; | ||
% if joinstatus{jstatrow-1,jstatcol}==0 | % if joinstatus{jstatrow-1,jstatcol}==0 | ||
Line 1,254: | Line 1,129: | ||
end | end | ||
totalgreentime=totalgreen*tau; | totalgreentime=totalgreen*tau; | ||
− | GFPrate= | + | GFPrate=1.2; |
GFPcount=totalgreentime*GFPrate; | GFPcount=totalgreentime*GFPrate; | ||
%GFPconc=GFPcount/eppendorfvolume; | %GFPconc=GFPcount/eppendorfvolume; | ||
− | + | %GFPrate is calculated using E0040 Biobrick for GFP (720 base | |
+ | %pairs/240 AA) Ribosome speed @ 200AA/min -> 240/200 = 1.2 GFP/min | ||
+ | |||
end | end | ||
Line 1,280: | Line 1,157: | ||
imwrite(imind,cm,outfile,'gif','DelayTime',0,'loopcount',inf); | imwrite(imind,cm,outfile,'gif','DelayTime',0,'loopcount',inf); | ||
else | else | ||
− | imwrite(imind,cm,outfile,'gif','DelayTime',0,'writemode', | + | imwrite(imind,cm,outfile,'gif','DelayTime',0,'writemode','append'); |
− | + | ||
end | end | ||
end | end | ||
Line 1,289: | Line 1,165: | ||
% iGEM team 2015. | % iGEM team 2015. | ||
% Developed mainly by Amy, Dan and Todd. | % Developed mainly by Amy, Dan and Todd. | ||
− | |||
##### SOURCE END ##### | ##### SOURCE END ##### | ||
--></body></html> | --></body></html> |
Latest revision as of 03:33, 19 September 2015
Contents
- BM_07_09
- Setting our deafault parameters and variables
- The coordinate generation and the main loop
- Generation of the inital starting points, calls startpoint.
- Coordinate generation and confinement checking
- Bouncing
- Startpoint
- Checking function
- Joining function
- Splitter function
- Plotting function
- Bouncing function
- Counting function
- Code needed to produce a .gif file of the simulation output
- End Of The Code
BM_07_09
Our final code for the simulation of our cell free kit. This is after the restructure implimented after meetings with both Jonathan Fieldsend and the lab team. There are still improvements and optimisations to be made these are discussed below. More information can be found at https://2015.igem.org/Team:Exeter/Modeling. The function take inputs of: * t - Number of toeholds * r - Number of RNA's * N - Number of time steps * T - temperature -> this is the parameter scanning variable It outputs GFPcount, this depends on the parameter scanning variable choosen.
function [GFPcount] = BM_07_09_insilicobinding(t,r,N,T)
Setting our deafault parameters and variables
These are the parameters used for the basic setup of Brownian motion as well as the contianment to a tube. Containment changed to a cylinder to emulate the lab, they are using a well plate now. All units are SI units unless otherwise stated.
rng('shuffle'); eta = 1.0e-3; % viscosity of water in SI units (Pascal-seconds) kB = 1.38e-23; % Boltzmann constant %T = 293; % Temperature in degrees Kelvin tau = .1; % time interval in seconds d_t=5.1e-8; % diameter in meters of toehold d_r=1.7e-8; % of RNA d_c=5.1e-8; % of toehold-RNA complex D_t = kB * T / (3 * pi * eta * d_t); %diffusion coefficient D_r = kB * T / (3 * pi * eta * d_r); D_c = kB * T / (3 * pi * eta * d_c); p_t = sqrt(2*D_t*tau); p_r = sqrt(2*D_r*tau); p_c = sqrt(2*D_c*tau); %CONFINEMENT - height can be changed depending on the volume of the solution (rather than the total possible volume of the eppendorf) A = (3.5e-10)*2; %binding distance, default at 1e-7, real world value .5e-10 cylinder_radius=3.34e-6; %radius of F-Well plate well in metres (3.34e-3metres) %changed tube_height_max=7.13e-7; %height of F-Well plate well to fill i billionth of 50microlitres (1.426e-3metres) tube_height_min=-7.13e-7; %Changeable to suit the container of your system %Total height is split in half, with one half above the positive xy plane and one half below cone_height=18e-3; %unused %GIF stuff theta = 0; % changes the viewing angle %Figure Stuff % figure() % %axis([-0.00005 0.00005 -0.00005 0.00005 -0.00005 0.00005]); % axis([-5e-3 5e-3 -5e-3 5e-3 -8e-3 8e-3]) %changed % grid on % grid MINOR % set(gcf, 'Position', [100 10 600 600]) % xlabel('X-axis') % ylabel('Y-axis') % zlabel('Z-axis') % hold on %Choosing the number of complexs based on the lower of t and r if t>=r c=r; else c=t; end %Checking variables and initalising to zeros blank=[0,0,0]; points={}; joinstatus=zeros(N,t+r); %Initalising points to zeros for j=1:N for k=1:t+r+(2*c) points{j,k}=blank; end for k=t+r+2:2:t+r+(2*c) points{j,k}=0; end end bouncepoints=points;
The coordinate generation and the main loop
The coordinates are now generated on the fly at every time step, this prevents the need to pass around large matrices. This is also the main loop at which every required function is called at each time step.
%The main for loop -> loops over all the time steps for j=1:N
Generation of the inital starting points, calls startpoint.
if j==1 [coords, startposition] = startpoint(); % c_joined=zeros(1,c); % c_split=zeros(1,c); check=zeros(c,3); else
Coordinate generation and confinement checking
The coordinates are checked against the height of the tube frist then checkxy is called to check whether it has left the cyclinder.
%Toehold for i=1:t if any(any(check==i))~=1 for k=1:3 coords(k+3,i)=coords(k,i); coords(k,i)=(p_t*randn(1))+coords(k+3,i); end % checking against the height of the tube. if coords(3,i)>=tube_height_max coords(3,i)=tube_height_max; elseif coords(3,i)<=tube_height_min coords(3,i)=tube_height_min; end %calling checkxy to check x and y [coords,bouncepoints]=checkxy(cylinder_radius, coords, i, bouncepoints); % end end %RNA for i=t+1:t+r if any(any(check==i))~=1 for k=1:3 coords(k+3,i)=coords(k,i); coords(k,i)=(p_r*randn(1))+coords(k+3,i); end % checking against the height of the tube. if coords(3,i)>=tube_height_max coords(3,i)=tube_height_max; end if coords(3,i)<=tube_height_min coords(3,i)=tube_height_min; end % %calling checkxy to check x and y [coords,bouncepoints]=checkxy(cylinder_radius, coords, i, bouncepoints); end end %Complex for i=t+r+1:t+r+c if check(i-(t+r),1)~=0 && check(i-(t+r),2)~=0 for k=1:3 coords(k+3,i)=coords(k,i); coords(k,i)=(p_c*randn(1))+coords(k+3,i); end % checking against the height of the tube. if coords(3,i)>=tube_height_max coords(3,i)=tube_height_max; end if coords(3,i)<=tube_height_min coords(3,i)=tube_height_min; end % %calling checkxy to check x and y [coords,bouncepoints]=checkxy(cylinder_radius, coords, i, bouncepoints); end end
end for q=1:c if check(q,3)==0 && check(q,1)==0 && check(q,2)==0 && j~=1 jointime=j; %variable to make sure joiner and splitter dont happen in same time step [coords,check, startposition, points] = joiner(coords,check, startposition, points); elseif check(q,3)~=0 check(q,3)=check(q,3)+1; end if check(q,1)~=0 && check(q,2)~=0 && j~=jointime [coords, check, startposition, points] = splitter(q, coords, check, startposition, points); end end
Bouncing
for f=1:t+r+c if f<t+r+1 if bouncepoints{j,f}==0 %not a bouncer matcoords=[coords(1,f),coords(2,f),coords(3,f)]; points{j,f}=matcoords; %couldn't have these statements on the same line for some reason elseif bouncepoints{j,f}~=0 if size(bouncepoints{j,f},2)==3 %couldn't have these statements on the same line for some reason matcoords=[coords(1,f),coords(2,f),coords(3,f) bouncepoints{j,f}(1,1),bouncepoints{j,f}(1,2),bouncepoints{j,f}(1,3)]; points{j,f}=matcoords; end end end if f>=(t+r+1) if f==(t+r+1) g=f; h=f+1; end if bouncepoints{j,g}==0 %not a bouncer matcoords=[coords(1,f),coords(2,f),coords(3,f)]; points{j,g}=matcoords; elseif bouncepoints{j,g}~=0 if size(bouncepoints{j,f},2)==3 matcoords=[coords(1,f),coords(2,f),coords(3,f) bouncepoints{j,g}(1,1),bouncepoints{j,g}(1,2),bouncepoints{j,g}(1,3)]; points{j,g}=matcoords; end end g=g+2; if j>1 if points{j-1,h}(1,1)~=0 if points{j,h}==0 points{j,h}=1; end end end h=g+1; end end if j==N plotter(points); counter(points); finish=1; end
end
Startpoint
Creates a start point definitely inside the dimensions of container, this is randomly generated. A vector called startpositon is made so the particles are located around this.
function [coords, startposition] = startpoint() coords=zeros(6,(t+r+c)); %each column is a toehold, with six rows, for current xyz and previous xyz % startposition=zeros(6,(t+r+c)); % coords=mat2dataset(coords); for m=1:t+r coords(3,m)=(tube_height_min)+((tube_height_max-tube_height_min)*rand(1)); coords(1,m)=(-cylinder_radius)+((cylinder_radius-(-cylinder_radius))*rand(1)); coords(2,m)=(-cylinder_radius)+((cylinder_radius-(-cylinder_radius))*rand(1)); end startposition=coords; end
Checking function
Checks the coordinates are within the boundaries of the eppendorf
%Function that checks whether the particle is inside of the tube %for its calculated z-coordinate at the point of contact in the %tube (in cone: via line equation intersects of path and boundary %// in cylinder: line equation of tube boundary). %From this point of contact, the new X and Y coordinates are %calculated for the "exit point" and then subsequently, the new %resultant xyz can be calculated function [coords,bouncepoints]=checkxy(radius,coords,i,bouncepoints) %Function that checks whether the particle is inside of the tube %for its calculated z-coordinate at the point of contact in the %tube (in cone: via line equation intersects of path and boundary %// in cylinder: line equation of tube boundary). %From this point of contact, the new X and Y coordinates are %calculated for the "exit point" and then subsequently, the new %resultant xyz can be calculated if (coords(1,i)^2)+(coords(2,i)^2)>=(radius^2) %red box in (Maths for exitx.png explains derivation) %setting exitX/Y at boundary of cylinder grad=abs((sqrt((coords(1,i)^2)+(coords(2,i)^2))-sqrt((coords(4,i)^2)+(coords(5,i)^2)))/(coords(3,i)-coords(6,i))); %confirmed to be correct if coords(1,i)<0 exitX=-sqrt((radius^2)/((grad^2)+1)); else exitX=sqrt((radius^2)/((grad^2)+1)); end if coords(2,i)<0 exitY=-(grad*sqrt(((radius^2)/((grad^2)+1)))); else exitY=grad*sqrt(((radius^2)/((grad^2)+1))); end Px=coords(1,i); Py=coords(2,i); lastx=coords(4,i); lasty=coords(5,i); trajectory_gradient=(Py-lasty)/(Px-lastx); %m1 tangent_gradient=(-exitX/exitY); %m2 theta_bounce=atan(trajectory_gradient); phi_2=atan(tangent_gradient); phi_1=theta_bounce-phi_2; exitPDist=sqrt(((Px-lastx)^2)+((Py-lasty)^2)); G_length=exitPDist*cos(phi_1); Gx=exitX+(G_length*cos(phi_1)); Gy=exitY+(G_length*cos(phi_1)); Cx=Px-Gx; Cy=Py-Gy; newX=Px-(2*Cx); newY=Py-(2*Cy); perpendicular_gradient=(exitY/exitX); % shifted_perpendicular_line=(perpendicular_gradient*EX)-((exitY+Px)/exitX)+Py; %z-intercept with boundary: (see book) prad=sqrt((coords(1,i)^2)+(coords(2,i)^2)); lastrad=sqrt((coords(4,i)^2)+(coords(5,i)^2)); Dr=prad-lastrad; pZ=coords(3,i); lastZ=coords(6,i); Dz=pZ-lastZ; Gr=radius-lastrad; Gz=Gr*tan(acos(Dr/sqrt((Dr^2)+(Dz^2)))); if pZ<lastZ exitZ=lastZ-Gz; else exitZ=lastZ+Gz; end %write new points directly into points in a way that joiner and %splitter can still work if i<=t+r bouncepoints{j,i}=[exitX exitY exitZ]; elseif i>t+r bouncepoints{j,(2*i)-1}=[exitX exitY exitZ]; end %update for next point coords(1,i)=newX; coords(2,i)=newY; coords(3,i)=coords(3,i); end end
Joining function
This function has a threshold for joining, a joining probability. If this is met the toehold and RNA's are joined. The check vector changes to indicate this, the toeholds and RNA's are spotted being made and a complex line is made instead. startingposition is also updated to indicate the new starting point of the complex line.
function [coords, check, startposition, points] = joiner(coords, check, startposition, points) colshift=0; %Joining probability calculated from in silico data of free energy of complex from NUPACK and %equation of polynomial fit to normalised curve gives probability %of binding (or rather gives the threshold to enable a successful %binding event which a randomly generated number is tested against) joinevent = (randi([1 10000000],1))/10000000; Tempcorrection = T-273; jointhreshold = ((4e-07)*(Tempcorrection^4)) - ((6e-05)*(Tempcorrection^3)) + (0.0023*(Tempcorrection^2)) - (0.0072*Tempcorrection) + 0.3745; if joinevent >= jointhreshold for n=1:t for m=t+1:r+t if any(any(check==n))==1 || any(any(check==m))==1 continue else % if ((((tx(j,k)-rx(j,m))^2)+((ty(j,k)-ry(j,m))^2)+((tz(j,k)-rz(j,m))^2))<=(A^2) || (check_r(1,m)~=0 && check_t(1,k)~=0)) && (j~=1) && delay(1,n)==0 if (((coords(1,n)-coords(1,m))^2)+((coords(2,n)-coords(2,m))^2)+((coords(3,n)-coords(3,m))^2))<=(A^2) for p=1:c if check(p,1)~=0 && check(p,2)~=0 continue else if check(p,1)==0 && check(p,2)==0 coords(1,t+r+p)=(coords(1,n)+coords(1,m))/2; coords(2,t+r+p)=(coords(2,n)+coords(2,m))/2; coords(3,t+r+p)=(coords(3,n)+coords(3,m))/2; startposition(1,t+r+p)=coords(1,t+r+p); startposition(2,t+r+p)=coords(2,t+r+p); startposition(3,t+r+p)=coords(3,t+r+p); check(p,1)=n; check(p,2)=m; if colshift==0; colshift=1; end points{j,t+r+p+colshift}=[1,n,m]; colshift=colshift+1; joinstatus(j,n)=1; joinstatus(j,m)=1; end break end end end end end end end end
Splitter function
Splitter is similar to joiner but the opposite happnens. If a threshold is reached the complex will split back into a toehold and RNA. These lines are now produced again, check is updated to reflect this and finally startposition is changed.
function [coords, check, startposition, points] = splitter(q, coords, check, startposition, points) splitevent = (randi([1 10000000],1))/10000000; Tempcorrection = T-273; splitthreshold = (-(4e-07)*(Tempcorrection^4)) + ((6e-05)*(Tempcorrection^3)) - (0.0023*(Tempcorrection^2)) + (0.0072*Tempcorrection) + 0.6255; %y=-4E-07x4 + 6E-05x3 - 0.0023x2 + 0.0072x + 0.6255 if splitevent<=splitthreshold if check(q,1)~=0 && check(q,2)~=0 toehold=check(q,1); rna=check(q,2); startposition(1,toehold)=coords(1,t+r+q); startposition(2,toehold)=coords(2,t+r+q); startposition(3,toehold)=coords(3,t+r+q); startposition(1,rna)=coords(1,t+r+q); startposition(2,rna)=coords(2,t+r+q); startposition(3,rna)=coords(3,t+r+q); coords(1,rna)=coords(1,t+r+q); coords(2,rna)=coords(2,t+r+q); coords(3,rna)=coords(3,t+r+q); coords(1,toehold)=coords(1,t+r+q); coords(2,toehold)=coords(2,t+r+q); coords(3,toehold)=coords(3,t+r+q); points{j,t+r+(2*q)}=[0,toehold,rna]; check(q,1)=0; check(q,2)=0; check(q,3)=-5; end end end
Plotting function
function [] = plotter(points) %Conditions from plotting drawn from points array for row=1:N if row==1 %startpoints for col=1:t+r plot3(points{row,col}(1,1), points{row,col}(1,2), points{row,col}(1,3),'kx') end else for altcol=t+r+2:2:t+r+(2*c) if points{row,altcol}(1,1)==1 && size(points{row,altcol},2)==3 && row>1 if points{row-1,altcol}(1,1)==0 %definitely joinpoint %plot blue using row-1 to row to joinpoint column, column selected from points{row,col}(1,2)) plot3([points{row-1,(points{row,altcol}(1,2))}(1,1), points{row,altcol-1}(1,1)], [points{row-1,(points{row,altcol}(1,2))}(1,2), points{row,altcol-1}(1,2)], [points{row-1,(points{row,altcol}(1,2))}(1,3), points{row,altcol-1}(1,3)], 'b') %plot red using row-1 to row to joinpoint column, column selected from points{row,col}(1,2) plot3([points{row-1,(points{row,altcol}(1,3))}(1,1), points{row,altcol-1}(1,1)], [points{row-1,(points{row,altcol}(1,3))}(1,2), points{row,altcol-1}(1,2)], [points{row-1,(points{row,altcol}(1,3))}(1,3), points{row,altcol-1}(1,3)], 'r') %plot circle at joinpoint plot3(points{row,altcol-1}(1,1), points{row,altcol-1}(1,2), points{row,altcol-1}(1,3), 'ko') end if points{row-1,altcol}(1,1)==1 %defintely splitpoint %do nothing end elseif (points{row,altcol}(1,1)==1 && size(points{row,altcol},2)==1) || (points{row,altcol}(1,1)==0 && size(points{row,altcol},2)==3) %plot green from row-1 to row if size(points{row-1,altcol-1},2)==3 plot3([points{row-1,altcol-1}(1,1), points{row, altcol-1}(1,1)], [points{row-1,altcol-1}(1,2), points{row, altcol-1}(1,2)], [points{row-1,altcol-1}(1,3), points{row, altcol-1}(1,3)],'g') elseif size(points{row,altcol-1},2)==6 %Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary bounceplot(points, row, altcol-1, 'g') end end if points{row,altcol}(1,1)==0 %currently split if size(points{row-1,altcol},2)==3 && points{row-1,altcol}(1,1)==0 %prevents incorrect plotting in the case of join/split in consecutive timesteps %plot from split column to blue column plot3([points{row-1,altcol-1}(1,1), points{row,(points{row-1,altcol}(1,2))}(1,1)],[points{row-1,altcol-1}(1,2), points{row,(points{row-1,altcol}(1,2))}(1,2)],[points{row-1,altcol-1}(1,3), points{row,(points{row-1,altcol}(1,2))}(1,3)],'b') %plot from split column to red column plot3([points{row-1,altcol-1}(1,1), points{row,(points{row-1,altcol}(1,3))}(1,1)],[points{row-1,altcol-1}(1,2), points{row,(points{row-1,altcol}(1,3))}(1,2)],[points{row-1,altcol-1}(1,3), points{row,(points{row-1,altcol}(1,3))}(1,3)],'r') %plot star at splitpoint plot3(points{row-1,altcol-1}(1,1), points{row-1,altcol-1}(1,2), points{row-1,altcol-1}(1,3), 'k*') %plot continue %might not be necessary end end for col=1:t+r if points{row,col}(1,1)~=points{row-1,col}(1,1) && points{row,col}(1,2)~=points{row-1,col}(1,2) && points{row,col}(1,3)~=points{row-1,col}(1,3) % have to be specific due to 1x6 object when bouncing occurs if size(points{row,altcol},2)~=3 %determine column in t or r for colour of line if col<=t %plot blue for toeholds if ((size(points{row-1,altcol},2)==3 && points{row-1,altcol}(1,1)==0) && points{row-1,altcol}(1,2)==col) %if just split, don't plot from row-1 to row in t column since plotting from split point has just occurred continue elseif points{row,altcol}==0 && size(points{row-1,altcol},2)~=3 if size(points{row-1,col},2)==3 plot3([points{row-1,col}(1,1), points{row,col}(1,1)], [points{row-1,col}(1,2), points{row,col}(1,2)], [points{row-1,col}(1,3), points{row,col}(1,3)],'b') elseif size(points{row,col},2)==6 %Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary bounceplot(points, row, col, 'b') end end end if col>t %plot red for rna(trigger) if ((size(points{row-1,altcol},2)==3 && points{row-1,altcol}(1,1)==0) && points{row-1,altcol}(1,3)==col) %if just split, don't plot from row-1 to row in r column since plotting from split point has just occurred continue elseif points{row,altcol}==0 && size(points{row-1,altcol},2)~=3 if size(points{row-1,col},2)==3 plot3([points{row-1,col}(1,1), points{row,col}(1,1)], [points{row-1,col}(1,2), points{row,col}(1,2)], [points{row-1,col}(1,3), points{row,col}(1,3)],'r') elseif size(points{row,col},2)==6 %Bouncing of the side points index for this is 6 numbers, the xyzpoint before hitting and the xyzpoint on the boundary bounceplot(points, row, col, 'r') end end end end end end end end end end
Bouncing function
function [points] = bounceplot(points, row, col, style) % coordinate structure is now: row-1 = [lastX lastY lastZ] % row = [newY exitZ newZ exitX newX exitY ] plot3([points{row-1,col}(1,1) points{row,col}(1,4)], [points{row-1,col}(1,2) points{row,col}(1,5)], [points{row-1,col}(1,3) points{row,col}(1,6)],style) plot3([points{row,col}(1,4) points{row,col}(1,1)], [points{row,col}(1,5) points{row,col}(1,2)], [points{row,col}(1,6) points{row,col}(1,3)],style) end
Counting function
This function is related to the generation of a GFP output of our system, it is used in combination with the parameter scanning aspect of our simulation.
function counter(points) %simplfied status of each toehold and trigger drawn from points array for jstatcol=1:t+r for jstatrow=2:N if points{jstatrow,jstatcol}(1)==points{jstatrow-1,jstatcol}(1) && points{jstatrow,jstatcol}(2)==points{jstatrow-1,jstatcol}(2) && points{jstatrow,jstatcol}(3)==points{jstatrow-1,jstatcol}(3) joinstatus(jstatrow,jstatcol)=1; % if joinstatus{jstatrow-1,jstatcol}==0 % joinstatus{jstatrow-1,jstatcol}=1; % end else if joinstatus(jstatrow,jstatcol)~=1 joinstatus(jstatrow,jstatcol)=0; end if points{jstatrow-1,jstatcol}==1 joinstatus(jstatrow,jstatcol)='split'; end end end end totalgreen=0; for col=1:t totalgreen=totalgreen+sum(joinstatus(:,col)); end totalgreentime=totalgreen*tau; GFPrate=1.2; GFPcount=totalgreentime*GFPrate; %GFPconc=GFPcount/eppendorfvolume; %GFPrate is calculated using E0040 Biobrick for GFP (720 base %pairs/240 AA) Ribosome speed @ 200AA/min -> 240/200 = 1.2 GFP/min end
Code needed to produce a .gif file of the simulation output
function jiff(row) change = 360/N; % the size of the angle change % gif utilities set(gcf,'color','w'); % set figure background to white drawnow; frame = getframe(gcf); im = frame2im(frame); [imind,cm] = rgb2ind(im,256); outfile = '17_07_v1.gif'; % adjusting the viewing the angle view(theta,45); theta = theta + change; % On the first loop, create the file. In subsequent loops, append. if row==2 imwrite(imind,cm,outfile,'gif','DelayTime',0,'loopcount',inf); else imwrite(imind,cm,outfile,'gif','DelayTime',0,'writemode','append'); end end
end
End Of The Code
This is the final simulation developed by the Univeristy Of Exeter iGEM team 2015. Developed mainly by Amy, Dan and Todd.