Random DNA generator
Random DNA, RNA, coding DNA or protein sequences as FASTA, from a seed you can repeat.
Random DNA, RNA, coding DNA or protein sequences as FASTA, from a seed you can repeat.
Each position is drawn independently in the browser: for DNA, first a coin flip, weighted by the GC content you choose, decides whether the base is G or C versus A or T, then a second, even flip picks which of the pair to place. No sequence is stored or sent anywhere.
The flips come from a seeded generator rather than from the browser's own randomness, so a draw can be repeated. The seed sits under the result, and the same seed with the same settings always gives the same FASTA, in any browser. Press Generate again for a new seed and a fresh set.
The Coding DNA tab builds an open reading frame rather than a plain stretch of bases. The length is given in codons, and the sequence is put together in three parts:
Every internal codon is drawn base by base with the GC weighting above and redrawn if it comes out as a stop codon, so nothing interrupts the reading frame. The result therefore translates to a protein of n − 1 residues, starting with methionine, and any gene finder or translation tool will read it as a complete coding sequence. Stop codons in the other two frames are not touched, and they turn up as often as chance dictates, which is what a real gene looks like.
Which codons count as stops depends on the genetic code, so the code is yours to pick. The NCBI translation tables behind the seven options:
| Genetic code | NCBI table | Stop codons |
|---|---|---|
| Standard | 1 | TAA, TAG, TGA |
| Bacterial | 11 | TAA, TAG, TGA |
| Vertebrate mito | 2 | TAA, TAG, AGA, AGG |
| Yeast mito | 3 | TAA, TAG |
| Mold mito | 4 | TAA, TAG |
| Invertebrate mito | 5 | TAA, TAG |
| Ciliate nuclear | 6 | TGA |
Throwing stop codons away pulls the GC content up a little, because two of the three standard stops, TAA and TAG, are the AT-rich ones. At a 50% target a long standard-code sequence averages50.9% GC rather than 50.0%, and the header of each record reports what it actually came out at.
The Protein tab draws from the 20 standard amino acids, one residue at a time and independently, with no start or stop to worry about. Three compositions are offered:
DNA. "Try an example" sets the length to 150, GC content to 45%, the count to3 and the seed to 1. The result is 3 FASTA records of 150 bases, 450 nt in total, at44.2% GC overall. The individual records come out at 49.3%, 42.0% and 41.3%, so the headers read>random_1 length=150 gc=49.3% and so on: short sequences scatter around the target rather than hitting it.
Coding DNA. The example is 100 codons at 50% GC, 3 sequences, standard code, seed 1. Each record is 300 nt, begins ATG, ends in a stop codon and has none in between; the first isATG GCG GGC GTT … and finishes … ATC TGA. The three come out at 52.3%, 52.7% and 55.7% GC.
Protein. The example is 150 residues, 3 sequences, average composition, seed 1. Across the 450 residues leucine comes to 8.7% and tryptophan to 1.1%, against the 9.0% and 1.3% they are drawn at.
To reorder a real sequence instead of inventing one, use shuffle DNA; to draw from the composition of a sequence you already have, use sample DNA. To read a coding sequence back into protein, use DNA to RNA and check the composition with GC content.
Each residue is drawn from a seeded generator, the same mulberry32 arithmetic the shuffle and sample tools use. That is fine for test data, primers to try out a pipeline, or negative controls, but it is not cryptographically secure and should not be used to generate anything security-sensitive. The seed is shown with the result: the same seed and settings always rebuild the same sequences, and Generate again picks a new seed.
Each base is chosen independently: first a coin flip decides G/C versus A/T using your target percentage, then a second flip picks which of the pair. Over a long sequence the average lands close to the target, but any single short sequence will vary around it, the same way a fair coin flipped 20 times rarely lands exactly 10-10. The GC content each sequence actually came out at is printed in its FASTA header.
Yes, turn on Output as RNA in the DNA tab and every T is drawn as U instead, with the same GC targeting. Coding sequences are always written as DNA, because start and stop codons are defined on the DNA alphabet.
Every internal codon is drawn on its own and redrawn whenever it comes out as a stop codon of the genetic code you chose, so the finished sequence has ATG at the front, one stop codon at the back and none in frame in between. Stop codons in the other two reading frames are left alone, and they do occur, which is what a real open reading frame looks like.
A letter followed by its weight, separated by spaces or commas: A 8 L 9 G 7 means alanine, leucine and glycine only, in the proportions 8:9:7. The weights do not need to add up to 100, they are scaled for you, and any of the 20 amino acids you leave out is never drawn. If nothing in the box can be read as a composition the generator falls back to equal proportions and says so.
Length is capped at 100,000 bases or amino acids, coding sequences at 33,333 codons, and the sequence count at 100 per generation, which keeps the page responsive in the browser. GC content defaults to 50% and the count to 1 when you leave those boxes empty.