Function Repository Resource:

BuildBioSequenceBondListFromFoldingMatrix

Source Notebook

Construct all potential bond lists from a folding matrix associated with a biomolecular sequence

Contributed by: John Cassel, Wolfram|Alpha Scientific Content

ResourceFunction["BuildBioSequenceBondListFromFoldingMatrix"][mat]

produce bond lists satisfying a potential bonding from a matrix of allowed connections mat.

Details and Options

By default, up to one thousand bond lists are returned. The MaxItems option overrides the maximum number of bond lists that can be returned by this function, with either All or Infinity imposing no limit.

Examples

Basic Examples (1) 

Generate all bond lists from a folding matrix within a given bond neighborhood:

In[1]:=
ResourceFunction["BuildBioSequenceBondListFromFoldingMatrix"][\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"0", "1", "0", "0", "0", "0", "0", "0", "1"},
{"1", "0", "0", "0", "0", "0", "0", "1", "0"},
{"0", "0", "0", "0", "0", "1", "1", "0", "0"},
{"0", "0", "0", "0", "0", "1", "1", "0", "0"},
{"0", "0", "0", "0", "0", "1", "1", "0", "0"},
{"0", "0", "1", "1", "1", "0", "0", "0", "0"},
{"0", "0", "1", "1", "1", "0", "0", "0", "0"},
{"0", "1", "0", "0", "0", "0", "0", "0", "1"},
{"1", "0", "0", "0", "0", "0", "0", "1", "0"}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {
Offset[
          0.27999999999999997`], {
Offset[0.7]}, 
Offset[0.27999999999999997`]}, "Rows" -> {
Offset[0.2], {
Offset[0.4]}, 
Offset[0.2]}}], "", ")"}],
Function[BoxForm`e$, 
MatrixForm[BoxForm`e$]]]\)]
Out[1]=

Scope (1) 

Decrease the constraint on the minimum distance sequences positions must be to be bonded:

In[2]:=
ResourceFunction["BuildBioSequenceBondListFromFoldingMatrix"][\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"0", "1", "0", "0", "0", "0", "0", "0", "1"},
{"1", "0", "0", "0", "0", "0", "0", "1", "0"},
{"0", "0", "0", "0", "0", "1", "1", "0", "0"},
{"0", "0", "0", "0", "0", "1", "1", "0", "0"},
{"0", "0", "0", "0", "0", "1", "1", "0", "0"},
{"0", "0", "1", "1", "1", "0", "0", "0", "0"},
{"0", "0", "1", "1", "1", "0", "0", "0", "0"},
{"0", "1", "0", "0", "0", "0", "0", "0", "1"},
{"1", "0", "0", "0", "0", "0", "0", "1", "0"}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {
Offset[
          0.27999999999999997`], {
Offset[0.7]}, 
Offset[0.27999999999999997`]}, "Rows" -> {
Offset[0.2], {
Offset[0.4]}, 
Offset[0.2]}}], "", ")"}],
Function[BoxForm`e$, 
MatrixForm[BoxForm`e$]]]\), 2]
Out[2]=

Options (2) 

MaxItems (2) 

For a larger matrix, the number of bond lists can grow to be quite large, so they are generally capped at one thousand:

In[3]:=
biggerMatrix = SparseArray[
  Automatic, {60, 60}, 0, {1, {{0, 16, 32, 48, 78, 94, 124, 154, 170, 186, 216, 246, 262, 292, 322, 338, 354, 384, 400, 416, 446, 462, 492, 508, 524, 540, 556, 572, 602, 632, 662, 692, 722, 752, 782, 798, 814, 844, 874, 904, 920, 936, 966, 982, 998, 1028, 1058, 1074, 1104, 1134, 1164,
      1194, 1210, 1240, 1270, 1300, 1316, 1332, 1362, 1378, 1408}, CompressedData["
1:eJxTTMoPSmJiYGBoYGVgYATSLGzsXNy8Coqqalq6eobGVnyCImIysnLySuoG
RqZm5jbo8ozMHJw8fAKCwiJi4tJghcrqmjoGRiZAxdY26Lrxq8Yvi24zaS4h
zWz8qplYWMHq+YVEJSSlFBRVVNU0tLR19fQNjS0sCYYYPXXjV00orgnxSXMb
7WQpiXnKQoh2NlM331Ezr5CWxigJA9LyLO3SF6F8QE13AgAJ/q7b "]}, CompressedData["
1:eJxTTMoPSmJkYGBoYGVgYBwFo2AUjIJRMCAAAC+pB60=
"]}];
Length[ResourceFunction["BuildBioSequenceBondListFromFoldingMatrix"][
  biggerMatrix]] (* takes ~15 seconds to compute *)
Out[3]=

The maximum number of items can be set to another count with the MaxItems option:

In[4]:=
ResourceFunction[
 "BuildBioSequenceBondListFromFoldingMatrix"][biggerMatrix, MaxItems -> 5]
Out[4]=

It is also possible to turn off any constraint on the maximum number of bond lists with either Infinity or All:

In[5]:=
ResourceFunction["BuildBioSequenceBondListFromFoldingMatrix"][\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"0", "1", "0", "0", "0", "0", "0", "0", "1"},
{"1", "0", "0", "0", "0", "0", "0", "1", "0"},
{"0", "0", "0", "0", "0", "1", "1", "0", "0"},
{"0", "0", "0", "0", "0", "1", "1", "0", "0"},
{"0", "0", "0", "0", "0", "1", "1", "0", "0"},
{"0", "0", "1", "1", "1", "0", "0", "0", "0"},
{"0", "0", "1", "1", "1", "0", "0", "0", "0"},
{"0", "1", "0", "0", "0", "0", "0", "0", "1"},
{"1", "0", "0", "0", "0", "0", "0", "1", "0"}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {
Offset[
          0.27999999999999997`], {
Offset[0.7]}, 
Offset[0.27999999999999997`]}, "Rows" -> {
Offset[0.2], {
Offset[0.4]}, 
Offset[0.2]}}], "", ")"}],
Function[BoxForm`e$, 
MatrixForm[BoxForm`e$]]]\), "MaxItems" -> Infinity]
Out[5]=

Properties and Relations (2) 

Folding matrices for this function can be obtained from the resource function BioSequenceFoldingMatrix:

In[6]:=
ResourceFunction["BioSequenceFoldingMatrix"][
 BioSequence["DNA", "CGTTTAACG", {}]]
Out[6]=
In[7]:=
ResourceFunction["BuildBioSequenceBondListFromFoldingMatrix"][%]
Out[7]=

The bond sequences built by this function can be added to the original sequence with BioSequenceModify:

In[8]:=
BioSequenceModify[BioSequence["DNA", "CGTTTAACG", {}],
 {"AddBond", {Bond[{1, 9}], Bond[{2, 8}], Bond[{3, 7}]}}
 ]
Out[8]=

Neat Examples (1) 

Add each of the generated bond sequences to the sequence they came from and plot them all with BioSequencePlot:

In[9]:=
seq = BioSequence["RNA", "CGAUGCGAGUGG", {}];
GraphicsGrid[
 Partition[
  BioSequencePlot /@ (BioSequenceModify[seq, {"AddBond", #}] & /@ ResourceFunction["BuildBioSequenceBondListFromFoldingMatrix"][
      ResourceFunction[
        "https://www.wolframcloud.com/obj/jcassel/DeployedResources/Function/BioSequenceFoldingMatrix"][seq]]), UpTo[5]]]
Out[9]=

Version History

  • 1.0.0 – 06 December 2021

Related Resources

License Information