Documentation

SequenceInterface

We use this class to manipulate Sequence() elements, most of the time taken from a database instance.

Tags
author

Amélie DUVERNET aka Amelaye amelieonline@gmail.com

Table of Contents

Methods

charge()  : string
Translates an amino acid sequence into its equivalent "charge sequence".
chemicalGroup()  : string
Returns a string of symbols from an 8-letter alphabet: A, L, M, R, C, H, I, S.
complement()  : string
Returns a string representing the genetic complement of a sequence.
countCodons()  : int
Counts the number of codons (a trio of nucleotide base-pairs) in the CDS feature of a parsed record.
expandNa()  : string
Returns the expansion of a nucleic acid sequence, replacing special wildcard symbols with the proper regular expression.
findMirror()  : array<string|int, mixed>|bool
Returns a three-dimensional associative array listing all mirror substrings contained within a given sequence, and their location (expressed as a zero-based index number).
findPalindrome()  : bool|array<string|int, mixed>
Returns a two-dimensional array containing palindromic substrings found in a sequence, and their location, in terms of zero-based indices. E.g. ( ("ATGttCAT", 2), ("ATGccccccCAT", 18), ... ) CASES: 1) seqlen is not set, pallen is not set. - return FALSE (function error) 2) seqlen is set, pallen is set.
findPattern()  : array<string|int, mixed>
Returns a one-dimensional array enumerating each occurrence or instance of a given pattern in a larger string or sequence. This returns the actual substring (that matches the pattern) itself.
getBridge()  : string
Returns the sequence located between two palindromic halves of a palindromic string.
getCodon()  : string
Returns the n-th codon in a sequence, with numbering starting at 0.
getSequence()  : Sequence
halfSequence()  : string
Returns one of the two palindromic "halves" of a palindromic string.
isMirror()  : bool
Returns TRUE if the given sequence or string is a "genetic mirror" which is the same as a "string palindrome", i.e., a sequence that "looks" the same when read backwards.
isPalindrome()  : bool
Tests if a given sequence is a "genetic palindrome" (as opposed to a "string palindrome"). A "genetic palindrome" is one where the ends of a sequence are reverse complements of each other.
molwt()  : float
Computes the molecular weight of a particular sequence.
patFreq()  : array<string|int, mixed>
Returns a one-dimensional associative array where each key is a substring matching the given pattern, and each value is the frequency count of the substring within the larger string.
patPos()  : array<string|int, mixed>
Returns a two-dimensional associative array where each key is a substring matching a given pattern, and each value is an array of positional indexes which indicate the location of each occurrence of the substring (needle) in the larger string (haystack). This DOES NOT allow for pattern overlaps.
patPoso()  : array<string|int, mixed>
Similar to patPos() except that this allows for overlapping patterns.
setSequence()  : mixed
Injection Sequence
subSeq()  : string
Creates a new sequence object with a sequence that is a substring of another.
symFreq()  : int
Returns the frequency of a given symbol in the sequence property string. Note that you can pass this a symbol argument which may be not be part of the sequence's alphabet.
translate()  : string
Translates a particular DNA sequence into its protein product sequence, using the given substitution matrix.
translateCodon()  : string
Translates a single codon into an amino acid.

Methods

charge()

Translates an amino acid sequence into its equivalent "charge sequence".

public charge(string $sAminoSeq) : string

Function charge() accepts a string of amino acids in single-letter format and outputs a string of charges in single-letter format also. A for acidic, C for basic, and N for neutral.

Parameters
$sAminoSeq : string

A string representing an amino acid sequence (e.g. GAVLIFYWKRH). If omitted, this is set to the sequence property of the "calling" Seq object. If the latter is not set either, the function returns the boolean value of FALSE.

Tags
throws
Exception
Return values
string —

A string where each amino acid "letter" is replaced by A (if amino acid is acidic), C (if amino acid is basic), or N (if amino acid is neutral), e.g. ACNNCCNANCCNA.

chemicalGroup()

Returns a string of symbols from an 8-letter alphabet: A, L, M, R, C, H, I, S.

public chemicalGroup(string $sAminoSeq) : string

Chemical groups: L - GAVLI, H - ST, M - NQ, R - FYW, S - CM, I - P, A - DE, C - KRH, * - *, X - X

Parameters
$sAminoSeq : string

A string representing an amino acid chain (e.g. GAVLI). If omitted, this is set to the sequence property of the "calling" Seq object. If the latter is not set either, the function returns the boolean value of FALSE.

