Main Content

randseq

Generate random sequence from finite alphabet

Syntax

Seq = randseq(SeqLength)
Seq = randseq(SeqLength, ...'Alphabet', AlphabetValue, ...)
Seq = randseq(SeqLength, ...'Weights', WeightsValue, ...)
Seq = randseq(SeqLength, ...'FromStructure', FromStructureValue, ...)
Seq = randseq(SeqLength, ...'Case', CaseValue, ...)
Seq = randseq(SeqLength, ...'DataType', DataTypeValue, ...)

Arguments

SeqLengthInteger that specifies the number of nucleotides or amino acids in the random sequence .
AlphabetValue

Character vector or string that specifies the alphabet for the sequence. Choices are 'dna'(default), 'rna', or 'amino'.

WeightsValue

Property to specify a weighted random sequence.

FromStructureValue

Property to specify a weighted random sequence using output structures from the functions from basecount, dimercount, codoncount, or aacount.

CaseValue

Character vector or string that specifies the case of letters in a sequence when Alphabet is 'char'. Choices are'upper' (default) or 'lower'.

DataTypeValue

Character vector or string that specifies the data type for a sequence. Choices are 'char'(default) for letter sequences, and 'uint8' or 'double' for numeric sequences.

Creates a sequence as an array of DataType.

Description

Seq = randseq(SeqLength) creates a random sequence with a length specified by SeqLength.

Seq = randseq(SeqLength, ...'PropertyName', PropertyValue, ...) calls randseq with optional properties that use property name/property value pairs. You can specify one or more properties in any order. Each PropertyName must be enclosed in single quotation marks and is case insensitive. These property name/property value pairs are as follows:

Seq = randseq(SeqLength, ...'Alphabet', AlphabetValue, ...) generates a sequence from a specific alphabet.

Seq = randseq(SeqLength, ...'Weights', WeightsValue, ...) creates a weighted random sequence where the ith letter of the sequence alphabet is selected with weight W(i). The weight vector is usually a probability vector or a frequency count vector. Note that the ith element of the nucleotide alphabet is given by int2nt(i), and the ith element of the amino acid alphabet is given by int2aa(i).

Seq = randseq(SeqLength, ...'FromStructure', FromStructureValue, ...) creates a weighted random sequence with weights given by the output structure from basecount, dimercount, codoncount, or aacount.

Seq = randseq(SeqLength, ...'Case', CaseValue, ...) specifies the case for a letter sequence.

Seq = randseq(SeqLength, ...'DataType', DataTypeValue, ...) specifies the data type for the sequence array.

Examples

Generate a random DNA sequence.

randseq(20)

ans =
TAGCTGGCCAAGCGAGCTTG

Generate a random RNA sequence.

randseq(20,'alphabet','rna')

ans = 
GCUGCGGCGGUUGUAUCCUG

Generate a random protein sequence.

randseq(20,'alphabet','amino')

ans =
DYKMCLYEFGMFGHFTGHKK

Version History

Introduced before R2006a