Main Content

randseq

Generate random sequence from finite alphabet

Description

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

Seq = randseq(___,Name=Value) specifies options using one or more name-value arguments in addition to the input arguments in previous syntaxes. Each name-value argument is case insensitive.

example

Examples

collapse all

This example shows how to generate a random DNA sequence with SeqLength of 20.

randseq(20)
ans = 
'TTATGACGTTATTCTACTTT'

This example shows how to generate a random RNA sequence with SeqLength of 20.

randseq(20,'Alphabet','rna')
ans = 
'UUAUGACGUUAUUCUACUUU'

This example shows how to generate a random protein sequence with SeqLength of 20.

randseq(20,'Alphabet','amino')
ans = 
'TYNYMRQLVVDVVITNHYSV'

Input Arguments

collapse all

Number of nucleotides or amino acids in the random sequence, specified as an Integer.

Example: 20

Data Types: single | double

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: Alphabet='rna'

Sequence alphabet, specified as a character vector or string.

Example: Alphabet='rna'

Data Types: char | string

Weighted random sequence, specified as a vector. randseq 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

  • The ith element of the nucleotide alphabet is given by int2nt(i).

  • The ith element of the amino acid alphabet is given by int2aa(i).

Example: Weights='1*20'

Data Types: double | uint8

Weighted random sequence using output structures from the basecount, dimercount, codoncount, or aacount functions.

Example: FromStructure=count, where count is the output structure from the aacount function.

Letter case in sequence, specified as 'upper' or 'upper'. randseq uses this argument if DataType is 'char'.

Example: Case='lower'

Data Types: char | string

Data type for sequence array, specified as a char, uint8, or double.

Example: DataType='uint8'

Data Types: char | double | uint8

Output Arguments

collapse all

Random sequence, returned according to the value of DataType.

Version History

Introduced before R2006a