This class represents the file crosslinking.xml
.
More...
#include <ms_crosslinking_configfile.hpp>
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_errs * | getErrorHandler () 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_method * | getMethodByName (const char *name) const |
Returns an method object by its name or NULL in case of not found. | |
const ms_crosslinking_method * | getMethodByNumber (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_configfile & | operator= (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) | |
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.
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.
fileName | represents 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. |
schemaFileName | is 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. |
cs | a 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. |
useSchema | specify whether it should use a xsd schema validator, true by default |
ms_crosslinking_configfile | ( | const ms_crosslinking_configfile & | src | ) |
Copying constructor.
src | another instance of this class to copy the content from. |
|
inherited |
Copies all errors from another instance and appends them at the end of own list.
src | The object to copy the errors across from. See Maintaining object references: two rules of thumb. |
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.
elem | an instance of the method object to copy content from. |
|
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.
void copyFrom | ( | const ms_crosslinking_configfile * | right | ) |
Copies all the information from another instance.
right | another instance of this class to copy the content from. |
|
inherited |
Use this member to make a copy of another instance.
right | is the source to initialise from |
|
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());
bool deleteMethodByName | ( | const char * | name | ) |
Remove an method from the list in memory.
name | name of the method for deletion. |
bool deleteMethodByNumber | ( | const int | idx | ) |
Remove an method from the list in memory.
idx | number of the method for deletion from 0 to (getNumberOfMethods() - 1). |
|
static |
Returns the default schema filename (no path)
Static method to return the filename of the currently used schema
|
inherited |
Retrive the error object using this function to get access to all errors and error parameters.
See Error Handling.
std::string getFileName | ( | ) | const |
Returns the current file name.
|
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.
|
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.
const ms_crosslinking_method * getMethodByName | ( | const char * | name | ) | const |
Returns an method object by its name or NULL in case of not found.
name | a unique name of the method. |
const ms_crosslinking_method * getMethodByNumber | ( | const int | idx | ) | const |
Returns an method object by its number.
idx | number of the method from 0 to (getNumberOfMethods() - 1). |
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.
|
inherited |
Call this function to determine if there have been any errors.
This will return true unless there have been any fatal errors.
See Error Handling.
ms_crosslinking_configfile & operator= | ( | const ms_crosslinking_configfile & | right | ) |
Assignment operator for C++ applications.
right | another instance of this class to copy the content from. |
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.
buffer | string buffer that contains a valid xml-document. It can be a document with just one modification in it, or only with amino acid masses. |
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.
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.
validateAgainstSchema | specifies 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. |
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().
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.
cs | is the new connection settings. |
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.
name | a new file location. |
void setSchemaFileName | ( | const char * | name | ) |
Call this member to specify a custom schema file name for validating the XML file.
name | a new file location (if empty default value will be assigned). |
bool updateMethodByName | ( | const char * | name, |
const ms_crosslinking_method * | method | ||
) |
Update the information for a specific method.
name | name of the method for updating. |
method | an object to copy the content from. |
bool updateMethodByNumber | ( | const int | idx, |
const ms_crosslinking_method * | method | ||
) |
Update the information for a specific method.
idx | number of the method for updating from 0 to (getNumberOfMethods() - 1). |
method | an object to copy the content from. |
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.