Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4272226
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:32:57+00:00 2026-05-21T07:32:57+00:00

I need to generate a random walk based on the DNA sequence of a

  • 0

I need to generate a random walk based on the DNA sequence of a virus, given its base pair sequence of 2k base pairs. The sequence looks like “ATGCGTCGTAACGT”. The path should turn right for an A, left for a T, go upwards for a G and downwards for a C.
How can I use either Matlab, Mathematica or SPSS for this purpose?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:32:57+00:00Added an answer on May 21, 2026 at 7:32 am

    I did not previously know of Mark McClure’s blog about Chaos Game representation of gene sequences, but it reminded me of an article by Jose Manuel Gutiérrez (The Mathematica Journal Vol 9 Issue 2), which also gives a chaos game algorithm for an IFS using (the four bases of) DNA sequences. A detailed description may be found here (the original article).

    The method may be used to produce plots such as the following. Just for the hell of it, I’ve included (in the RHS panels) the plots generated with the corresponding complementary DNA strand (cDNA).

    • Mouse Mitochondrial DNA (LHS) and its
      complementary strand (cDNA) (RHS).

    enter image description here

    These plots were generated from GenBank Identifier gi|342520. The sequence contains 16295 bases.

    (One of the examples used by Jose Manuel Gutiérrez. If anyone is interested, plots for the human equivalent may be generated from gi|1262342).

    • Human Beta Globin Region (LHS) and its cDNA (RHS)

    enter image description here

    Generated from gi|455025| (the example
    used my Mark McClure). The sequence contains 73308 bases

    There are pretty interesting plots! The (sometimes) fractal nature of such plots is known, but the symmetry obvious in the LHS vs RHS (cDNA) versions was very surprising (at least to me).

    The nice thing is that such plots for any DNA sequence may be very easily generated by directly importing the sequence (from, say, Genbank), and then using the power of Mma.
    All you need it the accession number! (‘Unknown’ nucleotides such as “R” may need to be zapped) (I am using Mma v7).

    The Original Implimenation (slightly modified) (by Jose Manuel Gutiérrez)

    Important Update

    On the advise of Mark McClure, I have changed Point/@Orbit[s, Union[s]] to Point@Orbit[s, Union[s]].

    This speeds things up very considerably. See Mark’s comment below.

    Orbit[s_List, {a_, b_, c_, d_}] := 
      OrbitMap[s /. {a -> {0, 0}, b -> {0, 1}, c -> {1, 0}, 
         d -> {1, 1}}];
    OrbitMap = 
      Compile[{{m, _Real, 2}}, FoldList[(#1 + #2)/2 &, {0, 0}, m]];
    IFSPlot[s_List] := 
     Show[Graphics[{Hue[{2/3, 1, 1, .5}], AbsolutePointSize[2.5], 
        Point @ Orbit[s, Union[s]]}], AspectRatio -> Automatic, 
      PlotRange -> {{0, 1}, {0, 1}}, 
      GridLines -> {Range[0, 1, 1/2^3], Range[0, 1, 1/2^3]}]
    

    This gives a blue plot. For green, change Hue[] to Hue[{1/3,1,1,.5}]

    The following code now generates the first plot (for mouse mitochondrial DNA)

     IFSPlot[Flatten@
          Characters@
           Rest@Import[
             "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=\
        nucleotide&id=342520&rettype=fasta&retmode=text", "Data"]]
    

    To get a cDNA plot I used the follow transformation rules (and also changed the Hue setting)

    IFSPlot[    ....   "Data"] /. {"A" -> "T", "T" -> "A", "G" -> "C", 
       "C" -> "G"}]
    

    Thanks to Sjoerd C. de Vries and telefunkenvf14 for help in directly importing sequences from the NCBI site.

    Splitting things up a bit, for the sake of clarity.

    Import a Sequence

    mouseMitoFasta=Import["http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nucleotide&id=342520&rettype=fasta&retmode=text","Data"];
    

    The method given for importing sequences in the original Mathematica J. article is dated.

    A nice check

    First@mouseMitoFasta

    Output:

    {>gi|342520|gb|J01420.1|MUSMTCG Mouse mitochondrion, complete genome}
    

    Generation of the list of bases

    mouseMitoBases=Flatten@Characters@Rest@mouseMitoFasta
    

    Some more checks

    {Length@mouseMitoBases, Union@mouseMitoBases,Tally@mouseMitoBases}
    

    Output:

    {16295,{A,C,G,T},{{G,2011},{T,4680},{A,5628},{C,3976}}}
    

    The second set of plots was generated in a similar manner from gi|455025. Note that the sequence is long!

    {73308,{A,C,G,T},{{G,14785},{A,22068},{T,22309},{C,14146}}}
    

    One final example (containing 265922 bp), also showing fascinating ‘fractal’ symmetry. (These were generated with AbsolutePointSize[1] in IFSPlot).

    The first line of the fasta file:

    {>gi|328530803|gb|AFBL01000008.1| Actinomyces sp. oral taxon 170 str. F0386 A_spOraltaxon170F0386-1.0_Cont9.1, whole genome shotgun sequence}

    enter image description here

    The corresponding cDNA plot is again shown in blue on RHS

    Finally, Mark’s method also gives very beautiful plots (for example with gi|328530803), and may be downloaded as a notebook.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Like my question, i need to generate random numbers that have identical pairs between
I need to generate random text strings of a particular format. Would like some
I need to generate a series of N random binary variables with a given
Here is a fun one: I need to generate random x/y pairs that are
I need to generate a (pseudo) random sequence of N bit integers, where successive
I need to generate random BigDecimal value from given range. How to do it
I need to generate random tokens so that when I see them later I
I need to generate a random integer between 1 and n (where n is
I need to generate multiple random values under SQL Server 2005 and somehow this
I need to generate a random port number between 2000-65000 from a shell script.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.