File: sequence.hpp

package info (click to toggle)
massxpert 2.3.6-1squeeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 20,736 kB
  • ctags: 3,541
  • sloc: cpp: 44,108; xml: 7,381; sh: 604; makefile: 108; ansic: 7
file content (143 lines) | stat: -rw-r--r-- 4,758 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* massXpert - the true massist's program.
   --------------------------------------
   Copyright(C) 2006,2007 Filippo Rusconi

   http://www.massxpert.org/massXpert

   This file is part of the massXpert project.

   The massxpert project is the successor to the "GNU polyxmass"
   project that is an official GNU project package(see
   www.gnu.org). The massXpert project is not endorsed by the GNU
   project, although it is released ---in its entirety--- under the
   GNU General Public License. A huge part of the code in massXpert
   is actually a C++ rewrite of code in GNU polyxmass. As such
   massXpert was started at the Centre National de la Recherche
   Scientifique(FRANCE), that granted me the formal authorization to
   publish it under this Free Software License.

   This software is free software; you can redistribute it and/or
   modify it under the terms of the GNU  General Public
   License version 3, as published by the Free Software Foundation.
   

   This software is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this software; if not, write to the

   Free Software Foundation, Inc.,

   51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/


#ifndef SEQUENCE_HPP
#define SEQUENCE_HPP


/////////////////////// Qt includes
#include <QString>


/////////////////////// Local includes
#include "monomer.hpp"
#include "prop.hpp"


namespace massXpert
{

  //! The Sequence class provides a simple sequence.
  /*!  A simple sequence is made of monomers arranged either in the form
    of a string of monomer codes concatenated one to the other with no
    delimitation(like "ATGC" or "AlaThrGlyCys") or in the form of a
    list(QList<Monomer *>) of full-fledged monomers.

    \attention The reference status of a sequence is in the form of a
    list of monomer instances. The conversion to the string of 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()). Note that functions size() and
    removeMonomerAt()) only work on a sequence in the form of a list
    of monomers.

    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 data. This is possible only when a pointer to
    a polymer chemistry definition is passed to the used functions.
  */
  class Sequence
  {
  protected:
    //! Sequence in the form of a string of concatenated monomer codes.
    /*! Used to fill the \c m_monomerList member.
     */
    QString m_monomerText;
  
    //! List of monomers in the sequence. Empty upon creation.
    /*! Is filled with Monomer instances upon parsing of the text
      version of the sequence.
    */
    QList<const Monomer *> m_monomerList;
  
  public:
    Sequence(const QString & = QString());
    virtual ~Sequence();
  
    void setMonomerText(const QString &);
    void appendMonomerText(const QString &);
    const QString *monomerText();
      
    const QList<const Monomer *> &monomerList() const;
    QList<const Monomer *> *monomerListPtr();
    
    int nextCode(QString *, int *, QString *, int);
    const Monomer *at(int) const;
    int monomerIndex(const Monomer *);
    
    int size() const;
  
    void unspacifyMonomerText();
    
    virtual int makeMonomerText();
    QString *monomerText(int, int, bool) const;
    QString *monomerText(const CoordinateList &, bool, bool) const;

    int makeMonomerList(const PolChemDef *, bool = true, 
			 QList<int> * = 0);
    
    bool insertMonomerAt(const Monomer *, int);
    virtual bool prepareMonomerRemoval(const Monomer *);
    virtual bool removeMonomerAt(int);
    
    bool findForwardMotif(Sequence *, const PolChemDef *, int *);
    
    bool validate(const PolChemDef *);
    
    quint16 checksum(int = -1, int = -1, bool = false) const;
  };

} // namespace massXpert


#endif // SEQUENCE_HPP