Tags
throws
Exception
Return values
string —

A string where each amino acid "letter" is replaced by one of the following: A (acidic group), L (aliphatic group), M (amide group), R (aromatic group), C (basic group), H (hydroxyl), I (iminio group), S (sulfur group).

complement()

Returns a string representing the genetic complement of a sequence.

public complement(string $sMoltypeUnfrmtd[, string $sSequence = null ]) : string
Parameters
$sMoltypeUnfrmtd : string

The type of molecule we are dealing with. If omitted, we work with "DNA" by default.

$sSequence : string = null
Tags
throws
Exception
Return values
string —

A string which is the genetic complement of the input string.

countCodons()

Counts the number of codons (a trio of nucleotide base-pairs) in the CDS feature of a parsed record.

public countCodons(array<string|int, mixed> $aFeatures) : int
Parameters
$aFeatures : array<string|int, mixed>

The record's Feature objects, as returned by a database parser's getFeatures() (e.g. ParseGenbankManager::getFeatures()).

Tags
throws
Exception

When $aFeatures holds no "CDS" feature.

Return values
int —

The number of complete codons within the CDS, expressed as a non-negative integer.

expandNa()

Returns the expansion of a nucleic acid sequence, replacing special wildcard symbols with the proper regular expression.

public expandNa([string $sSequence = null ]) : string
Parameters
$sSequence : string = null

The sequence

Tags
throws
Exception
Return values
string —

An "expanded" string where special metacharacters are replaced by the appropriate regular expression. For example, an N or X is replaced by the dot (.) meta-character, an R is replaced by [AG], etc.

findMirror()

Returns a three-dimensional associative array listing all mirror substrings contained within a given sequence, and their location (expressed as a zero-based index number).

public findMirror([string $sSequence = null ][, int $iPallen1 = null ][, int $iPallen2 = null ][, string $sOptions = "E" ]) : array<string|int, mixed>|bool
Parameters
$sSequence : string = null

The sequence which will be searched by the method for any occurrences of mirrors. If omitted, this is set to the sequence property of the current Seq object.

$iPallen1 : int = null

The length of the shortest mirror to look for.

$iPallen2 : int = null

The length of the longest mirror to look for.

$sOptions : string = "E"

May be "E" or "O" or "A". If "E" is passed, then the method only looks for mirrors with even lengths. If "O" is passed, the method only looks for mirrors with odd lengths. If "A" is passed, then method looks for all mirrors (odd and even lengths). If omitted, this is set to "E" by default.

Return values
array<string|int, mixed>|bool —

3D assoc array: ( [2] => ( ("AA", 3), ("GG", 7) ), [4] => ( ("GAAG", 16) ) )

findPalindrome()

Returns a two-dimensional array containing palindromic substrings found in a sequence, and their location, in terms of zero-based indices. E.g. ( ("ATGttCAT", 2), ("ATGccccccCAT", 18), ... ) CASES: 1) seqlen is not set, pallen is not set. - return FALSE (function error) 2) seqlen is set, pallen is set.

public findPalindrome(string $sSequence[, int $iSeqLen = 0 ][, int $iPalLen = 0 ]) : bool|array<string|int, mixed>
  1. seqlen is set, pallen is not set.
  2. seqlen is not set, pallen is set.
Parameters
$sSequence : string

The sequence to be searched by the method for any genetic palindromes. If omitted, this is set to the sequence property of the current Seq object.

$iSeqLen : int = 0

The length of the palindromic substring within $sSequence. If omitted, the method searches for palindromes of whatever length.

$iPalLen : int = 0

The length of one of two palindromic edges in a palindromic substring within $haystack.

Tags
throws
Exception
Return values
bool|array<string|int, mixed> —

A two-dimensional array of the form: ((palindrome1, position1), (palindrome2, position2), ...)

findPattern()

Returns a one-dimensional array enumerating each occurrence or instance of a given pattern in a larger string or sequence. This returns the actual substring (that matches the pattern) itself.

public findPattern(string $sPattern[, string $sSequence = null ][, string $sOptions = "I" ]) : array<string|int, mixed>
Parameters
$sPattern : string

The pattern to search for

$sSequence : string = null

The sequence

$sOptions : string = "I"

If set to "I", pattern-matching will be case-insensitive. Passing anything else would cause the pattern-matching to be case-sensitive.

Tags
example

