Simplifying Macromolecules

Macromolecules can contain thousands of base pairs (groups of atoms such as amino acids), but their huge size actually simplifies them in some ways.

In particular, we can often ignore the details of short-range interactions as we look at the overall structure:

(Click in the cell of equations below and shift-enter to execute it.)

possibleSteps=Permutations[{1,0,0}]~Join~Permutations[{-1,0,0}];
steps3[n_]:=RandomChoice[possibleSteps,n] 
n3=10000;
walk3[n_]:=Join[{{0,0,0}},Transpose[Accumulate/@Transpose@steps3[n]]]
w3=walk3[n3];
range3=Max@Abs@Flatten@w3;
Manipulate[
Graphics3D[Line@w3[[1;;Nw3]],PlotRange->Table[{-range3,range3},{3}],Axes->None,Boxed->False,ImageSize->Full],
{{Nw3,n3},1,n3,1},
Button["New Molecule",w3=walk3[n3];range=Max@Abs@Flatten@w3],
ContentSize->{700,700}
]

Click-drag the above image to rotate it. Hold down the key Option (Mac) or Alt (Windows) and click-drag the above image to zoom in or out.

The molecular representation above is an example of a random walk, in which the particle moves along a lattice one step at a time in a randomly chosen direction, tracing out the bonds and base-pair positions of the molecule.

This is an extremely simple model of a molecule, but it has many features in common with actual molecules.

One-Dimensional Random Walk

A particle moves along a line, each step taken is randomly either +1 or -1 with equal probability.

In the graph below, the N axis represents the number of steps taken.

n1=10000;
steps[n_]:=RandomChoice[{-1,1},n]    
walk1[n_]:= Transpose@{{0}~Join~Accumulate[steps[n]],Table[x,{x,0,n}]}
w1=walk1[n1];
range=Max@Abs@First@Transpose@w1;
Manipulate[
ListPlot[w1[[1;;Nw]],Joined->True,AxesLabel->{"x","Nw"},PlotRange->{{-range,range},{0,n1}}],
{Nw,1,n1,1},
Button["New Walk",w1=walk1[n1];range=Max@Abs@First@Transpose@w1]
]

RandomChoice[{-1,1},40]     (* RandomChoice[{-1,1},n] generates a list of n values chosen from the list {-1,1} *)

steps[n_]:=RandomChoice[{-1,1},n]    (* n = the number of steps taken *)

s=steps[20]

Accumulate@s    (* = Accumulate[s] ; Calculates successive totals, i.e. the position after each step *)

{0}~Join~Accumulate@s  (* = Join[{0}, Accumulate[s] ] ; Adds the initial position *)

Table[x,{x,0,20}]   (* The corresponding number of steps (the "time") *)

{{0}~Join~Accumulate@s,Table[x,{x,0,20}]}   (* 2 x n array *)//MatrixForm     (* = MatrixForm[ ] *)

Transpose@{{0}~Join~Accumulate@s,Table[x,{x,0,20}]}   (* n x 2 array *)//MatrixForm

walk[n_]:= Transpose@{{0}~Join~Accumulate[steps[n]],Table[x,{x,0,n}]}

w=walk[20]

ListPlot[w]

ListPlot[w,Joined->True]

range=Max@Abs@First@Transpose@w

ListPlot[w,Joined->True,AxesLabel->{"x","Nw"},PlotRange->{{-range,range},{0,20}}]

w                         (* An array of values *)
w[[1]]              (* The first element *)
w[[10]]            (* The 10th element *)
w[[-1]]            (* The last element *)
w[[5,2]]         (* The second element of the fifth element *)
w[[1;;3]]     (* The first through third elements *)

Manipulate[
ListPlot[w[[1;;Nw]],Joined->True,AxesLabel->{"x","Nw"},PlotRange->{{-range,range},{0,20}}],
{Nw,1,20,1}
]

Manipulate[
ListPlot[w[[1;;Nw]],Joined->True,AxesLabel->{"x","Nw"},PlotRange->{{-range,range},{0,20}}],
{Nw,1,20,1},
Button["New Walk",w=walk1[n];range=Max@Abs@First@Transpose@w]
]

Random Walk Statistics

If we look at where a random walk ends up, it can be quite far from the beginning point:

w[[-1]]

w[[-1,1]]

Table[walk[20][[-1,1]],{100}]

But if we average over a large number of walks, i.e. if we calculate the mean position after N steps (Subscript[x, i])= ±1 :

	⟨R⟩= ⟨ (∑_(i=1)^N) (Subscript[x, i]) ⟩

we'll get something like the following:

Table[walk[20][[-1,1]],{10000}]//Mean//N    (* N[x] forces a decimal evaluation rather than leaving values as exact fractions *)

If you think about it, it shouldn't be surprising that the mean final position ⟨R⟩ is zero!

How about the "excursion" from the mean position |(∑_(i=1)^N)(Subscript[x, i])-⟨R⟩| , i.e. the absolute distance rather than position? We could average the absolute value:

	⟨ |(∑_(i=1)^N)(Subscript[x, i])-⟨R⟩| ⟩

but usually physicists look at the mean square distance instead (or sometimes the root mean square distance):

	⟨ (R^2) ⟩= ⟨ ((((Underoverscript[ ∑, (i=1), N]) (Subscript[x, i])-⟨R⟩ ))^2) ⟩ =  ⟨ ((((Underoverscript[ ∑, (i=1), N]) (Subscript[x, i])))^2) ⟩

Manipulate[
Table[((walk[n][[-1,1]])^2),{10000}]//Mean//N,
{n,1,1000,1,Appearance->"Open"} ]

Note that if you change the number of steps with the slider above, the mean square distance has very close to the same value, i.e. in the limit of large numbers of walks:

	⟨ (R^2) ⟩= N