How To Generate Randomized Sequence Based On Sequence Already Known?
6
1
Entering edit mode
11.6 years ago

For example. I have a DNA sequence and I want to generate a randomized sequence with same DNA composition? Which program can I use to do it?

• 9.6k views
ADD COMMENT
0
Entering edit mode

I encourage you to also consider broadening your search beyond this thread because a web search will turn up a lot of related pages. I'm certain you will find a variety of helpful approaches to this question on this site alone because I recall answering similar questions in the past.

ADD REPLY
0
Entering edit mode

By "DNA composition", do you just mean single-base frequency?

ADD REPLY
6
Entering edit mode
11.6 years ago

You should also consider keeping the dinucleotide composition by applying the Altschul-Erikson algorithm ("Significance of nucleotide sequence alignments: A method for random sequence permutation that preserves dinucleotide and codon usage", S.F. Altschul and B.W. Erikson, Mol. Biol. Evol., 2(6):526--538, 1985).

P. Clote already implemented it in Python for the community:

http://bioinformatics.bc.edu/clotelab/RNAdinucleotideShuffle/dinucleotideShuffle.html

ADD COMMENT
3
Entering edit mode
11.6 years ago

There are countless ways to do this using pretty much any programming language.

From the perlfaq4: How do I shuffle an array randomly:

For example, if you either have Perl 5.8.0 or later installed, or if you have Scalar-List-Utils 1.03 or later installed, you can do the following from the command line (as a perl one liner):

perl -e 'use List::Util 'shuffle'; 
@original_dna = split(//, "ATATTCATGAGTACCGTA"); 
@random_dna = shuffle(@original_dna); 
print "\nOriginal: ", @original_dna, "\nRandom:   ", @random_dna, "\n\n";'
ADD COMMENT
3
Entering edit mode
11.6 years ago

Based on answers from stackoverflow: shuffle string in python:

python -c "import random; 
dna=list('ATATTCATGAGTACCGTA'); 
print 'Original:',''.join(dna); 
random.shuffle(dna); 
print 'Random:  ',''.join(dna);"
ADD COMMENT
2
Entering edit mode
11.6 years ago
Neilfws 49k

You can use shuffleseq from the EMBOSS suite. Here's the documentation. Here's a web interface.

ADD COMMENT
2
Entering edit mode
11.6 years ago
ff.cc.cc ★ 1.3k

R version:

dna      = unlist(strsplit("acctg", split=""))
rand_dna = [sample(1:length(dna))]
ADD COMMENT

Login before adding your answer.

Traffic: 2016 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6