|
The Sequence class provides abstractions to work with a simple sequence of Monomers. More...
Header: | #include <Sequence.hpp> |
Inherited By: | MsXpS::libXpertMass::Oligomer and MsXpS::libXpertMass::Polymer |
Sequence(const QString &text = QString()) | |
Sequence(const Sequence &other) | |
virtual | ~Sequence() |
void | appendMonomerText(const QString &text) |
const Monomer * | at(int index) const |
quint16 | checksum(int index_start = -1, int index_end = -1, bool with_modifs = false) const |
int | findForwardMotif(Sequence *motif, PolChemDefCstSPtr pol_chem_def_csp, int *index) |
bool | insertMonomerAt(const Monomer *monomer, int index) |
bool | isInBound(int index) |
int | makeMonomerList(PolChemDefCstSPtr pol_chem_def_csp, bool reset = true, QList<int> *errorList = 0) |
virtual int | makeMonomerText() |
int | monomerIndex(const Monomer *monomer) |
const QList<const Monomer *> & | monomerList() const |
QList<const Monomer *> * | monomerListPtr() |
const QString * | monomerText() |
QString * | monomerText(int start, int end, bool with_modif) const |
QString * | monomerText(const CoordinateList &coordinate_list, bool with_modif, bool delimited_regions) const |
int | nextCode(QString *code, int *index, QString *err, int code_length) |
virtual bool | removeMonomerAt(int index) |
void | setMonomerText(const QString &text) |
int | size() const |
void | unspacifyMonomerText() |
bool | validate(PolChemDefCstSPtr pol_chem_def_csp) |
Sequence & | operator=(const Sequence &other) |
QList<const Monomer *> | m_monomerList |
QString | m_monomerText |
A sequence of monomer can be represented in two ways:
Note: The reference status of a sequence is in the form of a list of allocated Monomer instances. The conversion to the string of monomer codes is only a utility. When a sequence is created (with an argument that is a string of monomer codes) the caller should ensure that the text sequence is converted into a list of monomers prior to starting using its methods extensively (see makeMonomerList()). Functions size() and removeMonomerAt()) only work on a sequence in the form of a list of Monomer instances.
Methods are provided to convert from one sequence kind (concatenated codes) to the other sequence kind(list of Monomer instances).
Equally interesting is the ability of the methods in this class to be able to:
- parse the monomer sequence and to extract monomer codes one after the other;
- remove monomers from the sequence at specified indexes;
- add monomers to the sequence at specified indexes.
However, for this rather basic class to be able to perform interesting tasks it has to be able to know where to find polymer chemistry definition PolChemDef data. This is possible only when a pointer to a polymer chemistry definition is passed to the used functions.
Construct a Sequence using text.
The sequence is in the form of a string of concatenated monomer codes. No quality check is performed.
Construct this Sequence as a copy of other.
The copying is deep with the list of Monomer instances copied to this Sequence.
[virtual noexcept]
Sequence::~Sequence()Destructs this sequence.
The Monomer instances are deleted.
Appends the text sequence of monomer codes to this Sequence.
No verification is performed on text.
Returns the Monomer instance at index index in this Sequence's monomer instance list.
Returns a checksum calculated on this Sequence's portion contained in [index_start – index_end].
The sequence matching the [index_start – index_end] range is extracted from m_monomerText, with (with_modifs is true) or without (with_modifs is false) the monomer modifications. The checksum is computed on that extracted string.
Returns the checksum.
Searches in for a Sequence textual motif in this Sequence's list of Monomer instances starting at index.
motif, a text string is first converted to a list of Monomer instances (using the reference list of monomers in pol_chem_def_csp). Then, this Sequence's monomer instances list is searched for a monomer stretch matching that created for motif.
As soon as a monomer code stretch is found, the index in this Sequence's list of Monomer instances is set to index.
Returns 1 if motif was found in this Sequence, 0 otherwise.
Insert monomer at index index.
Returns true.
Returns true if index is valid as an index of a Monomer instance in this Sequence's list of Monomers, false otherwise.
Allocates all the Monomer instances to describe this Sequence's string representation of monomer codes.
This function parses the member Monomer codes string (m_monomerText) and, for each encountered code, creates a Monomer instance and add it to the member list of Monomer instances (m_monomerList).
If reset is true, the member list of Monomer instances is reset before the work is done.
If errorList is non-nullptr, errors are stored in this list in the form of the indices of failing monomer codes in the string.
The allocation of each Monomer instance based on its code is performed by looking at the reference Monomer list in pol_chem_def_csp.
Because the m_monomerText member string of Monomer codes does not document any monomer modification, no modifications are handled in this function.
Returns the size of the Monomer instances list or -1 if an error occurred.
[virtual]
int Sequence::makeMonomerText()Creates the monomer codes string version of this Sequence's list of Monomer instances and set it to this Sequence
The function essentially writes to the m_monomerText string the code of each Monomer instance in m_monomerList.
m_monomerText is cleared before writing the codes to it.
Returns the count of monomer codes added to m_monomerText.
See also makeMonomerList().
Returns the monomer in this Sequence's list of Monomer instances.
The search is based on comparison of the pointers, that is, the returned index is for the same monomer object.
Returns -1 if monomer is not found.
Returns a reference to this Sequence's list of Monomer instances.
Returns this Sequence's list of Monomer instances.
Returns this Sequence's string of monomer codes.
See also setMonomerText().
Returns an allocated string with the monomer codes.
The returned string only contains the sequence of monomer codes for Monomer instances between indices [start – end] in this Sequence's list of Monomer instances (m_monomerList).
If with_modif is true, the modification(s) associated to Monomers are also output to the string. The form of the string is, in this case,
Thr<Phosphorylation>
Returns an allocated string with the monomer codes.
The returned string only contains the sequence of monomer codes for Monomer instances contained in the regions (Coordinates) described in coordinate_list.
If with_modif is true, the modification(s) associated to Monomers are also output to the string. The form of the string is, in this case,
Thr<Phosphorylation>
If delimited_regions, the sequence of Monomer codes beloging to each will be delimited using the Coordinates positions.
See also Coordinates::positionsAsText().
Seeks the next code occurring in this Sequence's string of Monomer codes.
This function starts looking in this Sequence's string of Monomer codes (m_monomerText) at index. The next found Monomer code is stored in code. If the text is not a monomer code, it is set to err.
The parsing of this Sequence's string of Monomer codes takes into account the code_length.
Returns the count of characters that make code. This count can be used to search for the next code by setting its value incremented by 1 to index for a next function call.
[virtual]
bool Sequence::removeMonomerAt(int index)Removes the monomer instance at index index from this Sequence's list of Monomer instances.
Returns true.
Set this Sequence' string of monomer codes to text.
See also monomerText().
Returns the size of this Sequence as the size of the list of Monomers instances.
Removes all spaces, carriage returns and linefeeds from this Sequence's monomer codes string.
Validates this Sequence using pol_chem_def_csp as the reference polymer chemistry definition.
Returns true if all the monomers in textual representation of the sequence (m_monomerText) could be converted into Monomer instances. This conversion actually fills in m_monomerList. If an error occurred, returns false.
See also makeMonomerList().
Assigns other to this Sequence
Returns a reference to this Sequence.
List of allocated Monomer instances that should match the sequence of codes string (m_monomerText).
String holding the sequence of monomer codes.