Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
config_enzymes.cpp

Read in the enzymes file.

/*
##############################################################################
# file: config_enzymes.cpp #
# 'msparser' toolkit example code #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1998-2005 Matrix Science Limited All Rights Reserved. #
# #
##############################################################################
# $Source: parser/examples/test_cxx/config_enzymes.cpp $ #
# $Author: villek@matrixscience.com $ #
# $Date: 2018-07-30 16:23:53 +0100 $ #
# $Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $ #
# $NoKeywords:: $ #
##############################################################################
*/
#include "msparser.hpp"
#include <iostream>
// All the classes are part of the matrix_science namespace
using namespace matrix_science;
int main(int argc, char * argv[])
{
if ( argc < 2 )
{
std::cout << "The location of enzymes file has to be specified as a parameter" << std::endl;
std::cout << "The location should either be the full path to the enzymes file" << std::endl;
std::cout << "or a URL to a Mascot server - e.g. http://mascot-server/mascot/cgi" << std::endl;
return 1;
}
// A sessionID can optionally be passed as the second parameter
// This will only be required if the 'file' is a URL
if (argc > 2)
{
cs.setSessionID(argv[2]);
}
ms_enzymefile file(argv[1], &cs);
if (!file.isValid())
{
std::cout << "There are errors. Cannot continue. The last error description:" << std::endl;
std::cout << file.getLastErrorString() << std::endl;
return 1;
}
// how many do we have in total?
int n = file.getNumberOfEnzymes();
std::cout << "There are " << n << " enzymes definitions available" << std::endl;
// now get them all!
int i;
for(i=0; i < n ; i++)
{
const ms_enzyme * enzyme = file.getEnzymeByNumber(i);
std::cout << enzyme->getTitle() << ": ";
for (int c=0; c < enzyme->getNumberOfCutters(); c++) {
std::cout << "nTerm - ";
} else {
std::cout << "cTerm - ";
}
std::cout << enzyme->getCleave(c) << "!" << enzyme->getRestrict(c);
std::cout << "; ";
}
std::cout << std::endl;
}
// Now try updating the first one in the list to semi-specific
ms_enzyme enzyme = *file.getEnzymeByNumber(0);
enzyme.setSemiSpecific(true);
file.updateEnzymeByNumber(0, enzyme);
// And delete V8-DE
if (file.deleteEnzymeByName("V8-DE")) {
std::cout << "Deleted the enzyme V8-DE " << std::endl;
}
//Finally, save the file under a new name - but only if not http:
if (strncmp("http:", argv[1], 5) != 0) {
std::string filename = argv[1];
filename += ".new";
file.setFileName(filename.c_str());
file.save_file();
}
std::cout << "There are now " << file.getNumberOfEnzymes() << " enzymes definitions available" << std::endl;
return 0;
}
/*
will give the output:
# test.exe ../config/enzymes
There are 19 enzymes definitions available
Trypsin: cTerm - KR!P;
Arg-C: cTerm - R!P;
Asp-N: nTerm - BD!;
Asp-N_ambic: nTerm - DE!;
Chymotrypsin: cTerm - FLWY!P;
CNBr: cTerm - M!;
CNBr+Trypsin: cTerm - M!; cTerm - KR!P;
Formic_acid: cTerm - D!;
Lys-C: cTerm - K!P;
Lys-C/P: cTerm - K!;
PepsinA: cTerm - FL!;
Tryp-CNBr: cTerm - KMR!P;
TrypChymo: cTerm - FKLRWY!P;
Trypsin/P: cTerm - KR!;
V8-DE: cTerm - BDEZ!P;
V8-E: cTerm - EZ!P;
semiTrypsin: cTerm - KR!P;
LysC+AspN: nTerm - BD!; cTerm - K!P;
None: cTerm - KR!P;
There are now 18 enzymes definitions available
*/
Settings required to make an HTTP connection to a Mascot server.
Definition: ms_connection_settings.hpp:54
void setSessionID(const std::string sessionID)
Sets the Mascot security sessionID to be used for the connection.
Definition: ms_connection_settings.cpp:242
Represent a single entry in the enzymes file.
Definition: ms_enzyme.hpp:67
int getNumberOfCutters() const
Returns the number of cutters.
Definition: ms_enzyme.cpp:454
std::string getCleave(const int cutterNum) const
Returns the list of cleavage points for a cutter.
Definition: ms_enzyme.cpp:593
std::string getRestrict(const int cutterNum) const
Returns the list of restriction points for a cutter.
Definition: ms_enzyme.cpp:632
ms_enzyme::cuttertype getCutterType(const int cutterNum) const
Return the number of cutters that make up the enzyme definition.
Definition: ms_enzyme.cpp:573
@ NTERM_CUTTER
N Terminus cutter - cuts before the specified residue(s).
Definition: ms_enzyme.hpp:78
std::string getTitle() const
Returns a name of the enzyme as appears in the file.
Definition: ms_enzyme.cpp:318
void setSemiSpecific(const bool value)
Sets a new value for the semi specific flag.
Definition: ms_enzyme.cpp:380
Reads and parses the enzymes file that contains multiple enzyme definitions.
Definition: ms_enzyme.hpp:194
void save_file()
Stores enzyme definitions in a file.
Definition: ms_enzyme.cpp:1442
int getNumberOfEnzymes() const
Returns a number of enzymes successfully read from the file.
Definition: ms_enzyme.cpp:910
bool updateEnzymeByNumber(const int num, const ms_enzyme enzyme)
Update the information for a specific enzyme.
Definition: ms_enzyme.cpp:936
void setFileName(const char *filename)
Call this member before reading the file if you want to specify a non-default name.
Definition: ms_enzyme.cpp:868
const ms_enzyme * getEnzymeByNumber(const int num) const
Returns a pointer to an internally stored enzyme.
Definition: ms_enzyme.cpp:921
bool deleteEnzymeByName(const char *name)
Remove an enzyme from the list in memory.
Definition: ms_enzyme.cpp:1016
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