1 /* massXpert - the true massist's program.
2    --------------------------------------
3    Copyright(C) 2006,2007 Filippo Rusconi
4 
5    http://www.massxpert.org/massXpert
6 
7    This file is part of the massXpert project.
8 
9    The massxpert project is the successor to the "GNU polyxmass"
10    project that is an official GNU project package(see
11    www.gnu.org). The massXpert project is not endorsed by the GNU
12    project, although it is released ---in its entirety--- under the
13    GNU General Public License. A huge part of the code in massXpert
14    is actually a C++ rewrite of code in GNU polyxmass. As such
15    massXpert was started at the Centre National de la Recherche
16    Scientifique(FRANCE), that granted me the formal authorization to
17    publish it under this Free Software License.
18 
19    This software is free software; you can redistribute it and/or
20    modify it under the terms of the GNU  General Public
21    License version 3, as published by the Free Software Foundation.
22 
23 
24    This software is distributed in the hope that it will be useful,
25    but WITHOUT ANY WARRANTY; without even the implied warranty of
26    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27    General Public License for more details.
28 
29    You should have received a copy of the GNU General Public License
30    along with this software; if not, write to the
31 
32    Free Software Foundation, Inc.,
33 
34    51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
35 */
36 
37 
38 #ifndef OLIGOMER_HPP
39 #define OLIGOMER_HPP
40 
41 
42 /////////////////////// Local includes
43 #include "sequence.hpp"
44 #include "ponderable.hpp"
45 #include "ionizable.hpp"
46 #include "calcOptions.hpp"
47 #include "ionizeRule.hpp"
48 #include "monomer.hpp"
49 #include "coordinates.hpp"
50 #include "crossLinkList.hpp"
51 
52 
53 namespace massXpert
54 {
55 
56   class Polymer;
57 
58 
59   //! The Oligomer class provides an oligomer.
60   /*! An oligomer is a stretch of monomers belonging to a polymer. It is
61     characterized by: \                         \
62 
63     \li The polymer(a pointer to a Polymer) in which it spans a
64     given region;
65 
66     \li An index(integer) at which the region starts in the polymer sequence;
67 
68     \li An index(integer) at which the region stops in the polymer
69     sequence
70 
71     The start index cannot be less than 0 and greater than the size of
72     the polymer minus one, and the end index follows the same rule.
73 
74     Derived from Ponderable, an oligomer is also characterized by a
75     monoisotopic mass and an average mass.
76 
77     All computations about an oligomer(fragmentation, composition, for
78     example, isoelectric point, ...) can only be performed by referring
79     to the sequence of its "enclosing" polymer. Therefore, an oligomer
80     should never exist after the destruction of its enclosing polymer.
81   */
82   class Oligomer : public Sequence,
83                    public CoordinateList,
84                    public Ionizable,
85                    public PropListHolder
86   {
87   protected:
88     //! Polymer in which this oligomer spans a region.
89     const QPointer<Polymer> mp_polymer;
90 
91     QString m_description;
92 
93     // !The list of the the cross-links that are involved in the
94     // !formation of the cross-linked oligomer(the CrossLink *
95     // !instances are in mp_polymer->crossLinkList()). We cannot use
96     // !the CrossLinkList object because when destructed it would
97     // !destroy the cross-links in it, while we only want to store
98     // !pointers.
99     QList<CrossLink*> m_crossLinkList;
100 
101     CalcOptions m_calcOptions;
102 
103   public:
104     Oligomer(Polymer *,
105              const QString &,
106              const QString &,
107              const Ponderable &,
108              const IonizeRule &,
109              const CalcOptions &,
110              bool,
111              int, int);
112 
113     Oligomer(const PolChemDef *,
114              const QString &,
115              const QString &,
116              const Ponderable &,
117              const IonizeRule &,
118              const CalcOptions &,
119              bool,
120              int, int);
121 
122     Oligomer(Polymer *,
123              const QString &,
124              const QString &,
125              const Ponderable & = Ponderable(),
126              int = -1, int = -1,
127              const CalcOptions & = CalcOptions());
128 
129     Oligomer(const PolChemDef *,
130              const QString &,
131              const QString &,
132              const Ponderable & = Ponderable(),
133              const CalcOptions & = CalcOptions(),
134              int = -1, int = -1);
135 
136     Oligomer(const Ionizable &,
137              const CalcOptions & = CalcOptions(),
138              int = -1, int = -1);
139 
140     Oligomer(Polymer *,
141              const QString &,
142              const QString &,
143              double = 0, double = 0, int = -1, int = -1,
144              const CalcOptions & = CalcOptions());
145 
146     Oligomer(const PolChemDef *,
147              const QString &,
148              const QString &,
149              const CalcOptions & = CalcOptions(),
150              double = 0, double = 0, int = -1, int = -1);
151 
152     Oligomer(const Oligomer &);
153 
154     virtual ~Oligomer();
155 
156     const Polymer *polymer() const;
157 
158     void setStartEndIndices(int, int);
159 
160     void setStartIndex(int);
161     int startIndex() const;
162 
163     void setEndIndex(int);
164     int endIndex() const;
165 
166     void setDescription(const QString &);
167     QString description() const;
168 
169     int appendCoordinates(CoordinateList *);
170 
171     void setIonizeRule(IonizeRule &);
172     IonizeRule &ionizeRule();
173 
174     void setCalcOptions(const CalcOptions &);
175     const CalcOptions &calcOptions() const;
176     void updateCalcOptions();
177 
178     const Monomer &atLeftEnd() const;
179     const Monomer &atRightEnd() const;
180     const Monomer *monomerAt(int) const;
181 
182     QList<CrossLink*> *crossLinkList();
183     bool addCrossLink(CrossLink *);
184 
185     // ELEMENTAL CALCULATION FUNCTION
186     /////////////////////////////////
187 
188     QString elementalComposition();
189 
190     /////////////////////////////////
191     // ELEMENTAL CALCULATION FUNCTION
192 
193     virtual int makeMonomerText();
194     QString *monomerText();
195 
196     virtual bool calculateMasses();
197     virtual bool calculateMasses(const CalcOptions *calcOptions,
198                                  const IonizeRule *ionizeRule = 0);
199 
200     virtual bool isModified();
201 
202     int size();
203 
204     bool encompasses(int) const;
205     bool encompasses(const Monomer *) const;
206   };
207 
208 } // namespace massXpert
209 
210 
211 #endif // OLIGOMER_HPP
212