SequenceAlignmentManager
in package
implements
SequenceAlignmentInterface
Represents the result of an alignment performed by various third-party software such as ClustalW. The alignment is usually found in a file that uses a particular format. Right now, my code supports only FASTA and CLUSTAL formats.
Properties and methods allow users to perform post-alignment operations, manipulations, etc.
Tags
Table of Contents
Interfaces
- SequenceAlignmentInterface
- Represents the result of an alignment performed by various third-party software such as ClustalW. The alignment is usually found in a file that uses a particular format. Right now, my code supports only FASTA and CLUSTAL formats.
Properties
- $aAlphabet : array<string|int, mixed>
- Letters of the alphabet
- $aSeqSet : ArrayIterator
- An array containing all the sequences in the alignment set.
- $bFlush : bool
- A boolean or logical value: TRUE if all the sequences in the alignment have the same length, FALSE otherwise.
- $iGapCount : int
- The total number of gaps ("-") in all sequences in the alignment set.
- $iLength : int
- The length of the longest sequence in the alignment set.
- $sequenceManager : SequenceBuilder
- Dependency injection for the Sequences Services
- $sFilename : string
- Filename of the original parsed file.
- $sFormat : string
- Format of the original parsed file.
Methods
- __construct() : mixed
- SequenceAlignmentManager constructor.
- addSequence() : int
- Adds a sequence to an alignment set. It does not perform any sequence alignment.
- charAtRes() : bool|string
- Returns the character found at a given residue number in a given sequence.
- colToRes() : bool|string
- Converts a column number to a residue number in a sequence that is part of an alignment set.
- consensus() : string
- Returns the consensus string for an alignment set. See technical reference for details.
- deleteSequence() : int
- Deletes or removes a sequence from an alignment set.
- getGapCount() : int
- Counts the number of gaps ("-") found in all sequences in an alignment set.
- getIsFlush() : bool
- Tests if all the sequences in an alignment set have the same length.
- getMaxiLength() : int
- Returns the length of the longest sequence in an alignment set.
- getSeqSet() : ArrayIterator
- The ArrayIterator of sequences ... then you can rewind(), next(), prev(), offsetGet(), count() on it
- parseClustal() : mixed
- Parses Clustal Files and create Sequence object
- parseFasta() : mixed
- Parses Fasta Files and create Sequence object
- parseFile() : mixed
- Main method - Parses FASTA or CLUSTAL file This "fetches" all sequences into the $aSeqSet property of the service.
- resToCol() : bool|int
- Converts a residue number to a column number in a sequence in an alignment set.
- resVar() : array<string|int, mixed>
- Determines the index position of both variant and invariant residues according to a given "percentage threshold" similar to that in the consensus() method.
- select() : mixed
- Creates a new alignment set from non-consecutive sequences found in another existing alignment set.
- setFilename() : mixed
- Sets a specific filename : the file to parse
- setFormat() : mixed
- Sets a specific format : FASTA or CLUSTAL
- sortAlpha() : mixed
- Rearranges the sequences in an alignment set alphabetically by their sequence id.
- subalign() : mixed
- Creates a new alignment set from a series of contiguous/consecutive sequences.
- substrBwRes() : string|bool
- Gets the substring between two residues in a sequence that is part of an alignment set.
- calcMaxPercent() : float|int
- Calculates the max percentage of frequencies
- longestLength() : int
- validationRes() : bool|int|string
- Fetches something found at a given residue number in a given sequence
Properties
$aAlphabet
Letters of the alphabet
private
array<string|int, mixed>
$aAlphabet
= null
$aSeqSet
An array containing all the sequences in the alignment set.
private
ArrayIterator
$aSeqSet
= null
As ArrayIterator I dropped the former next(), prev(), fetch(), last(), first() functions, easy pieceeeee <3
$bFlush
A boolean or logical value: TRUE if all the sequences in the alignment have the same length, FALSE otherwise.
private
bool
$bFlush
= null
$iGapCount
The total number of gaps ("-") in all sequences in the alignment set.
private
int
$iGapCount
= null
$iLength
The length of the longest sequence in the alignment set.
private
int
$iLength
= null
$sequenceManager
Dependency injection for the Sequences Services
private
SequenceBuilder
$sequenceManager
$sFilename
Filename of the original parsed file.
private
string
$sFilename
= null
$sFormat
Format of the original parsed file.
private
string
$sFormat
= null
Methods
__construct()
SequenceAlignmentManager constructor.
public
__construct(SequenceBuilder $sequenceManager) : mixed
Parameters
- $sequenceManager : SequenceBuilder
addSequence()
Adds a sequence to an alignment set. It does not perform any sequence alignment.
public
addSequence(Sequence $oSequence) : int
Parameters
- $oSequence : Sequence
-
The object to be added to the alignment set.
Tags
Return values
int —The number of sequences in the alignment set after the call.
charAtRes()
Returns the character found at a given residue number in a given sequence.
public
charAtRes(int $iSeqIdx, int $iRes) : bool|string
Parameters
- $iSeqIdx : int
-
Index of the sequence in the array
- $iRes : int
-
The residue number of the character we wish to get or extract
Tags
Return values
bool|string —A single character representing an amino acid residue or a "gap".
colToRes()
Converts a column number to a residue number in a sequence that is part of an alignment set.
public
colToRes(int $iSeqIdx, int $iCol) : bool|string
Parameters
- $iSeqIdx : int
-
Index number of the desired sequence within the alignment set.
- $iCol : int
-
The column number which we want to convert to a residue number.
Tags
Return values
bool|string —An integer representing the residue number corresponding to the given column number.
consensus()
Returns the consensus string for an alignment set. See technical reference for details.
public
consensus([int $iThreshold = 100 ]) : string
Parameters
- $iThreshold : int = 100
-
A number between 0 to 100, indicating the percentage threshold before (or below which) the unknown character "?" is used in a particular position or column in the consensus string. If omitted, this is set to 100 by default.
Tags
Return values
string —The consensus string formed according to the given threshold.
deleteSequence()
Deletes or removes a sequence from an alignment set.
public
deleteSequence(string $iSequenceId) : int
Parameters
- $iSequenceId : string
-
The id of the sequence to be deleted from the alignment set.
Tags
Return values
int —The number of sequences in the alignment set after the call.
getGapCount()
Counts the number of gaps ("-") found in all sequences in an alignment set.
public
getGapCount() : int
Tags
Return values
int —The number of "gap characters" in the all sequences in the alignment set.
getIsFlush()
Tests if all the sequences in an alignment set have the same length.
public
getIsFlush() : bool
Tags
Return values
boolgetMaxiLength()
Returns the length of the longest sequence in an alignment set.
public
getMaxiLength() : int
Tags
Return values
intgetSeqSet()
The ArrayIterator of sequences ... then you can rewind(), next(), prev(), offsetGet(), count() on it
public
getSeqSet() : ArrayIterator
Return values
ArrayIteratorparseClustal()
Parses Clustal Files and create Sequence object
public
parseClustal() : mixed
Tags
parseFasta()
Parses Fasta Files and create Sequence object
public
parseFasta() : mixed
Tags
parseFile()
Main method - Parses FASTA or CLUSTAL file This "fetches" all sequences into the $aSeqSet property of the service.
public
parseFile() : mixed
resToCol()
Converts a residue number to a column number in a sequence in an alignment set.
public
resToCol(int $iSeqIdx, int $iRes) : bool|int
Parameters
- $iSeqIdx : int
-
The index number of the desired sequence in the alignment set.
- $iRes : int
-
The residue number we wish to convert into a column number.
Tags
Return values
bool|int —An integer representing the column number corresponding to the given residue number.
resVar()
Determines the index position of both variant and invariant residues according to a given "percentage threshold" similar to that in the consensus() method.
public
resVar([int $iThreshold = 100 ]) : array<string|int, mixed>
Parameters
- $iThreshold : int = 100
-
a number between 0 to 100, indicating the percentage threshold below which the current index position is considered variant, and on or above which the current index position is considered invariant. If omitted, this is set to 100 by default.
Tags
Return values
array<string|int, mixed>select()
Creates a new alignment set from non-consecutive sequences found in another existing alignment set.
public
select() : mixed
Tags
setFilename()
Sets a specific filename : the file to parse
public
setFilename(string $sFilename) : mixed
Parameters
- $sFilename : string
setFormat()
Sets a specific format : FASTA or CLUSTAL
public
setFormat(string $sFormat) : mixed
Parameters
- $sFormat : string
sortAlpha()
Rearranges the sequences in an alignment set alphabetically by their sequence id.
public
sortAlpha([string $sOption = "ASC" ]) : mixed
In addition, you can specify if you wish it be in ascending or descending order via $sOption. The sOption accepts either "ASC" or "DESC" in whatever case (uppercase, lowercase, mixed case). This determines the sort order of the alignment set.
Parameters
- $sOption : string = "ASC"
-
ASCendant or DESCendant
Tags
subalign()
Creates a new alignment set from a series of contiguous/consecutive sequences.
public
subalign(int $iStart, int $iEnd) : mixed
Parameters
- $iStart : int
-
The index number of the first sequence to include in the new SeqAlign object.
- $iEnd : int
-
The index number of the last sequence to include in the new SeqAlign object.
Tags
substrBwRes()
Gets the substring between two residues in a sequence that is part of an alignment set.
public
substrBwRes(int $iSeqIdx, int $iResStart[, int $iResEnd = 0 ]) : string|bool
Parameters
- $iSeqIdx : int
-
Index of the sequence in the array
- $iResStart : int
-
Start of the subsequence
- $iResEnd : int = 0
-
End of the subsequence
Tags
Return values
string|bool —A substring within the specified sequence.
calcMaxPercent()
Calculates the max percentage of frequencies
private
calcMaxPercent(array<string|int, mixed> $aGlobFreq, int $i, array<string|int, mixed> &$aKeys) : float|int
Parameters
- $aGlobFreq : array<string|int, mixed>
-
Array of frequencies of the letters
- $i : int
-
Current iteration
- $aKeys : array<string|int, mixed>
-
Keys of the array of frequencies
Return values
float|intlongestLength()
private
longestLength() : int
Return values
int —The length of the longest sequence of the set, whose columns are all scanned
validationRes()
Fetches something found at a given residue number in a given sequence
private
validationRes(int $iSeqIdx, int $iRes, int &$iNonGapCount, int &$iLength, string $sContext) : bool|int|string
Parameters
- $iSeqIdx : int
-
The index number of the desired sequence in the alignment set.
- $iRes : int
-
The residue number we wish to convert.
- $iNonGapCount : int
-
Number of non-gap characters
- $iLength : int
-
Length of a sequence
- $sContext : string
-
The original function calling