Findpattern returns: ( "GCG", "GCG", "GCG" ) if pattern is exactly "GCG".

throws
Exception
Return values
array<string|int, mixed> —

A one-dimensional array

getBridge()

Returns the sequence located between two palindromic halves of a palindromic string.

public getBridge(string $string) : string

Take note that the "bridge" as I call it, is not necessarily a genetic mirror or a palindrome.

Parameters
$string : string

A palindromic or mirror sequence containing the bridge.

Return values
string

getCodon()

Returns the n-th codon in a sequence, with numbering starting at 0.

public getCodon(int $iIndex[, string $sSequence = null ][, int $iReadFrame = 0 ]) : string
Parameters
$iIndex : int

The index number of the codon.

$sSequence : string = null

The sequence

$iReadFrame : int = 0

The reading frame, which may be 0, 1, or 2 only. If omitted, this is set to 0 by default.

Return values
string —

The n-th codon in the sequence.

halfSequence()

Returns one of the two palindromic "halves" of a palindromic string.

public halfSequence(int $iIndex[, string $sSequence = null ]) : string
Parameters
$iIndex : int

Pass 0 to get he first palindromic half, pass any other number (e.g. 1) to get the second palindromic half.

$sSequence : string = null

The sequence

Tags
throws
Exception
Return values
string —

A string representing either the first or the second palindromic half of the string.

isMirror()

Returns TRUE if the given sequence or string is a "genetic mirror" which is the same as a "string palindrome", i.e., a sequence that "looks" the same when read backwards.

public isMirror([string $sSequence = null ]) : bool

Definition of terms: MIRROR: The equivalent of a string palindrome in programming terms. Comes in two varieties -- ODD-LENGTH and EVEN-LENGTH. The strict biological definition of mirrors are EVEN-LENGTH only. MIRROR SEQUENCE: seq1-[X]-seq2, where X is an optional nucleotide base (A, G, C, or T). Seq1 and Seq2 are called the complementary sequences or halves. For our purposes, we shall call [X] as the "bridge".

Parameters
$sSequence : string = null

A sequence which we want to test if it is a mirror or not.

Return values
bool

isPalindrome()

Tests if a given sequence is a "genetic palindrome" (as opposed to a "string palindrome"). A "genetic palindrome" is one where the ends of a sequence are reverse complements of each other.

public isPalindrome([string $sSequence = null ]) : bool

For mirror repeats, we allow strings with both ODD and EVEN lengths.

Parameters
$sSequence : string = null

A sequence which we want to test if it is a genetic palindrome or not.

Return values
bool —

TRUE if the given string is a genetic palindrome, FALSE otherwise.

molwt()

Computes the molecular weight of a particular sequence.

public molwt([string $sLimit = "upperlimit" ][, string $sSequence = null ][, string $sMolType = null ][, int $iNALen = null ]) : float

The reference is Biopython's Bio.SeqUtils.molecular_weight (average masses, single strand, linear) : on canonical bases the result equals it, and the tests pin values it computed. The weight is that of a neutral single strand carrying a 5' phosphate and a 3' hydroxyl, as a fragment cut by an enzyme does : the sum of its nucleoside monophosphates (dAMP 331.2218) less one water (18.0153) per phosphodiester bond, that is the sum of the nucleotide residues the database holds (dA 313.2065) plus one water. A synthetic oligonucleotide, which has a 5' hydroxyl, weighs 79.98 (HPO3) less.

Parameters
$sLimit : string = "upperlimit"

Upper or Lowerlimit

$sSequence : string = null

The sequence

$sMolType : string = null

DNA or RNA

$iNALen : int = null

Length of the sequence

Tags
throws
Exception
Return values
float —

The molecular weight, upper or lower limit

patFreq()

Returns a one-dimensional associative array where each key is a substring matching the given pattern, and each value is the frequency count of the substring within the larger string.

public patFreq(string $sPattern, string $sSequence[, string $sOptions = "I" ]) : array<string|int, mixed>

Return value example: ( "GAATTC" => 3, "ATAT" => 4, ... )

Parameters
$sPattern : string

The pattern to search for and tally.

$sSequence : string

Sequence

$sOptions : string = "I"

If set to "I", pattern-matching and tallying will be case-insensitive. Passing anything else would cause it to be case-sensitive.

Tags
throws
Exception
Return values
array<string|int, mixed> —

The function returns an array of the form: ( substring1 => frequency1, substring2 => frequency2, ... )

patPos()

