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 POLYMER_HPP 39 #define POLYMER_HPP 40 41 42 /////////////////////// Qt includes 43 #include <QString> 44 #include <QObject> 45 46 47 /////////////////////// Local includes 48 #include "sequence.hpp" 49 #include "ionizable.hpp" 50 #include "polChemDef.hpp" 51 #include "modif.hpp" 52 #include "calcOptions.hpp" 53 #include "crossLinkList.hpp" 54 55 56 namespace massXpert 57 { 58 59 //! The Polymer class provides a polymer. 60 /*! A polymer is a sequence(Sequence) to which data are 61 aggregated to make it able to perform a number of tasks. 62 63 The polymer has a name and a code, so that it is possible to 64 refer to it in printed material... 65 66 Because Polymer derives from Ionizable, which itself derives from 67 PolChemDefEntity, it holds a pointer to the polymer chemistry 68 definition of the polymer sequence. Without that datum, using the 69 polymer in a complex context would be impossible, as the polymer 70 chemistry definition will provide a huge amount of data required 71 to operate the polymer efficiently. Because Ionizable inherits 72 Ponderable, the polymer has a mono mass and an average mass. 73 74 The polymer also has modifications(left-end and right-end) to 75 characterize it better. 76 */ 77 class Polymer : public QObject, public Sequence, public Ionizable 78 { 79 Q_OBJECT 80 81 private: 82 //! Name 83 QString m_name; 84 85 //! Code. 86 QString m_code; 87 88 //! Name of the last user having last modified the polymer sequence. 89 QString m_author; 90 91 //! File name. 92 QString m_filePath; 93 94 //! Date and time of the last modification. 95 QDateTime m_dateTime; 96 97 //! Left end modification. 98 Modif m_leftEndModif; 99 100 //! Right end modification. 101 Modif m_rightEndModif; 102 103 //! The list of CrossLink instances. 104 CrossLinkList m_crossLinkList; 105 106 107 public: 108 Polymer(const PolChemDef *, const QString & = QString("NOT_SET"), 109 const QString & = QString("NOT_SET"), 110 const QString & = QString("NOT SET")); 111 112 virtual ~Polymer(); 113 114 void setName(const QString &); 115 QString name() const; 116 117 void setCode(const QString &); 118 QString code() const; 119 120 void setAuthor(const QString &); 121 QString author() const; 122 123 void setFilePath(const QString &); 124 QString filePath() const; 125 126 void setDateTime(const QString &); 127 QString dateTime() const; 128 129 bool setLeftEndModif(const QString & = QString()); 130 bool setLeftEndModif(const Modif &); 131 const Modif &leftEndModif() const; 132 133 bool setRightEndModif(const QString & = QString()); 134 bool setRightEndModif(const Modif &); 135 const Modif &rightEndModif() const; 136 137 const CrossLinkList &crossLinkList() const; 138 CrossLinkList *crossLinkListPtr(); 139 bool crossLinkedMonomerIndexList(int, int, QList<int> *, int *); 140 bool crossLinkList(int, int, QList<CrossLink *> *, int *); 141 142 virtual bool prepareMonomerRemoval(Monomer *); 143 virtual bool removeMonomerAt(int); 144 145 146 // MASS CALCULATION FUNCTIONS 147 ///////////////////////////// 148 149 bool accountMasses(const CalcOptions &); 150 static bool accountMasses(Polymer *, 151 const CalcOptions &, 152 double *, double *); 153 154 bool calculateMasses(const CalcOptions &, bool = true); 155 static bool calculateMasses(Polymer *, const CalcOptions &, 156 double *, double *, bool = true); 157 158 bool accountCappingMasses(int, int = 1); 159 static bool accountCappingMasses(Polymer *, int, 160 double *, double *, int = 1); 161 162 bool accountEndModifMasses(int); 163 static bool accountEndModifMasses(Polymer *, int, 164 double *, double *); 165 static bool accountEndModifMasses(Polymer *, int, 166 Ponderable *); 167 168 bool crossLink(CrossLink *); 169 bool uncrossLink(CrossLink *); 170 171 ///////////////////////////// 172 // MASS CALCULATION FUNCTIONS 173 174 // ELEMENTAL CALCULATION FUNCTION 175 ///////////////////////////////// 176 177 QString elementalComposition(const IonizeRule &, 178 const CoordinateList &, 179 const CalcOptions &); 180 181 ///////////////////////////////// 182 // ELEMENTAL CALCULATION FUNCTION 183 184 bool renderXmlCodesElement(const QDomElement &element); 185 186 static QString xmlPolymerFileGetPolChemDefName(const QString &filePath); 187 188 bool renderXmlPolymerFile(QString = QString("")); 189 bool renderXmlPolymerModifElement(const QDomElement &, int); 190 bool renderXmlPolymerModifElement(const QDomElement &); 191 bool renderXmlPolymerModifElementV3(const QDomElement &); 192 bool renderXmlPolymerModifElementV4(const QDomElement &); 193 bool renderXmlCrossLinksElement(const QDomElement &, int); 194 195 QString *formatXmlDtd(); 196 QString *formatXmlPolSeqElement(int, const QString & = QString(" ")); 197 QString *formatXmlCrossLinksElement(int, const QString & = QString(" ")); 198 199 bool writeXmlFile(); 200 201 bool validate(); 202 203 void debugPutStdErr(); 204 205 signals: 206 void polymerDestroyedSignal(Polymer *); 207 void crossLinkChangedSignal(Polymer *); 208 void crossLinksPartiallyEncompassedSignal(int) const; 209 }; 210 211 } // namespace massXpert 212 213 214 #endif // POLYMER_HPP 215