taskspaces.rna
Class SequenceGenerator

java.lang.Object
  |
  +--taskspaces.rna.SequenceGenerator
All Implemented Interfaces:
java.io.Serializable

public class SequenceGenerator
extends java.lang.Object
implements java.io.Serializable

Contains methods to generate random RNA sequence Strings from a sequence, generate structures from sequences, generate a given number of random RNA sequences of a given length, and create random base pairs.

Version:
1.00
Author:
Rob Markel
See Also:
Serialized Form

Constructor Summary
SequenceGenerator()
           
 
Method Summary
private static java.util.List embed(java.lang.String[] modules, java.lang.String spacer)
          Embeds modules into a background sequence at specified points.
static java.util.List embedCompositionModules(java.lang.String[] modules, int sequenceLength)
          Generates a random sequence with embedded modules, based on the composition of the modules.
static java.util.List embedModules(java.lang.String[] modules, int sequenceLength)
          Generates a random sequence with embedded modules in random but ascending positions.
static java.util.List embedModules(java.lang.String[] modules, int sequenceLength, float[] composition)
          Generates a sequence with the base composition of the passed composition percentage values and with embedded database modules in random but ascending positions.
static java.util.List embedModules(java.lang.String[] modules, int sequenceLength, java.lang.String baseSequence)
          Generates a sequence with the base composition of the passed base sequence with embedded database modules in random but ascending positions.
static char getCompositionBase(float[] f)
          Returns a base with the given composition.
static char[] getCompositionPair(java.lang.String baseSequence)
          Returns a base pair using the composition of the passed sequence.
static java.lang.String getCompositionSequence(java.lang.String baseSequence, int length)
          Returns a random piece of the input String or a lengthened randomized String of the input length.
private static int[] getInsertionPoints(int moduleNum, int spacerLength)
          Generates an integer array of sorted points for inserting modules into sequences.
static char getPairingBase(char c)
          Returns the pair of the passed base.
static java.lang.String getPartitionSequence(int[] composition)
          Returns a randomized sequence with the given base composition.
static char getRandomBase(long seed)
          Returns a random base.
static java.lang.String[] getRandomizedSequences(java.lang.String seq, int num)
          Generates the input number of random sequences using the input String.
static char[] getRandomPair(boolean b)
          Returns a random base pair.
static java.lang.String getRandomSequence(int sequenceLength, long seed)
          Generates a random sequence using the MersenneTwisterFast class.
static java.lang.String[] getRandomSequences(int num, int sequenceLength, long seed)
          Generates an input number of random sequences using the MersenneTwisterFast class.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

SequenceGenerator

public SequenceGenerator()
Method Detail

getRandomizedSequences

public static java.lang.String[] getRandomizedSequences(java.lang.String seq,
                                                        int num)
                                                 throws java.lang.Exception
Generates the input number of random sequences using the input String. It is randomized using the shuffleString() method of the Shuffle class.
Parameters:
sequence - the sequence to randomize.
num - number of sequences to return.
Returns:
the randomized sequences.

getCompositionSequence

public static java.lang.String getCompositionSequence(java.lang.String baseSequence,
                                                      int length)
                                               throws java.lang.Exception
Returns a random piece of the input String or a lengthened randomized String of the input length. The character composition is maintained.
Parameters:
input - sequence for input.
Returns:
the shuffled sequence, either a piece or shuffled concatenation of the input sequence up to the given length.

getCompositionPair

public static char[] getCompositionPair(java.lang.String baseSequence)
Returns a base pair using the composition of the passed sequence.
Parameters:
baseSequence - a sequence.
Returns:
randomly selected base pair from the passed sequence.

getPairingBase

public static char getPairingBase(char c)
Returns the pair of the passed base.
Parameters:
c - an RNA base.
Returns:
the pairing RNA base.

getRandomSequences

public static java.lang.String[] getRandomSequences(int num,
                                                    int sequenceLength,
                                                    long seed)
Generates an input number of random sequences using the MersenneTwisterFast class.
Parameters:
num - number of sequences to generate.
sequenceLength - desired length of generated sequences.
seed - a random seed.
Returns:
the generated random sequences.

getRandomSequence

public static java.lang.String getRandomSequence(int sequenceLength,
                                                 long seed)
Generates a random sequence using the MersenneTwisterFast class.
Parameters:
sequenceLength - desired length of generated sequence.
seed - a random seed.
Returns:
the generated random sequences.

getRandomBase

public static char getRandomBase(long seed)
Returns a random base.
Parameters:
seed - a random seed.
Returns:
the random base.

getCompositionBase

public static char getCompositionBase(float[] f)
Returns a base with the given composition.
Parameters:
composition - base composition percentages.
Returns:
the selected base.

getRandomPair

public static char[] getRandomPair(boolean b)
Returns a random base pair.
Parameters:
b - if true include GU and UG as valid pairs.
Returns:
a base pair.

getPartitionSequence

public static java.lang.String getPartitionSequence(int[] composition)
Returns a randomized sequence with the given base composition.
Parameters:
composition - base composition percentage values.
Returns:
the randomized sequence String.

embedModules

public static java.util.List embedModules(java.lang.String[] modules,
                                          int sequenceLength,
                                          float[] composition)
                                   throws java.lang.Exception
Generates a sequence with the base composition of the passed composition percentage values and with embedded database modules in random but ascending positions.
Parameters:
modules - sequence modules.
sequenceLength - the desired sequence length.
composition - the desired base composition of the spacer.
Returns:
the generated String.

embedModules

public static java.util.List embedModules(java.lang.String[] modules,
                                          int sequenceLength,
                                          java.lang.String baseSequence)
                                   throws java.lang.Exception
Generates a sequence with the base composition of the passed base sequence with embedded database modules in random but ascending positions.
Parameters:
modules - sequence modules.
sequenceLength - the desired sequence length.
Returns:
the generated String.

embedModules

public static java.util.List embedModules(java.lang.String[] modules,
                                          int sequenceLength)
                                   throws java.lang.Exception
Generates a random sequence with embedded modules in random but ascending positions.
Parameters:
modules - module sequences.
sequenceLength - the desired sequence length.
Returns:
the generated String.

embedCompositionModules

public static java.util.List embedCompositionModules(java.lang.String[] modules,
                                                     int sequenceLength)
                                              throws java.lang.Exception
Generates a random sequence with embedded modules, based on the composition of the modules. NOTE: This method only works with sequence lengths which are multiples of 20.
Parameters:
modules - sequence modules.
Returns:
the generated String.

getInsertionPoints

private static int[] getInsertionPoints(int moduleNum,
                                        int spacerLength)
Generates an integer array of sorted points for inserting modules into sequences.
Parameters:
moduleNum - the number of modules.
Returns:
the random but ascending values.

embed

private static java.util.List embed(java.lang.String[] modules,
                                    java.lang.String spacer)
Embeds modules into a background sequence at specified points.
Parameters:
modules - the sequence modules.
sequence - the background sequence.
Returns:
List containing generated sequence and insertion points.

-bottom