SequenceMatchManager
in package
implements
SequenceMatchInterface
uses
FormatsTrait
Class SequenceMatchManager - This class represents the results of performing sequence analysis and matching on two or more sequences.
Tags
Table of Contents
Interfaces
- SequenceMatchInterface
- Class SequenceMatchManager - This class represents the results of performing sequence analysis and matching on two or more sequences.
Properties
Methods
- compareLetter() : string
- Compares two letters $let1 and $let2 and returns another letter indicating if the two were exact matches, partial matches, or non-matches.
- getmin() : int
- Gets the minimum of three (usually numeric) values $x, $y, and $z.
- hamdist() : int
- Computes the Hamming Distance between two strings or Seq objects of equal length. For more information, consult the technical reference.
- intrim() : mixed
- Removes "internal spaces" (as opposed to leading and trailing spaces) from a string.
- left() : bool|string
- Returns the first $numchars characters of a string.
- levdist() : int
- Computes the Levenshtein Distance between two sequences with equal/unequal lengths. You can pass custom values for cost of insertion, replacement, and deletion. If you don't pass any, they are assumed to be 1.
- match() : string
- This method accepts two sequence strings (not objects) of equal length, and returns a sequence match result string, according to the following rules: If there is an exact match, return the amino acid symbol.
- partialMatch() : bool
- We abbreviate substitution matrix to "submatrix". Each element in a submatrix is an array of symbols that are considered "partial matches" of each other.
- rem_right() : bool|string
- Removes $charcount characters from the right (end) of a string.
- right() : bool|string
- Returns the substring beginning at $numchars characters from the right end of a string.
- setSubMatrix() : mixed
- trim_element() : mixed
- trim_element() removes leading and trailing spaces from a string. In conjunction with the array_walk() function, it removes spaces from each element of an array.
- xlevdist() : int
- Extended version of levdist() which accepts strings with length greater than 255 but not to exceed 1024 .
Properties
$subMatrix
private
SubMatrix
$subMatrix
= null
Methods
compareLetter()
Compares two letters $let1 and $let2 and returns another letter indicating if the two were exact matches, partial matches, or non-matches.
public
compareLetter(string $sLetter1, string $sLetter2[, array<string|int, mixed> $aMatrix = null ][, string $sEqual = null ][, string $sPartial = "+" ][, string $sNomatch = "." ]) : string
Parameters
- $sLetter1 : string
-
The first amino acid residue symbol to match.
- $sLetter2 : string
-
The second amino acid residue symbol to match.
- $aMatrix : array<string|int, mixed> = null
-
The substitution matrix to use in matching.
- $sEqual : string = null
-
The character symbol to return if $let1 and $let2 are exact matches.
- $sPartial : string = "+"
-
The character symbol to return if $let1 and $let2 are partial matches.
- $sNomatch : string = "."
-
The character symbol to return if $let1 and $let2 are totally mismatched.
Tags
Return values
string —A character symbol which indicates if the two residues are exact, partial, or negative matches.
getmin()
Gets the minimum of three (usually numeric) values $x, $y, and $z.
public
getmin(int $x, int $y, int $z) : int
For now, this can't handle situations when one or more arguments is FALSE.
Parameters
- $x : int
- $y : int
- $z : int
Return values
inthamdist()
Computes the Hamming Distance between two strings or Seq objects of equal length. For more information, consult the technical reference.
public
hamdist(string $sSequence1, string $sSequence2) : int
Parameters
- $sSequence1 : string
-
The first sequence
- $sSequence2 : string
-
The second sequence
Tags
Return values
int —The hamming distance between the two strings or sequences, defined to be the number of "mismatching" characters found in corresponding positions in the two strings.
intrim()
Removes "internal spaces" (as opposed to leading and trailing spaces) from a string.
public
intrim(string $string) : mixed
Parameters
- $string : string
left()
Returns the first $numchars characters of a string.
public
left(string $str, int $numchars) : bool|string
Parameters
- $str : string
- $numchars : int
Return values
bool|stringlevdist()
Computes the Levenshtein Distance between two sequences with equal/unequal lengths. You can pass custom values for cost of insertion, replacement, and deletion. If you don't pass any, they are assumed to be 1.
public
levdist(string $sSequence1, string $sSequence2[, int $iCostInser = 1 ][, int $iCostRepl = 1 ][, int $iCostDel = 1 ]) : int
For more information, see technical reference.
Parameters
- $sSequence1 : string
-
The first sequence, with a length not exceeding 255 symbols.
- $sSequence2 : string
-
The second string or sequence, with a length not exceeding 255 symbols.
- $iCostInser : int = 1
-
The cost or weight of an insertion operation.
- $iCostRepl : int = 1
-
The cost or weight of a replacement operation.
- $iCostDel : int = 1
-
The cost or weight of a deletion operation.
Tags
Return values
int —The Levenshtein Distance between two strings, defined to be the number of insertion, deletion, or replacement operations that must be performed on the strings before they can become identical.
match()
This method accepts two sequence strings (not objects) of equal length, and returns a sequence match result string, according to the following rules: If there is an exact match, return the amino acid symbol.
public
match(string $sSequence1, string $sSequence2[, array<string|int, mixed> $aMatrix = null ][, string $sEqual = null ][, string $sPartial = "+" ][, string $sNonmatch = "." ]) : string
If there is a partial match, return a plus sign. If there is no match, return a whitespace character.
Parameters
- $sSequence1 : string
-
The first of two sequences being compared.
- $sSequence2 : string
-
The second of two sequences being compared.
- $aMatrix : array<string|int, mixed> = null
-
An array specifying valid symbol substitution and equivalence rules.
- $sEqual : string = null
-
The symbol to output if the symbol in the first sequence is exactly the same as the corresponding symbol in the second sequence.
- $sPartial : string = "+"
-
The symbol to output if the symbol in the first sequence is equivalent but not identical to the corresponding symbol in the second sequence.
- $sNonmatch : string = "."
-
The symbol to output if the symbol in the first sequence is neither identical nor equivalent to the corresponding symbol in the second sequence.
Tags
Return values
string —A string which indicates where exact, partial and no matches occur between the first and second sequences being compared.
partialMatch()
We abbreviate substitution matrix to "submatrix". Each element in a submatrix is an array of symbols that are considered "partial matches" of each other.
public
partialMatch(string $sLet1, string $sLet2, array<string|int, mixed> $aMatrix) : bool
Default submatrix: ( ('G','A','V','L','I'), ('S','T'), ('N','Q'), ('F','Y','W'), ('C', 'M'), ('P'), ('D','E'), ('K','R','H'), ('*'), ('X') )
- Check if both $iLet1 and $let2 appear in the first element (G,A,V,L,I) of the substitution matrix.
- If they are, you've found a "hit", and $let1 and $let2 are partial matches. Return a TRUE value. If they are not, then go to the next element in the substitution matrix. Repeat steps 1 and 2 until you reach a submatrix element where both $let1 and $let2 appear, or until the last element in the submatrix has been checked.
- If you reach the last submatrix element without a "hit", return a FALSE value.
Parameters
- $sLet1 : string
-
The first amino acid residue.
- $sLet2 : string
-
The second amino acid residue.
- $aMatrix : array<string|int, mixed>
-
The substitution matrix to use for determining partial matches.
Return values
bool —TRUE if the two symbols belong to the same chemical group, FALSE otherwise.
rem_right()
Removes $charcount characters from the right (end) of a string.
public
rem_right(string $str[, int $charcount = 1 ]) : bool|string
Parameters
- $str : string
- $charcount : int = 1
Return values
bool|stringright()
Returns the substring beginning at $numchars characters from the right end of a string.
public
right(string $str, int $numchars) : bool|string
Parameters
- $str : string
- $numchars : int
Return values
bool|stringsetSubMatrix()
public
setSubMatrix(SubMatrix $subMatrix) : mixed
Parameters
- $subMatrix : SubMatrix
trim_element()
trim_element() removes leading and trailing spaces from a string. In conjunction with the array_walk() function, it removes spaces from each element of an array.
public
trim_element(mixed &$value, mixed $key) : mixed
Parameters
- $value : mixed
- $key : mixed
xlevdist()
Extended version of levdist() which accepts strings with length greater than 255 but not to exceed 1024 .
public
xlevdist(string $sSequence1, string $sSequence2) : int
The only drawback to xlevdist is that the cost of insertion, deletion, and replacement is fixed to 1. I have yet to find a way to allow custom values for these.
Parameters
- $sSequence1 : string
-
The first sequence, with a length not exceeding 1024 symbols.
- $sSequence2 : string
-
The second string or sequence, with a length not exceeding 1024 symbols.
Tags
Return values
int —The Levenshtein Distance between two strings, as defined in levdist().