Egglib 2.1.11
C++ library reference manual
|
Handles a set of sequence alignment (aligned or not) More...
#include <Container.hpp>
Public Member Functions | |
Container () | |
Creates an empty object. More... | |
Container (const Container &source) | |
Copy constructor. More... | |
Container & | operator= (const Container &source) |
Assignment operator. More... | |
Container (unsigned int number_of_sequences, char const *const *const cstring_array) | |
Creates an object from a data matrix. More... | |
virtual | ~Container () |
Destructor. More... | |
virtual void | clear () |
Clears all content of the object. More... | |
virtual unsigned int | append (const char *name, const char *sequence, unsigned int group=0) |
Adds a sequence to the object. More... | |
virtual unsigned int | remove (unsigned int pos) |
Removes a sequence from the object. More... | |
virtual void | name (unsigned int pos, const char *name) |
Changes the name of a given sequence. More... | |
virtual void | sequence (unsigned int pos, const char *sequence) |
Changes the sequence string of a given sequence. More... | |
virtual void | appendSequence (unsigned int pos, const char *sequence) |
Appends a string to the a given sequence. More... | |
virtual void | set (unsigned int sequence, unsigned position, char ch) |
Changes a character. More... | |
virtual char | get (unsigned int s, unsigned int p) const |
Gets a given character. More... | |
virtual void | group (unsigned int pos, unsigned int group) |
Changes the group index of a given sequence. More... | |
Container | hslice (unsigned int a, unsigned int b) const |
Extracts a range of sequences. More... | |
unsigned int | ns () const |
Gets the number of sequences. More... | |
virtual unsigned int | ls (unsigned int pos) const |
Gets the length of a given sequence. More... | |
virtual const char * | name (unsigned int pos) const |
Gets the name of the a given sequence. More... | |
virtual const char * | sequence (unsigned int pos) const |
Gets the name of a given sequence. More... | |
virtual unsigned int | group (unsigned int pos) const |
Gets the group index of a given sequence. More... | |
bool | isEqual () const |
Checks if all lengths are equal. More... | |
unsigned int | equalize (char ch='?') |
Equalizes sequence lengths. More... | |
int | find (const char *string, bool strict=true) const |
Finds a sequence by its name. More... | |
Protected Member Functions | |
virtual void | setFromSource (unsigned int number_of_sequences, const char *const *const cstring_array) |
virtual void | copyObject (const Container &) |
virtual void | getNamesAndGroups (const Container &) |
Protected Attributes | |
unsigned int | _ns |
unsigned int * | lnames |
char ** | names |
char ** | sequences |
unsigned int * | groups |
Handles a set of sequence alignment (aligned or not)
Creation from a file or string stream should be performed using the class Fasta.
Sequences are represented by two strings (name and sequence) and an integer (group) that can be accessed or modified by index.The order of sequences is guaranteed to be conserved, as if Container was a list of triplets (name, sequence, group).
The data matrix is implemented as continuous arrays (char**) and allows efficient access and modification of data. For very large data matrices you might claim immediately the required memory using the constructor Container(unsigned int, char**).
Container | ( | ) |
Creates an empty object.
Container | ( | unsigned int | number_of_sequences, |
char const *const *const | cstring_array | ||
) |
Creates an object from a data matrix.
Allows you to create an object from data stored in a char* array. The array's size must be passed to the constructor. Since sequences can have different lengths, you need to terminate each sequence by a NULL character. This constructor is dedicated to very performance-critical tasks. For usual tasks, using the default constructor and subsequently adding sequences with addSeq should be enough.
number_of_sequences | the number of sequences (the length of the first dimension of the array). |
cstring_array | the pointer to the data matrix. |
|
virtual |
Destructor.
|
virtual |
Adds a sequence to the object.
name | the name of the sequence, as a c-string. |
sequence | the sequence string, as a c-string. |
group | the group index of the sequence. |
Reimplemented in Align.
|
virtual |
Appends a string to the a given sequence.
pos | the sequence index. |
sequence | the sequence to append at the end of the current one. |
Reimplemented in Align.
|
virtual |
Clears all content of the object.
Reimplemented in Align.
unsigned int equalize | ( | char | ch = '?' | ) |
Equalizes sequence lengths.
Extends sequences as need to ensure that all sequences have the same length.
ch | the character to use for padding. |
int find | ( | const char * | string, |
bool | strict = true |
||
) | const |
Finds a sequence by its name.
Gets the position of the first sequence with the specified name.
string | a sequence name. |
strict | if true, seeks an exact match. If false, compares only until the end of the requested name (for example: ATCFF will match ATCFF_01 if strict is false). |
|
virtual |
Gets a given character.
s | the sequence index. |
p | the character index. |
The positions must fit in the current ranges.
Reimplemented in Align.
|
virtual |
Changes the group index of a given sequence.
pos | the sequence index. |
group | the new group index value. |
|
virtual |
Gets the group index of a given sequence.
pos | the index of the sequence. |
Container hslice | ( | unsigned int | a, |
unsigned int | b | ||
) | const |
Extracts a range of sequences.
a | the index of the first sequence. |
b | the index immediately passed the last sequence to extract. |
Sequences a to b-1 are extracted, provided that the indices fit in the current number of sequences. To extract all sequences, use container.hslice(0, container.ns()).
Note: invalid ranges will be silently supported. If a>=ls or b<=a, an empty object is returned. If b>ns, ls will be substituted to a.
bool isEqual | ( | ) | const |
Checks if all lengths are equal.
Returns true if the length of all sequences are equal or if there is less thant two sequences.
|
virtual |
Gets the length of a given sequence.
pos | the index of the sequence. |
Reimplemented in Align.
|
virtual |
Changes the name of a given sequence.
pos | the sequence index. |
name | the new name as a C-like string. |
|
virtual |
Gets the name of the a given sequence.
pos | the index of the sequence. |
unsigned int ns | ( | ) | const |
Gets the number of sequences.
|
virtual |
Removes a sequence from the object.
pos | the index of the sequence to remove. |
Reimplemented in Align.
|
virtual |
Changes the sequence string of a given sequence.
pos | the sequence index. |
sequence | the new sequence as a C-like string. |
Reimplemented in Align.
|
virtual |
Gets the name of a given sequence.
pos | the index of the sequence. |
Reimplemented in Align.
|
virtual |
Changes a character.
sequence | the sequence index. |
position | the character index. |
ch | the new character value. |
The positions must fit in the current ranges.
Reimplemented in Align.