Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_crosslinking_configfile Class Reference

This class represents the file crosslinking.xml. More...

#include <ms_crosslinking_configfile.hpp>

Inheritance diagram for ms_crosslinking_configfile:
Collaboration diagram for ms_crosslinking_configfile:

Public Member Functions

 ms_crosslinking_configfile ()
 Default constructor.
 
 ms_crosslinking_configfile (const char *fileName, const char *schemaFileName, const ms_connection_settings *cs=0, bool useSchema=true)
 Immediate action constructor that reads the XML file with the given name.
 
 ms_crosslinking_configfile (const ms_crosslinking_configfile &right)
 Copying constructor.
 
virtual ~ms_crosslinking_configfile ()
 Desctructor.
 
void appendErrors (const ms_errors &src)
 Copies all errors from another instance and appends them at the end of own list.
 
void appendMethod (const ms_crosslinking_method *elem)
 Adds a new method at the end of the list.
 
void clearAllErrors ()
 Remove all errors from the current list of errors.
 
void clearMethods ()
 Deletes all methods from the list.
 
void copyFrom (const ms_crosslinking_configfile *right)
 Copies all the information from another instance.
 
void copyFrom (const ms_errors *right)
 Use this member to make a copy of another instance.
 
virtual void defaultValues ()
 Re-initialises the instance.
 
bool deleteMethodByName (const char *name)
 Remove an method from the list in memory.
 
bool deleteMethodByNumber (const int idx)
 Remove an method from the list in memory.
 
ms_connection_settings getConnectionSettings () const
 Returns the sessionID and proxy server for use with an HTTP transfer.
 
const ms_errsgetErrorHandler () const
 Retrive the error object using this function to get access to all errors and error parameters.
 
std::string getFileName () const
 Returns the current file name.
 
int getLastError () const
 Return the error description of the last error that occurred.
 
std::string getLastErrorString () const
 Return the error description of the last error that occurred.
 
std::string getMajorVersion () const
 Returns major document schema version as read from the file, otherwise the latest.
 
const ms_crosslinking_methodgetMethodByName (const char *name) const
 Returns an method object by its name or NULL in case of not found.
 
const ms_crosslinking_methodgetMethodByNumber (const int idx) const
 Returns an method object by its number.
 
std::string getMinorVersion () const
 Returns minor document schema version as read from the file, otherwise the latest.
 
int getNumberOfMethods () const
 Returns a number of methods currently held in memory.
 
std::string getSchemaFileName () const
 Returns the current schema file name that is used to validate the XML file.
 
bool isValid () const
 Call this function to determine if there have been any errors.
 
ms_crosslinking_configfileoperator= (const ms_crosslinking_configfile &right)
 Assignment operator for C++ applications.
 
void read_buffer (const char *buffer)
 Reads configuration information from a string buffer.
 
void read_file ()
 Reads configuration information from the XML file.
 
std::string save_buffer (bool validateAgainstSchema=true)
 Creates a string representation of the XML document with all the content of the object.
 
void save_file ()
 Saves configuration information in the XML file (not mod_file).
 
void setConnectionSettings (const ms_connection_settings &cs)
 Sets the sessionID and proxy server for use with an HTTP transfer.
 
void setFileName (const char *filename)
 Changes the file name for subsequent read/write operations.
 
void setSchemaFileName (const char *name)
 Call this member to specify a custom schema file name for validating the XML file.
 
bool updateMethodByName (const char *name, const ms_crosslinking_method *method)
 Update the information for a specific method.
 
bool updateMethodByNumber (const int idx, const ms_crosslinking_method *method)
 Update the information for a specific method.
 
std::string validateDocument () const
 Validates the whole document against schema and returns errors as a string.
 

Static Public Member Functions

static std::string getDefaultSchemaFileName ()
 Returns the default schema filename (no path)
 

Detailed Description

This class represents the file crosslinking.xml.

The crosslinking configuration file contains definitions for crosslinking methods. The method comprises settings such as intact vs cleavable linker, which protein accessions to intralink or interlink and various method-specific filters and settings. The file can be created from scratch, read from a disk file or retrieved from a remote location (HTTP).

After reading a file and before using the object check validity by calling isValid() and retrieve error descriptions with getLastErrorString() if not valid. Similarly, after writing out the file, isValid() can be used to check if the file has been created correctly and is valid for further use.

Constructor & Destructor Documentation

◆ ms_crosslinking_configfile() [1/2]

ms_crosslinking_configfile ( const char *  fileName,
const char *  schemaFileName,
const ms_connection_settings cs = 0,
bool  useSchema = true 
)

Immediate action constructor that reads the XML file with the given name.

