For calculating peptide and fragment masses.
#include "msparser.hpp"
#include <iostream>
#include <iomanip>
using namespace matrix_science;
static void displayMascotTestSearch(
const ms_modvector vecFixed,
const double mr,
int main(int argc, char * argv[])
{
if ( argc < 3 )
{
std::cout << "Location of enzymes file and mod_file has to be specified as parameters" << std::endl;
return 0;
}
if ( !enzymefile.isValid() )
{
std::cout << "There are errors. Cannot continue. The last error description:" << std::endl;
std::cout << enzymefile.getLastErrorString() << std::endl;
return 1;
}
const ms_enzyme *enzyme = enzymefile.getEnzymeByName(
"Trypsin");
if ( enzyme == NULL )
{
std::cout << "Cannot find Trypsin enzyme in the file. Cannot continue." << std::endl;
return 1;
}
if ( !modfile.isValid() )
{
std::cout << "There are errors. Cannot continue. The last error description:" << std::endl;
std::cout << modfile.getLastErrorString() << std::endl;
return 1;
}
const ms_modification *oxidation = modfile.getModificationByName(
"Oxidation (M)");
const ms_modification *acetylNterm = modfile.getModificationByName(
"Acetyl (N-term)");
const ms_modification *phospho = modfile.getModificationByName(
"Phospho (STY)");
if ( oxidation == NULL || acetylNterm == NULL || phospho == NULL)
{
std::cout << "Cannot find necessary modifications in the mod_file. Cannot continue." << std::endl;
return 1;
}
char proteinStr[] = "MAIFRIDEIRNMSSEELEEELRKLEVELIRERGAVRAGGAPEKPGRIREIRRTIARMKTVQRERVRK";
std::cout << "List of peptides" << std::endl;
{
std::string peptideStr;
peptideStr.assign(proteinStr+start, len);
std::cout << peptideStr << std::endl;
}
std::cout << "End of list" << std::endl;
{
std::cout << "There are errors. Cannot continue. The last error description:" << std::endl;
return 1;
}
std::vector< int > numThatMustBeModded;
numThatMustBeModded.push_back(1);
numThatMustBeModded.push_back(1);
static_cast<int>(strlen(proteinStr)),
1, 10,
numThatMustBeModded,
0,
&err);
{
std::cout << "There have been errors while calculating peptide mass: " << std::endl;
}
else
{
std::cout << "Peptide mass calculated using 'calcPeptideMZ' is "
<< std::setprecision(3)
<< std::fixed
<< std::setw(8)
<< mr
<< std::endl << std::endl << std::endl;
}
std::vector< int > numModded;
numModded.push_back(2);
numModded.push_back(1);
numModded.push_back(0);
numModded.push_back(0);
numModded.push_back(0);
numModded.push_back(0);
numModded.push_back(0);
numModded.push_back(0);
numModded.push_back(0);
numModded.push_back(0);
numModded.push_back(0);
numModded.push_back(0);
std::vector< int > whichNl;
whichNl.push_back(0);
whichNl.push_back(1);
whichNl.push_back(0);
whichNl.push_back(0);
whichNl.push_back(0);
whichNl.push_back(0);
whichNl.push_back(0);
whichNl.push_back(0);
whichNl.push_back(0);
whichNl.push_back(0);
whichNl.push_back(0);
whichNl.push_back(0);
static_cast<int>(strlen(proteinStr)),
1,10,
numModded,
whichNl,
0,
&err);
{
std::cout << "There have been errors while creating a peptide: " << std::endl;
}
else
{
std::cout
<< "Peptide has been created successfully: "
<< std::endl;
}
std::vector< double > ions;
ms_fragmentationrules::FRAG_B_SERIES,
false,
100.0,
mr,
&fragments,
&err);
std::cout << "b-ion series fragments: " << std::endl;
printFragmentsTable(fragments);
ms_fragmentationrules::FRAG_Y_SERIES,
false,
100.0,
mr,
&fragments,
&err);
std::cout << "y-ion series fragments: " << std::endl;
printFragmentsTable(fragments);
int i;
ms_fragmentationrules::FRAG_Y_SERIES,
2,
100.0,
mr,
&fragments,
&err);
std::cout << "y++-ion series fragments: " << std::endl;
printFragmentsTable(fragments);
ms_fragmentationrules::FRAG_INTERNAL_YB,
false,
100.0,
700,
&fragments,
&err);
std::cout << "internal yb-ion series fragments: " << std::endl;
printFragmentsTable(fragments);
std::cout << "Run a search under Mascot to verify the output above" << std::endl;
std::cout << "Paste the following into a Mascot search query window:" << std::endl;
displayMascotTestSearch(vecFixed, vecVariable,
enzyme,
mr,
b_ions);
return 0;
}
{
std::cout << "Col\tStart\tEnd\tLabel\t\t Mass\t NL\tName\tImmon\tIntern\tReg" << std::endl;
{
std::cout << frag->
getEnd() <<
"\t";
std::cout << std::setw(10) << frag->
getLabel() <<
"\t";
std::cout << std::fixed << std::setprecision(2) << std::setw(7) << frag->
getMass() <<
"\t";
}
std::cout << std::endl;
}
static void displayMascotTestSearch(
const ms_modvector vecFixed,
const double mr,
{
int i;
{
std::cout << "MODS="
<< std::endl;
}
{
std::cout << "IT_MODS="
<< std::endl;
}
std::cout << "CHARGE=Mr" << std::endl;
std::cout <<
"CLE=" << enzyme->
getTitle() << std::endl;
std::cout << "INSTRUMENT=MALDI-TOF-TOF" << std::endl;
std::cout << std::setprecision(3) << mr << " ions(";
{
if (i > 0)
std::cout << ", ";
}
std::cout << ")" << std::endl;
}
This class facilitates creation of peptides and calculation of MS-fragment masses.
Definition: ms_aahelper.hpp:35
std::vector< double > calcFragments(const ms_peptide *peptide, const int seriesID, const bool doubleCharged, const double minMass, const double maxMass, const MASS_TYPE massType, ms_fragmentvector *fragments, ms_errs *err, const FRAG_NL fragNlType=FRAG_NL_PRIMARY) const
Returns a vector of ion masses for the given series and peptide.
Definition: ms_aahelper.cpp:4072
int getPepEnd() const
Returns the last position of the current peptide.
Definition: ms_aahelper.cpp:1105
bool calcFragmentsEx(const ms_peptide *peptide, const int seriesID, const int fragCharge, const double minMass, const double maxMass, const MASS_TYPE massType, ms_fragmentvector *fragments, ms_errs *err, const FRAG_NL fragNlType=FRAG_NL_PRIMARY) const
Returns a vector of ion masses for the given series and peptide.
Definition: ms_aahelper.cpp:4124
double calcPeptideMZ(const char *proteinStr, const int proteinLen, const int startPos, const int endPos, const std::vector< int > numThatMustBeModded, const int charge, const MASS_TYPE massType, ms_errs *err) const
Calculates and returns a peptide m/z (or Mr) value without specifying exact positions of modified res...
Definition: ms_aahelper.cpp:1163
void setEnzyme(const ms_enzyme *enzyme)
Sets an enzyme to use.
Definition: ms_aahelper.cpp:494
void setAvailableModifications(const ms_modvector *fixedModVector, const ms_modvector *varModVector)
Applies fixed modifications to residue masses and stores variable modifications for later use.
Definition: ms_aahelper.cpp:550
bool getNextPeptide()
Call to iterate to the next peptide.
Definition: ms_aahelper.cpp:885
void setMasses(const ms_masses *masses)
Copies all residue and chemical element masses from the masses file instance.
Definition: ms_aahelper.cpp:512
void startIteratePeptides(const char *sequenceProtein, const int sizeProtein, const int pfa)
Initialises internal members in preparation for generating peptides.
Definition: ms_aahelper.cpp:837
ms_peptide createPeptide(const char *proteinStr, const int proteinLen, const int startPos, const int endPos, const std::vector< int > varMods, const std::vector< int > varModsWhichNl, const int charge, const MASS_TYPE massType, ms_errs *err) const
Creates and returns a peptide object.
Definition: ms_aahelper.cpp:1558
int getPepStart() const
Returns the first position of the current peptide.
Definition: ms_aahelper.cpp:1094
Represent a single entry in the enzymes file.
Definition: ms_enzyme.hpp:67
std::string getTitle() const
Returns a name of the enzyme as appears in the file.
Definition: ms_enzyme.cpp:318
Reads and parses the enzymes file that contains multiple enzyme definitions.
Definition: ms_enzyme.hpp:194
std::string getLastErrorString() const
Return the error description of the last error that occurred.
Definition: ms_errors.cpp:1488
bool isValid() const
Call this function to determine if there have been any errors.
Definition: ms_errors.cpp:1472
All errors are collected in an instance of this class.
Definition: ms_errors.hpp:37
std::string getLastErrorString() const
Return the last error number or an empty string.
Definition: ms_errors.cpp:1126
bool isValid() const
Returns TRUE if no errors occurred, FALSE otherwise.
Definition: ms_errors.cpp:707
void clearAllErrors()
Remove all errors from the current list of errors.
Definition: ms_errors.cpp:1019
Class representing a single peptide fragment.
Definition: ms_fragment.hpp:38
int getColumn() const
Returns the 1-based position index in case of a regular series.
Definition: ms_fragment.cpp:809
std::string getLabel(const LABEL_FORMAT fmt=LABEL_FORMAT_TRADITIONAL) const
Returns a symbolic label like "a*(6)++".
Definition: ms_fragment.cpp:758
std::string getSeriesName() const
Returns the ion series name.
Definition: ms_fragment.cpp:804
bool isImmonium() const
Returns TRUE for immonium ions.
Definition: ms_fragment.cpp:733
int getStart() const
Returns the 1-based start position within the peptide sequence.
Definition: ms_fragment.cpp:818
double getNeutralLoss() const
Returns the neutral loss (m/z) values applied to the fragment.
Definition: ms_fragment.cpp:748
int getEnd() const
Returns the 1-based last position in case of an internal fragment.
Definition: ms_fragment.cpp:828
bool isInternal() const
Returns TRUE for internal fragments ya and yb.
Definition: ms_fragment.cpp:728
double getMass() const
Returns the ion mass (m/z) value.
Definition: ms_fragment.cpp:743
bool isRegular() const
Returns TRUE for a, b, c, d, y, v, w, x, z series and their derivatives.
Definition: ms_fragment.cpp:713
Class for holding a list of ms_fragment objects.
Definition: ms_fragmentvector.hpp:47
int getNumberOfFragments() const
Returns a number of fragments currently held in the vector.
Definition: ms_fragmentvector.cpp:88
const ms_fragment * getFragmentByNumber(const unsigned int numFrag) const
Return a fragment object by its number.
Definition: ms_fragmentvector.cpp:121
void appendFragment(const ms_fragment *item)
Adds a new fragment to the end of the vector.
Definition: ms_fragmentvector.cpp:109
void copyFrom(const ms_fragmentvector *right)
Copies all content from another instance.
Definition: ms_fragmentvector.cpp:60
Reads and parses the masses file with residue and atom masses.
Definition: ms_masses.hpp:48
Use this class in order to read in the amino acid modification file.
Definition: ms_modfile.hpp:407
The class represents a single modification-entry in mod_file.
Definition: ms_modfile.hpp:134
std::string getTitle() const
Returns the modification title.
Definition: ms_modfile.cpp:171
General usage class for creating lists of modifications to be passed as parameters.
Definition: ms_modfile.hpp:339
const ms_modification * getModificationByNumber(const int numMod) const
Returns a modification object by its number.
Definition: ms_modfile.cpp:955
int getNumberOfModifications() const
Returns the number of modifications currently held in the vector.
Definition: ms_modfile.cpp:918
void appendModification(const ms_modification *item)
Adds a new modification at the end of the vector.
Definition: ms_modfile.cpp:933
This class encapsulates a peptide from the mascot results file.
Definition: ms_peptide.hpp:57
std::string getPeptideStr(bool substituteAmbiguous=true, const PSM psmComponent=PSM_COMPLETE) const
Returns the sequence found for the peptide.
Definition: ms_peptide.cpp:710
@ MASS_TYPE_MONO
monoisotopic mass index
Definition: ms_modfile.hpp:66