Code covered by the BSD License  

Highlights from
Generate Exhaustive Permutations

Be the first to rate this file! 9 Downloads (last 30 days) File Size: 5.29 KB File ID: #29383

Generate Exhaustive Permutations

by

 

12 Nov 2010 (Updated )

Illustrates generation of exhaustive permutation of symbols given the symbolic bases.

| Watch this File

File Information
Description

Generate Exhaustive Permutations
--------------------------------------------------
[1] main executing reference usage: usage_generateExhaustivePermutation

The objective is to illustrate generation of exhaustive permutation of symbols given the symbolic bases.
The method of generation is a kronecker-akin approach. The indexRepresentedPermutations may be mapped to any symbols provided.

Sample output:
Given bases = 'AB';
              lengthOf1PatternSeq = 3;

< symbols >
AAA
AAB
ABA
ABB
BAA
BAB
BBA
BBB

< indexRepresentedPermutations >
     1 1 1
     1 1 2
     1 2 1
     1 2 2
     2 1 1
     2 1 2
     2 2 1
     2 2 2

Given bases = '01';
              lengthOf1PatternSeq = 4;

< symbols >
 0000
 0001
 0010
 0011
 0100
 0101
 0110
 0111
 1000
 1001
 1010
 1011
 1100
 1101
 1110
 1111

< indexRepresentedPermutations >
     1 1 1 1
     1 1 1 2
     1 1 2 1
     1 1 2 2
     1 2 1 1
     1 2 1 2
     1 2 2 1
     1 2 2 2
     2 1 1 1
     2 1 1 2
     2 1 2 1
     2 1 2 2
     2 2 1 1
     2 2 1 2
     2 2 2 1
     2 2 2 2
--------------------------------------------------
[2] main executing reference usage: usage_computePermutationSeqForSpecificIndex
Obtain a sequence of permutation by direct computation, instead of extracting from a pre-generated exhaustive sequence of prescribed order.
This accelerate the process and saves memory space.

Sample output:

The sequence is CGGGCAG.
The sequence indexed extracted from exhaustive list is CGGGCAG from index: 4044.
==========================================
The sequence is CCCTATC.
The sequence indexed extracted from exhaustive list is CCCTATC from index: 101.
==========================================
The sequence is CCTGGAC.
The sequence indexed extracted from exhaustive list is CCTGGAC from index: 505.
==========================================
The sequence is CCGGATA.
The sequence indexed extracted from exhaustive list is CCGGATA from index: 999.
==========================================

* Caveat : Illustrative Purposes
- may run out of memory when lengthOf1PatternSeq >= 10;
- note as well that lengthOf1PatternSeq has to be >= length(bases)
- uncomment variables for display, eg. indexRepresentedPermutations

If the demo has more elegant presentation, please do not hesitate to suggest and send feedback to author.
Email: promethevx@yahoo.com.

Thank you.

Regards,
Michael Chan JT

Acknowledgements

This file inspired Motif Finding.

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
18 Jun 2011 Michael Chan

Hi Forrest,

For a length of 64, at usage_generateExhaustivePermutation.m

% Caveat: may run out of memory when >= 10;
% note as well that lengthOf1PatternSeq has to be >= length(bases)
lengthOf1PatternSeq = 64;

and

bases = 'ABCD';

Please note the caveat of memory issue, unless your machine has large memory capacity. However, you may wish to run by parts, ie. using another sample usage (computePermutationSeqForSpecificIndex.m), the usage is illustrated by: usage_computePermutationSeqForSpecificIndex.m

You may also convert it to C or java. It can be faster, however, in C, please note on the use of 'malloc' (memory allocation).

30 May 2011 Forrest

I have 4 letters... A,B,C,D. I need all possible combos of this, 64. Can you explain how I would install and run this code? I attempted to, and got an error below.

??? Input argument "bases" is undefined.

Error in ==> generateExhaustivePermutation at 9
numberOfUniqueBases = length(bases);"

Updates
03 Apr 2011

Added an option to derive a permutated sequence for a specific index for speed and memory conservation.

Contact us