DNA Shuffle icon

DNA Shuffle

(v1.0.0)Docs

Shuffle DNA sequences while preserving nucleotide, dinucleotide, or k-mer composition.

Input

Output

Configure inputs to begin

Set options on the left, then click “Shuffle”.

How to shuffle a DNA sequence while keeping its composition?

Paste a DNA or RNA sequence, or upload a FASTA file with one or more records. Choose which composition every shuffle must keep, set how many shuffles you want per sequence, and select Shuffle. ProteinIQ returns the shuffled sequences as FASTA in the browser, ready to copy or download as a set of randomized control sequences.

With Shuffle method set to Mononucleotide, Random seed set to 42, and the other settings at their defaults, this promoter fragment:

Text
>promoter_fragment
TTGACAATTAATCATCGGCTCGTATAATGTGTGGAATTGTGAGCGGATAACAATTTCACACAGGA

returns a sequence with the same number of A, C, G, and T:

Text
>promoter_fragment_shuffled
AACATTTTAGAACTAATTTACTGCTAAGCTGCGTACGGCAAGTTGGTTTAGAAGTGACGAGACTA

To shuffle a sequence:

  1. Paste a raw sequence or FASTA records, or upload a FASTA, text, Word (.docx), or PDF file.
  2. Keep the default Dinucleotide method, the usual control for RNA folding and motif enrichment, or choose another Shuffle method.
  3. Set Number of shuffles to the number of control sequences you need per input, up to 100.
  4. Enter a Random seed if the run must be repeatable, or leave it at 0 to draw a new seed.
  5. Select Shuffle, then copy the preview or download the FASTA file.

No account or credits are required, and sequences never leave your browser.

Worked examples

Dinucleotide shuffle with several replicates

The page example keeps every dinucleotide count of the same promoter fragment and makes three replicates with seed 42:

Text
>promoter_fragment_shuffled_1
TTCATTGTTGTGATCAGAATATTAAATTGGCATATACTGTGGTCAGCGGATCGGACAACGACAAA
>promoter_fragment_shuffled_2
TACATGTGGGCATTTACGTTTGTCACAAATGATCAACGGAGAAATATGGTATCGATGCTTCAAGA
>promoter_fragment_shuffled_3
TGCTGACATATTTCAAATTGTCACATTCGATTGTCGAACGGGGTAACAAGGCATGTATGAGAATA

The summary above the preview reads 3 shuffled sequences from 1 input sequence, dinucleotide counts preserved, seed 42. Each replicate starts with T and ends with A, like the input. A rearrangement of the same bases that keeps every dinucleotide count always shares the first and last base.

RNA with a description line

RNA is shuffled with U kept as U. With K-mer at size 3, two shuffles, and seed 7:

Text
>hairpin_rna some description
GGGAAACUUCGGUUUCCC

returns:

Text
>hairpin_rna_shuffled_1 some description
GGGAAACUUUCGGUUCCC
>hairpin_rna_shuffled_2 some description
GGUUUCGGGAAACUUCCC

The suffix is added to the sequence ID, before the description, so every record keeps a unique ID for downstream tools.

Input reference

InputWhat happens
Raw sequenceTreated as one sequence named Sequence. Blocks separated by a blank line become Sequence_1, Sequence_2, and so on.
FASTA recordsEach record is shuffled separately and keeps its header.
RNAU is kept. DNA and RNA can be mixed in one file.
IUPAC codesN, R, Y, S, W, K, M, B, D, H, and V are shuffled like any other base, so their counts are kept too.
LowercaseAccepted. Output case follows Output case.
Database layoutSpaces, position numbers, and ORIGIN and // lines copied from a GenBank page are removed.
Alignment gaps- and . are removed before shuffling, with a notice.
Word and PDF filesText is extracted from .docx and .pdf uploads. Titles, captions, and page footers are skipped with a notice.
Text pasted from documentsInvisible characters, non-breaking spaces, and soft hyphens are removed.

Protein sequences, FASTQ files, and full GenBank records are rejected with a message that names the problem. Convert FASTQ with FASTQ to FASTA and GenBank records with GenBank to FASTA first.

Settings

Shuffle options

SettingDescription
Shuffle methodWhich composition every shuffle keeps. Mononucleotide keeps base counts. Dinucleotide (default) keeps the count of all 16 adjacent base pairs, and with them the base counts. K-mer keeps the count of every k-mer of the chosen size.
K-mer sizeLength of the k-mers to keep, from 2 to 6 (default 3). Only shown for the K-mer method. A size of 2 is the same as Dinucleotide.
Number of shufflesShuffled sequences generated per input sequence, from 1 to 100 (default 1).
Random seed0 (default) draws a new seed for each run. Any value from 1 to 999999 gives the same shuffles for the same input and settings. The seed used is shown in the summary and the run log.

Output formatting

SettingDescription
Output caseUppercase (default) or Lowercase.
Add suffix to headersAdds _shuffled, or _shuffled_1, _shuffled_2 for several shuffles, to each sequence ID. On by default. Turning it off with more than one shuffle gives repeated IDs.
Line lengthBases per FASTA line, from 0 to 200 (default 80). 0 puts each sequence on one line.

Results and downloads

The Preview tab shows the shuffled FASTA with a one-line summary of the number of sequences, the composition kept, and the seed. The Files tab has two downloads:

  • The shuffled FASTA, named after the uploaded file with _shuffled added, or shuffled.fasta for pasted input.
  • run.log, which records the method, seed, shuffles per sequence, each sequence's length, and any notices.

Notices appear above the result when records were skipped, gaps were removed, lines of different lengths were joined into one sequence, a sequence is mostly ambiguity codes, or a shuffle came back identical to its input.

Each record gets its own random stream from the seed. Adding shuffles keeps the earlier ones unchanged, and editing one record does not change the shuffles of the others.

Which shuffle method should I choose?

GoalMethod
Test whether base composition alone explains a resultMononucleotide
Control for RNA folding energy or base-stacking effectsDinucleotide
Control for CpG depletion or other neighbor-pair bias in motif searchesDinucleotide
Keep codon-sized or longer local patternsK-mer with size 3 or more

Higher orders keep more of the original sequence's local structure, so the controls are stricter. They also leave fewer possible arrangements. A short sequence shuffled at k-mer size 5 or 6 often has only one arrangement, and the tool then returns the input unchanged with a notice.

How DNA Shuffle works

Mononucleotide shuffling

Bases are permuted with the Fisher-Yates algorithm. Every ordering of the input bases is equally likely.

Dinucleotide and k-mer shuffling

Keeping k-mer counts means finding another walk through the same set of overlapping words. The sequence is turned into a graph whose vertices are its (k-1)-mers and whose edges are its k-mers. Every sequence with the same k-mer counts is an Eulerian path through this graph, a path that uses every edge exactly once, starting from the first (k-1)-mer and ending at the last.

A random Eulerian path is not automatically a fair sample: a greedy random walk favors some arrangements many times over others. DNA Shuffle uses the Altschul-Erickson algorithm in the form described by Kandel et al. and implemented in uShuffle. It first draws a uniformly random tree of "last exits" toward the final vertex with Wilson's algorithm, then permutes the remaining exits at each vertex before walking the graph. Every sequence with the same k-mer counts is produced with equal probability.

The random numbers come from xoshiro128**, a generator with a very long period, so long sequences and many replicates do not repeat or correlate.

Troubleshooting

Every shuffle is identical to the input

The sequence has few or no other arrangements with the same composition. This is common for sequences under about 30 bases at k-mer size 4 or more. Use a lower order or a longer sequence.

A record was skipped

The record had a header but no sequence lines. The notice lists the skipped names.

The tool says a record contains letters that are not bases

The record contains letters no DNA or RNA base code uses, such as E, F, I, L, P, or Q. It is either a protein sequence or text mixed into the sequence lines. DNA Shuffle only shuffles nucleotide sequences. To pull sequences out of a document with a lot of surrounding text, run it through TXT to FASTA first.

A line of my document was ignored

Lines that read as ordinary text, such as a table title or Page 1 of 1, are skipped, and the notice quotes them. A line is treated as text when it has a capitalized word with letters no base code uses. Sequence lines, including lowercase soft-masked bases, are never skipped.

My list of sequences came back as one sequence

Headerless lines are joined into one sequence, and a notice appears when their lengths suggest a list. Add a FASTA header above each sequence, or separate them with blank lines.

FAQ

What is a dinucleotide shuffle?

A dinucleotide shuffle rearranges a sequence so that the count of every adjacent base pair (AA, AC, CG, and so on) stays the same. It also keeps the base counts and the first and last base.

Why use shuffled sequences as controls?

Shuffled sequences with the same composition give a null distribution. If a motif score or folding energy for the real sequence is more extreme than for most shuffles, composition alone is unlikely to explain it.

How many shuffles do I need?

Enough for the statistic you compute. A z-score is often based on 100 or more shuffles, and an empirical p-value cannot be smaller than one over the number of shuffles plus one.

Is this the same as uShuffle?

It uses the same uniform k-let shuffling method as uShuffle. The outputs differ for the same seed because the random number generators differ.

Can I shuffle protein sequences?

No. DNA Shuffle accepts DNA and RNA only.

Shuffling versus mutation

DNA Shuffle rearranges an existing sequence while keeping selected composition. To keep most of a sequence unchanged and introduce a controlled number or rate of substitutions, insertions, or deletions, use the DNA mutation generator. To generate sequences from scratch with a chosen GC content, use Random DNA.

References

  • Altschul SF, Erickson BW. Significance of nucleotide sequence alignments: a method for random sequence permutation that preserves dinucleotide and codon usage. Molecular Biology and Evolution. 1985;2(6):526-538.
  • Kandel D, Matias Y, Unger R, Winkler P. Shuffling biological sequences. Discrete Applied Mathematics. 1996;71(1-3):171-185.
  • Jiang M, Anderson J, Gillespie J, Mayne M. uShuffle: a useful tool for shuffling biological sequences while preserving the k-let counts. BMC Bioinformatics. 2008;9:192.

Table of contents

Related tools

Codon optimization

Codon optimization

Optimize coding DNA for a target organism with DNA Chisel while preserving its translation.

DNA mutation generator

DNA mutation generator

Mutate DNA online by exact count or mutation rate, with reproducible controls and FASTA export.

DNAGenIQ (Random DNA sequence generator)

DNAGenIQ (Random DNA sequence generator)

Generate random DNA sequences with controlled length, GC content, and restriction sites.

Dimorphite-DL

Dimorphite-DL

Generate ligand protonation states over a pH range with Dimorphite-DL.

Overlapping peptide generator

Overlapping peptide generator

Design overlapping peptide libraries with adjustable length, overlap and terminal restrictions. Runs in your browser.

ProtGenIQ (Random protein sequence generator)

ProtGenIQ (Random protein sequence generator)

Generate random protein sequences with controlled length, amino acid composition, and motifs.

RNAGenIQ (Random RNA sequence generator)

RNAGenIQ (Random RNA sequence generator)

Generate random RNA test sequences with adjustable GC content and optional RNA-like templates and sequence motifs.

Stereoisomer generator

Stereoisomer generator

Enumerate stereoisomers from SMILES while preserving assigned stereochemistry by default.

Filter DNA

Filter DNA

Clean DNA sequences by removing or replacing non-standard nucleotides with IUPAC-aware filters.

GenBank Feature Extractor

GenBank Feature Extractor

Extract CDS, mRNA, gene, rRNA, and tRNA features from GenBank records into FASTA.