String Decomposition
Examine the relative frequencies of codons (groups of three consecutive nucleotides) in the list of nucleotides of a gene.
Get the DNA sequence of the human gene "SCNN1A".
In[1]:=
![Click for copyable input](assets.en/string-decomposition/In_9.png)
dnasequence = GenomeData["SCNN1A", "FullSequence"];
Use StringPartition to construct the corresponding list of codons.
In[2]:=
![Click for copyable input](assets.en/string-decomposition/In_10.png)
codons = StringPartition[dnasequence, 3];
In[3]:=
![Click for copyable input](assets.en/string-decomposition/In_11.png)
Take[codons, 10]
Out[3]=
![](assets.en/string-decomposition/O_8.png)
Compute the relative frequency of each codon in this gene.
In[4]:=
![Click for copyable input](assets.en/string-decomposition/In_12.png)
frequencies = N[Counts[codons]/Length[codons]];
There are 64 possible codons formed from the A, C, G, T nucleotides, and they all appear in the gene chosen.
In[5]:=
![Click for copyable input](assets.en/string-decomposition/In_13.png)
frequencies // Length
Out[5]=
![](assets.en/string-decomposition/O_9.png)
Find the three codons with the highest frequencies.
In[6]:=
![Click for copyable input](assets.en/string-decomposition/In_14.png)
TakeLargest[frequencies, 3]
Out[6]=
![](assets.en/string-decomposition/O_10.png)
Find the three codons with the lowest frequencies.
In[7]:=
![Click for copyable input](assets.en/string-decomposition/In_15.png)
TakeSmallest[frequencies, 3]
Out[7]=
![](assets.en/string-decomposition/O_11.png)
Visualize all relative frequencies in a Grid.
show complete Wolfram Language input
Out[8]=
![](assets.en/string-decomposition/O_12.png)