An instance of this class is normally created using this form of the constructor.

Parameters
fileNamerepresents either local file name (for example, "C:/crosslinking.xml") or a fully formed URL such as http://www.matrixscience.com/cgi . The filename may use backslashes or forward slashes on Windows and spaces in file or directory names are allowed.
schemaFileNameis a local file name for the schema (for example, "C:/crosslinking_2.xsd"). The schema must be a local file – it cannot be accessed using HTTP. The schema filename may use backslashes or forward slashes on Windows and spaces in file or directory names are allowed.
csa connection settings object for downloading the file from a Mascot server. This should contain a sessionID and optionally the proxy server settings. For a local file cs is not required and will be ignored.
useSchemaspecify whether it should use a xsd schema validator, true by default

◆ ms_crosslinking_configfile() [2/2]

Copying constructor.

Parameters
srcanother instance of this class to copy the content from.

Member Function Documentation

◆ appendErrors()

void appendErrors ( const ms_errors src)
inherited

Copies all errors from another instance and appends them at the end of own list.

Parameters
srcThe object to copy the errors across from. See Maintaining object references: two rules of thumb.

◆ appendMethod()

void appendMethod ( const ms_crosslinking_method elem)

Adds a new method at the end of the list.

Creates a new method object, copies all content from the object supplied as a parameter and adds it at the end of the methods list.

Parameters
eleman instance of the method object to copy content from.

◆ clearAllErrors()

void clearAllErrors ( )
inherited

Remove all errors from the current list of errors.

The list of 'errors' can include fatal errors, warning messages, information messages and different levels of debugging messages.

All messages are accumulated into a list in this object, until clearAllErrors() is called.

See Error Handling.

See also
isValid(), getLastError(), getLastErrorString(), getErrorHandler()
Examples
common_error.cpp, resfile_error.cpp, and resfile_summary.cpp.

◆ copyFrom() [1/2]

void copyFrom ( const ms_crosslinking_configfile right)

Copies all the information from another instance.

Parameters
rightanother instance of this class to copy the content from.

◆ copyFrom() [2/2]

void copyFrom ( const ms_errors right)
inherited

Use this member to make a copy of another instance.

Parameters
rightis the source to initialise from

◆ defaultValues()

void defaultValues ( )
virtual

Re-initialises the instance.

After calling this method, all internal values will be reset to their defaults, as if the object had been freshly created with the default constructor.

This method, however, doesn't change file name, schema location and connection settings. If a complete cleanup is required, you need to do three additional calls:

   crosslinking_configfile.setFileName(""); 
   crosslinking_configfile.setSchemaFileName("");
   crosslinking_configfile.setConnectionSetting(ms_connection_settings());

◆ deleteMethodByName()

bool deleteMethodByName ( const char *  name)

Remove an method from the list in memory.

Parameters
namename of the method for deletion.
Returns
TRUE if the method has been found and successfully deleted and FALSE otherwise.

◆ deleteMethodByNumber()

bool deleteMethodByNumber ( const int  idx)

Remove an method from the list in memory.

Parameters
idxnumber of the method for deletion from 0 to (getNumberOfMethods() - 1).
Returns
TRUE if the method has been found and successfully deleted and FALSE otherwise.

◆ getDefaultSchemaFileName()

std::string getDefaultSchemaFileName ( )
static

Returns the default schema filename (no path)

Static method to return the filename of the currently used schema

Returns
Returns "crosslinking_2.xsd" (at version 2.6.1)

◆ getErrorHandler()

const ms_errs * getErrorHandler ( ) const
inherited

Retrive the error object using this function to get access to all errors and error parameters.

See Error Handling.

Returns
Constant pointer to the error handler
See also
isValid(), getLastError(), getLastErrorString(), clearAllErrors(), getErrorHandler()
Examples
common_error.cpp, and http_helper_getstring.cpp.

◆ getFileName()

std::string getFileName ( ) const

Returns the current file name.

Returns
currently set file location (not necessarily the location from which the current content has been read).

◆ getLastError()

int getLastError ( ) const
inherited

Return the error description of the last error that occurred.

All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.

See Error Handling.

See also
isValid(), getLastErrorString(), clearAllErrors(), getErrorHandler()
Returns
the error number of the last error, or 0 if there have been no errors.

◆ getLastErrorString()

std::string getLastErrorString ( ) const
inherited

Return the error description of the last error that occurred.

All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.

Returns
Most recent error, warning, information or debug message

See Error Handling.

