Matrix Science header

ms_aahelper.hpp

00001 /*
00002 ##############################################################################
00003 # File: ms_aahelper.hpp                                                      #
00004 # Mascot Parser toolkit                                                      #
00005 # Utility functions for generating peptides, peptide and fragment masses     #
00006 ##############################################################################
00007 # COPYRIGHT NOTICE                                                           #
00008 # Copyright 1998-2006 Matrix Science Limited  All Rights Reserved.           #
00009 #                                                                            #
00010 ##############################################################################
00011 #    $Source: parser/inc/ms_aahelper.hpp $
00012 #    $Author: villek@matrixscience.com $ 
00013 #      $Date: 2019-11-08 15:15:24 +0000 $ 
00014 #  $Revision: 3515c2de6fecc95325d37682f127179265ced370 | MSPARSER_REL_2_8_1-0-gea32989045 $
00015 ##############################################################################
00016 */
00017 
00018 #ifndef MS_AAHELPER_HPP
00019 #define MS_AAHELPER_HPP
00020 
00021 
00022 #include <string>
00023 #include <vector>
00024 
00025 
00026 namespace matrix_science {
00033 
00034     class MS_MASCOTRESFILE_API ms_aahelper: public ms_errors
00035     {
00036     public:
00038 
00047         enum FRAG_NL {
00048             FRAG_NL_PRIMARY = 0x0001, 
00049             FRAG_NL_SECONDARY = 0x0010 
00050         };
00051 
00053         ms_aahelper();
00054 
00056         ms_aahelper(const ms_mascotresfile & resfile, 
00057                     const char * enzymeFileName,
00058                     const char * quantSchemaFilePath = "http://www.matrixscience.com/xmlns/schema/quantitation_2  ../html/xmlns/schema/quantitation_2/quantitation_2.xsd http://www.matrixscience.com/xmlns/schema/quantitation_1 ../html/xmlns/schema/quantitation_1/quantitation_1.xsd",
00059                     const char * unimodSchemaFilePath = "http://www.unimod.org/xmlns/schema/unimod_2 ../html/xmlns/schema/unimod_2/unimod_2.xsd");
00060 
00062         ms_aahelper(const ms_mascotresults & summary, 
00063                     const char * enzymeFileName,
00064                     const char * quantSchemaFilePath = "http://www.matrixscience.com/xmlns/schema/quantitation_2  ../html/xmlns/schema/quantitation_2/quantitation_2.xsd http://www.matrixscience.com/xmlns/schema/quantitation_1 ../html/xmlns/schema/quantitation_1/quantitation_1.xsd",
00065                     const char * unimodSchemaFilePath = "http://www.unimod.org/xmlns/schema/unimod_2 ../html/xmlns/schema/unimod_2/unimod_2.xsd");
00066 
00068         ms_aahelper(const ms_aahelper& right);
00069 
00071         ~ms_aahelper();
00072 
00073 #ifndef SWIG
00074 
00075         ms_aahelper& operator=(const ms_aahelper& right);
00076 #endif
00077 
00078         void copyFrom(const ms_aahelper* right);
00079 
00081         void defaultValues();
00082 
00084         void setEnzyme(const ms_enzyme* enzyme);
00085 
00087         const ms_enzyme* getEnzyme() const;
00088 
00090         void setMasses(const ms_masses *masses);
00091 
00093         const ms_masses* getMasses() const;
00094 
00096         void setAvailableModifications(const ms_modvector *fixedModVector, 
00097                                        const ms_modvector *varModVector);
00098 
00100         ms_modvector getFixedMods() const;
00101 
00103         ms_modvector getVarMods() const;
00104 
00106         void startIteratePeptides(const char* sequenceProtein,
00107                                   const int sizeProtein,
00108                                   const int pfa);
00109 
00111         bool getNextPeptide();
00112 
00114         int getPepStart() const;
00115 
00117         int getPepEnd() const;
00118 
00120         int getMissed() const;
00121 
00123         void stopIteratePeptides();
00124 
00126         double calcPeptideMZ(const char* proteinStr,
00127                              const int proteinLen,
00128                              const int startPos,
00129                              const int endPos,
00130                              const std::vector< int > numThatMustBeModded, 
00131                              const int charge, 
00132                              const MASS_TYPE massType,
00133                              ms_errs *err) const;
00134 
00136         ms_peptide createPeptide(const char* proteinStr,
00137                                  const int proteinLen,
00138                                  const int startPos,
00139                                  const int endPos,
00140                                  const std::vector< int > varMods, 
00141                                  const std::vector< int > varModsWhichNl,
00142                                  const int charge,
00143                                  const MASS_TYPE massType,
00144                                  ms_errs *err) const;
00145 
00147         ms_peptide createPeptide(const char* proteinStr,
00148                                  const int proteinLen,
00149                                  const int startPos,
00150                                  const int endPos,
00151                                  const std::vector< int > varMods, 
00152                                  const std::vector< int > varModsWhichNl,
00153                                  const std::vector< int > summedMods, 
00154                                  const std::vector< int > summedModsWhichNl,
00155                                  const int charge,
00156                                  const MASS_TYPE massType,
00157                                  ms_errs *err) const;
00158 
00160         ms_peptide createCrosslinkedPeptide(const ms_peptide &pepAlpha,
00161                                             const ms_peptide &pepBeta,
00162                                             const ms_linker_site_vector &linkedSites,
00163                                             ms_errs *err) const;
00164 
00166         std::vector< double > calcFragments(const ms_peptide* peptide, 
00167                                             const int seriesID, 
00168                                             const bool doubleCharged,
00169                                             const double minMass, 
00170                                             const double maxMass,
00171                                             const MASS_TYPE massType,
00172                                             ms_fragmentvector* fragments,
00173                                             ms_errs* err,
00174                                             const FRAG_NL fragNlType = FRAG_NL_PRIMARY) const;
00175 
00177         bool calcFragmentsEx(const ms_peptide* peptide, 
00178                              const int seriesID, 
00179                              const int fragCharge,
00180                              const double minMass, 
00181                              const double maxMass,
00182                              const MASS_TYPE massType,
00183                              ms_fragmentvector* fragments,
00184                              ms_errs* err,
00185                              const FRAG_NL fragNlType = FRAG_NL_PRIMARY) const;
00186 
00187 #ifndef SWIG
00188 
00189         std::vector< double > calcFragments(const ms_peptide* peptide, 
00190                                             const int seriesID, 
00191                                             const bool doubleCharged,
00192                                             const double minMass, 
00193                                             const double maxMass,
00194                                             const MASS_TYPE massType,
00195                                             std::vector< ms_fragment > *fragments,
00196                                             ms_errs* err,
00197                                             const FRAG_NL fragNlType = FRAG_NL_PRIMARY) const;
00198 
00200         bool calcFragmentsEx(const ms_peptide* peptide, 
00201                              const int seriesID, 
00202                              const int fragCharge,
00203                              const double minMass, 
00204                              const double maxMass,
00205                              const MASS_TYPE massType,
00206                              std::vector< ms_fragment > *fragments,
00207                              ms_errs* err,
00208                              const FRAG_NL fragNlType = FRAG_NL_PRIMARY) const;
00209 #endif
00210 
00211                              
00212     private:
00213         // Nasty const issue with logging and tracing.
00214         ms_errs* getLog() const { return const_cast<ms_errs*>(getErrorHandler()); }
00215 
00216         std::string convertPrimaryNlVectorToString(const std::vector< int > modded,
00217                                                    const std::vector< int > whichNl, 
00218                                                    const ms_modvector &varMods,
00219                                                    const ms_modvector &varMods_used,
00220                                                    ms_errs* err) const;
00221 
00222         std::vector< int > convertPrimaryNlStringToVector(const std::string varModStr,
00223                                                           const std::string primaryNlStr, 
00224                                                           const ms_modvector &varMods_used,
00225                                                           ms_errs* err) const;
00226 
00227         void initialiseFromResfile(const ms_mascotresfile & resfile,
00228                                    const char * enzymeFileName,
00229                                    const char * quantSchemaFilePath,
00230                                    const char * unimodSchemaFilePath);
00231         bool checkVarModConflicts(const ms_modvector *varModVector, ms_modvector &varMods, std::vector<int> &varModsSrc, ms_modvector &varMods_used, ms_errs &err) const;
00232         bool iscleavagepoint(const char left, const char right) const;
00233         bool switchIndependent();
00234         void updatemissed(const int leftPos);
00235         void dropmissed();
00236         void clearMods();
00237         bool calcUnionFragmentList(const ms_peptide* peptide, 
00238                                    const int seriesID, 
00239                                    const int fragCharge,
00240                                    const double minMass, 
00241                                    const double maxMass,
00242                                    const MASS_TYPE massType,
00243                                    const FRAG_NL fragNlType,
00244                                    std::vector< ms_fragment > *fragments,
00245                                    ms_errs *err,
00246                                    std::vector< double > *vi) const;
00247         bool calcCrosslinkedFragments(const ms_peptide *peptide,
00248                                       const int seriesID, 
00249                                       const int fragCharge,
00250                                       const double minMass, 
00251                                       const double maxMass,
00252                                       const MASS_TYPE massType,
00253                                       const FRAG_NL fragNlType,
00254                                       std::vector< ms_fragment > *fragments,
00255                                       ms_errs *err,
00256                                       std::vector< double > *vi) const;
00257         bool cfr(const ms_peptide* peptide,
00258                 const ms_peptide::PSM psmComponent,
00259                 const int seriesID, 
00260                 const int fragCharge,
00261                 const double minMass, 
00262                 const double maxMass,
00263                 const MASS_TYPE massType,
00264                 const FRAG_NL fragNlType,
00265                 const int linkerColumn,
00266                 const double linkerMassOffset,
00267                 std::vector< ms_fragment > *fragments,
00268                 ms_errs* err,
00269                 std::vector< double > *vi) const;
00270 
00271         void getSeriesParams(const char* pepStr,
00272                              const int seriesID,
00273                              const ms_masses & masses,
00274                              const MASS_TYPE massType,
00275                              double& delta,
00276                              int& start,
00277                              int& end,
00278                              bool& forward) const;
00279 
00280         void prepareCumulativeMassAndNL(const std::string &pepStr,
00281                                         const ms_masses *pMasses,
00282                                         const MASS_TYPE massType,
00283                                         const std::vector<bool> &residue_has_varmod,
00284                                         const std::vector<double> &fixedModNlVals,
00285                                         const std::vector<double> &totalModDelta,
00286                                         const std::vector<double> &totalNlVals,
00287                                         const bool isMasterNL,
00288                                         std::vector<double> &m,
00289                                         std::vector<double> &cumulativeNlVals) const;
00290 
00291         class IonSet;
00292         void calculateSeriesMasses(const int seriesID,
00293                                    const int fragCharge,
00294                                    const MASS_TYPE massType,
00295                                    const ms_peptide::PSM psmComponent,
00296                                    const int linkerColumn,
00297                                    const double linkerMassOffset,
00298                                    const ms_masses *pMasses,
00299                                    const std::string &pepStr,
00300                                    const std::vector<double> &m,
00301                                    const std::vector<double> &cumulativeNlVals,
00302                                    const std::vector<bool> &loopLinkingAllows,
00303                                    IonSet &ionSet) const;
00304 
00305         void setupFromPre2_2ResultsFile(const std::string & peptide, const std::string & varMods);
00306 
00307         class ModLookupHelper;
00308         bool initialiseModsAtResidues(const ModLookupHelper &lookupHelper,
00309                                       const std::string &pepStr,
00310                                       const std::string &modStr,
00311                                       const std::vector<int> &primaryNl,
00312                                       const std::string &monoLinkStr,
00313                                       const ms_modvector *varmods,
00314                                       const std::vector<int> *varmods_src,
00315                                       const ms_modvector *varmods_used,
00316                                       const ms_peptide::PSM psmComponent,
00317                                       std::vector< const ms_modification* > &mod_at_residue,
00318                                       ms_errs *err) const;
00319 
00320         bool lookupLocalModVectors(int q, const ms_modvector* &local_mods, const std::vector<int>* &local_mods_src, const ms_modvector* &local_mods_used);
00321         void clearLocalModVectors();
00322 
00323         ms_masses   massesUnmod_;
00324         ms_masses   masses_;
00325         ms_umod_configfile umodFile_;
00326         ms_quant_configfile quantFile_;
00327         const ms_mascotresfile * pResfile_;
00328         const ms_mascotresults * pSummary_;
00329 
00330         ms_modvector fixedMods_;
00331         ms_modvector varMods_;
00332         std::vector< int > varModsSrc_;
00333         ms_modvector varMods_used_;
00334 
00335         typedef std::map<int, ms_modvector > queryParsedLocalMods_t;
00336         typedef std::map<int, std::vector<int> > queryParsedLocalModsSrc_t;
00337         queryParsedLocalMods_t queryParsedLocalMods_;
00338         queryParsedLocalModsSrc_t queryParsedLocalModsSrc_;
00339         queryParsedLocalMods_t queryParsedLocalModsUsed_;
00340 
00341         ms_enzyme   enzyme_;
00342         bool        bEnzymeSet_;
00343         std::string protStr_;
00344         int         protLen_;
00345         int         pfa_; // missed cleavages limit
00346 
00347         // internal iteration parameters
00348         int         numInd_; // current independent enzyme ID
00349         int         l_, r_; // the last peptide ends
00350         int         missed_; // number of missed cleavages in the current peptide
00351         int         enzymesPassed_;
00352 
00353         // for the sake of semi-specific enzymes
00354         bool        forward_;
00355 
00356         // For a pre 2.2 results file, need to keep track of what we know
00357         enum DERIVED_MOD_SPECIFICITY_STATUS
00358         {
00359             DMSS_NOT_INITIALISED,
00360             DMSS_WORKING,
00361             DMSS_COMPLETED,
00362             DMSS_FROM_V2_2_OR_LATER_RESFILE,
00363             DMSS_NOT_FROM_RESFILE
00364         };
00365         DERIVED_MOD_SPECIFICITY_STATUS derivedModSpecificityStatus_;
00366         std::vector<MOD_TYPES> derivedModSpecificities_;
00367         typedef std::vector< std::vector<bool> > modifiedResidues_t;
00368         modifiedResidues_t derivedModifiedResidues_;
00369 
00370     }; // ms_aahelper // end of mass_calculation_group
00372 } // matrix_science
00373 
00374 #endif // MS_AAHELPER_HPP
00375 
00376 /*------------------------------- End of File -------------------------------*/

Copyright © 2022 Matrix Science Ltd.  All Rights Reserved. Generated on Thu Mar 31 2022 01:12:29