Returns a two-dimensional associative array where each key is a substring matching a given pattern, and each value is an array of positional indexes which indicate the location of each occurrence of the substring (needle) in the larger string (haystack). This DOES NOT allow for pattern overlaps.

public patPos(string $sPattern[, string $sOptions = "I" ][, string $sSequence = null ]) : array<string|int, mixed>
Parameters
$sPattern : string

The pattern to locate

$sOptions : string = "I"

If set to "I", pattern-matching will be case-insensitive.

$sSequence : string = null

The sequence

Tags
throws
Exception
Return values
array<string|int, mixed> —

Value example: ( "PAT1" => (0, 17), "PAT2" => (8, 29) )

patPoso()

Similar to patPos() except that this allows for overlapping patterns.

public patPoso(string $sPattern[, string $sOptions = "I" ][, int $iCutPos = 1 ][, string $sSequence = null ]) : array<string|int, mixed>

Return value format: (index1, index2, ... ) Return value sample: ( 0, 8, 17, 29)

Parameters
$sPattern : string

The pattern to locate

$sOptions : string = "I"

If set to "I", pattern-matching will be case-insensitive. Passing anything else would cause it to be case-sensitive.

$iCutPos : int = 1

A non-negative integer specifying where search for the next pattern will resume, relative to the current matching substring.

$sSequence : string = null

The sequence to analyze

Tags
throws
Exception
Return values
array<string|int, mixed> —

One-dimensional array of the form: ( position1, position2, position3, ... ) where position is a zero-based index indicating the location of the substring within the larger sequence. Thus, if substring is found at the very beginning of sequence, its position is equal to zero (0).

subSeq()

Creates a new sequence object with a sequence that is a substring of another.

public subSeq(int $iStart, int $iCount[, string $sSequence = null ]) : string
Parameters
$iStart : int

The position in the original sequence from which we will begin extracting the subsequence; the position is expressed as a zero-based index.

$iCount : int

The number of "letters" to include in the subsequence, starting from the position specified by the $start parameter.

$sSequence : string = null

The sequence

Tags
throws
Exception
Return values
string —

String sequence.

symFreq()

Returns the frequency of a given symbol in the sequence property string. Note that you can pass this a symbol argument which may be not be part of the sequence's alphabet.

public symFreq(string $sSymbol[, string $sSequence = null ]) : int

In this case, the method will simply return zero (0) value.

Parameters
$sSymbol : string

The symbol whose frequency in a sequence we wish to determine.

$sSequence : string = null

The sequence

Tags
throws
Exception
Return values
int —

The frequency (number of occurrences) of a particular symbol in a sequence string.

translate()

Translates a particular DNA sequence into its protein product sequence, using the given substitution matrix.

public translate([string $sSequence = null ][, int $iReadFrame = 0 ][, int $iFormat = 1 ]) : string
Parameters
$sSequence : string = null

The sequence

$iReadFrame : int = 0

The reading frame (0, 1, or 2) to be used in translating a nucleic sequence into a protein. A value of 0 means that the first codon would start at the first "letter" in the sequence, a value of 1 means that the second codon would start the second "letter" in the sequence, and so on. When omitted, this argument is set to reading frame 0 by default.

$iFormat : int = 1

This may be passed the value 1 or 3 and determines the format of the output string. Passing 1 would cause translate() to output a string made up of single-letter amino acid symbols strung together without any space in between. Passing 3 would output a string made up of three-letter amino acid symbols separated by a space.

Tags
example

When $format is passed a value of 1, the function returns a string of this format: GAVLISNFYW where each of G, A, V, and the other letters represent a single amino acid residue.

When $format is passed a value of 3, the function returns a string of this format: Phe Leu Ser Tyr Cys STP where each of Phe, Leu, and the other 3-letter "words" represent a single amino acid residue.

throws
Exception
Return values
string

translateCodon()

Translates a single codon into an amino acid.

public translateCodon(string $sCodon[, int $iFormat = 3 ]) : string
Parameters
$sCodon : string

A three-letter nucleic acid sequence (each letter can be A, U, G, or C) which translates into a single amino acid residue.

$iFormat : int = 3

This may be passed the value 1 or 3 and determines the format of the output string. When omitted, $format is set to 3 by default.

Tags
throws
Exception
Return values
string —

When $format is passed a value of 1, the function returns a single letter. When $format is passed a value of 3, the function returns a string of three letters. The return value represents a single amino acid residue.

On this page

Search results