See also
isValid(), getLastError(), clearAllErrors(), getErrorHandler()
Examples
common_error.cpp, config_enzymes.cpp, config_fragrules.cpp, config_license.cpp, config_mascotdat.cpp, config_masses.cpp, config_modfile.cpp, config_procs.cpp, config_quantitation.cpp, config_taxonomy.cpp, http_helper_getstring.cpp, and tools_aahelper.cpp.

◆ getMethodByName()

const ms_crosslinking_method * getMethodByName ( const char *  name) const

Returns an method object by its name or NULL in case of not found.

Parameters
namea unique name of the method.
Returns
a read-only pointer to an method object. See Maintaining object references: two rules of thumb.

◆ getMethodByNumber()

const ms_crosslinking_method * getMethodByNumber ( const int  idx) const

Returns an method object by its number.

Parameters
idxnumber of the method from 0 to (getNumberOfMethods() - 1).
Returns
a read-only pointer to an method object. See Maintaining object references: two rules of thumb.

◆ getNumberOfMethods()

int getNumberOfMethods ( ) const

Returns a number of methods currently held in memory.

Returns
total number of methods in the configuration file.

◆ getSchemaFileName()

std::string getSchemaFileName ( ) const

Returns the current schema file name that is used to validate the XML file.

Returns
currently set file location (not necessarily the location from which the current content has been read).

◆ isValid()

bool isValid ( ) const
inherited

◆ operator=()

Assignment operator for C++ applications.

Parameters
rightanother instance of this class to copy the content from.
Returns
reference to the current object

◆ read_buffer()

void read_buffer ( const char *  buffer)

Reads configuration information from a string buffer.

This method is useful when reading configuration information from a mascor result file. Old content of the object will be removed and substituted with the information read from the buffer.

Parameters
bufferstring buffer that contains a valid xml-document. It can be a document with just one modification in it, or only with amino acid masses.

◆ read_file()

void read_file ( )

Reads configuration information from the XML file.

Downloads the file if necessary from the Crosslinking web site and parses it. Check for errors before using any other methods for retrieving content.

◆ save_buffer()

std::string save_buffer ( bool  validateAgainstSchema = true)

Creates a string representation of the XML document with all the content of the object.

Creates a valid XML document and returns it as a string which can be used, for example, for writing out configuration information to mascot result file.

To produce a 'file' that validates against the schema, it is not sufficient to add, for example, just a modification because this will be missing keyrefs to elements and termini building 'bricks'.

If you choose not to validate against the schema, then it is sufficient to just output, say, a single modification.

Parameters
validateAgainstSchemaspecifies whether to validate against the schema. If true and the schema file exists and the resulting XML fails to validate, then an empty string will be returned and the errors will indicate why it failed to validate.
Returns
XML document with the object content.

◆ save_file()

void save_file ( )

Saves configuration information in the XML file (not mod_file).

Check for errors after calling this method to see if the operation has been successful or to get any schema validation errors. If the document is not valid it is going to be saved anyway unless there are other problems.

If you want to validate document without actually saving it use validateDocument().

◆ setConnectionSettings()

void setConnectionSettings ( const ms_connection_settings cs)

Sets the sessionID and proxy server for use with an HTTP transfer.

This value would normally be passed in the constructor.

Parameters
csis the new connection settings.

◆ setFileName()

void setFileName ( const char *  name)

Changes the file name for subsequent read/write operations.

Calling this method does not mean an immediate update on disk. Use either read_file() or save_file() for that.

Parameters
namea new file location.

◆ setSchemaFileName()

void setSchemaFileName ( const char *  name)

Call this member to specify a custom schema file name for validating the XML file.

Parameters
namea new file location (if empty default value will be assigned).

◆ updateMethodByName()

bool updateMethodByName ( const char *  name,
const ms_crosslinking_method method 
)

Update the information for a specific method.

Parameters
namename of the method for updating.
methodan object to copy the content from.
Returns
TRUE if the method has been found and successfully updated and FALSE otherwise.

◆ updateMethodByNumber()

bool updateMethodByNumber ( const int  idx,
const ms_crosslinking_method method 
)

Update the information for a specific method.

Parameters
idxnumber of the method for updating from 0 to (getNumberOfMethods() - 1).
methodan object to copy the content from.
Returns
TRUE if the method has been found and successfully updated and FALSE otherwise.

◆ validateDocument()

std::string validateDocument ( ) const

Validates the whole document against schema and returns errors as a string.

This method doesn't attempt to store the document anywhere and doesn't make the object invalid. Also, no errors are stored. Therefore, this method can be called as many times as necessary without any consequences.

All validation errors will be returned back as a string. However, the XML parser will describe errors in terms of row and column numbers as if the document was actually saved in a file.

Returns
validation errors as a string or an empty string if there are no errors detected.

The documentation for this class was generated from the following files: