Matrix Science header
Public Member Functions

ms_taxonomytree Class Reference
[Mascot configuration files module]

The complete taxonomy tree as built from one or more files such as nodes.dmp. More...

#include <ms_taxonomyrules.hpp>

Inheritance diagram for ms_taxonomytree:
Inheritance graph
[legend]
Collaboration diagram for ms_taxonomytree:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ms_taxonomytree (const ms_taxonomyrules *taxonomyRules, const char *taxonomyDirectory="../taxonomy", const bool useIndex=true, const bool createList=false, const char *preparingDirectory="../taxonomy/preparing", const char *oldDirectory="../taxonomy/old")
 Create a taxonomy tree based on the rules specified in mascot.dat.
 ms_taxonomytree (const ms_taxonomytree &src)
 Copying constructor.
 ~ms_taxonomytree ()
 Destructor.
void appendErrors (const ms_errors &src)
 Copies all errors from another instance and appends them at the end of own list.
void clearAllErrors ()
 Remove all errors from the current list of errors.
void copyFrom (const ms_taxonomytree *right)
 Can be used to create a copy of another instance.
void copyFrom (const ms_errors *right)
 Use this member to make a copy of another instance.
const ms_errsgetErrorHandler () const
 Retrive the error object using this function to get access to all errors and error parameters.
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.
bool getParent (const int id, int &ttParent, int &ttGenTable) const
 Return the parent id and translation table id for a species.
TAX_TREE_NODES * getTaxIDArray ()
 Return a raw array of TAX_TREE_NODE values, with the array index being the id.
bool isIncludedIn (const int id, const ms_taxonomychoice *choice) const
 Return true if the taxonomy id is included in the choice.
bool isSpeciesDescendantOf (const int parentID, const int id) const
 Determine if a particular id is a child of the parentID.
bool isValid () const
 Call this function to determine if there have been any errors.
ms_taxonomytreeoperator= (const ms_taxonomytree &right)
 Assignment operator for C++ client applications.

Detailed Description

The complete taxonomy tree as built from one or more files such as nodes.dmp.

Used for determining the taxonomy lineage. This class is used to load all of the files specified in a specified taxonomy section in mascot.dat, for example:

     NodesFiles          NCBI:nodes.dmp, NCBI:merged.dmp
     

Index files are created using ms_tinycdb to improve performance in cases where a moderate number of parent id's are required. Index files are created in the same directory as the text files, with an additional 'extension' of ".cdb". Error or warning messages in ms_tinycdb are concatenated into the ms_taxonomytree object. If, for example, the process does not have write access to the directory with the taxonomy files , then an error ms_errs:: is generated, but the object is still valid and will continue with just the text files.

Other possible errors include: ms_errs::ERR_MSP_TAXONOMY_CONFLICT_PARENTS ms_errs::ERR_MSP_TAXONOMY_INVALID_NODE_FILE ms_errs::ERR_MSP_TAXONOMY_MISSING_NODE_FILE

The nodes.dmp file also contains the genetic code translation table id to be used when translating from nucleic acid to protein.

Example code to see if Homo Sapiens (9606) are mammals (40674):

     my $datfile = new msparser::ms_datfile("../config/mascot.dat");
     my $taxonomy_rules = $datfile->getTaxonomyRules(3);
     my $tree = new msparser::ms_taxonomytree($taxonomy_rules);
     if ($tree->isValid()) {
       my $human = 9606;
       my $mammalia = 40674;
       if ($tree->isSpeciesDescendantOf($mammalia, $human)) {
         print "Indeed, we are mammals\n";
       }
     }
     

Constructor & Destructor Documentation

ms_taxonomytree ( const ms_taxonomyrules taxonomyRules,
const char *  taxonomyDirectory = "../taxonomy",
const bool  useIndex = true,
const bool  createList = false,
const char *  preparingDirectory = "../taxonomy/preparing",
const char *  oldDirectory = "../taxonomy/old" 
)

Create a taxonomy tree based on the rules specified in mascot.dat.

The complete taxonomy tree as built from one or more files such as nodes.dmp

Parameters:
taxonomyRulescontains the list of NodesFiles specified in the taxonomy section of mascot.dat. These files are all loaded by this constructor. The names are retrieved using ms_taxonomyrules::getNodesFile
taxonomyDirectoryspecifies the directory to look in for the files. The names in mascot.dat do not normally include path information since the files are generally in the ../taxonomy directory
useIndexwill normally be set to true. If just a handful of 'parent ids' are required, then it is most efficient to use the index files. See getTaxIDArray() for a situation where this should be set to false.
createListwill normally be set to false. It is used to create the list of nodes in memory even if the cache file is used.
preparingDirectoryoptional parameter to specify a directory to look for new files and create temporary index files. Once the index files have been created, the new file and the created index files are moved to taxonomyDirectory. If this parameter is an empty string, or if there are no taxonomy files in this directory, new files will be looked for in taxonomyDirectory instead, and the index files will be created directly in taxonomyDirectory.
oldDirectoryoptional parameter to archive existing files once index files have been created for a new file. If this parameter is an empty string, no archiving will be done.

Member Function Documentation

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.
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.
void copyFrom ( const ms_taxonomytree right )

Can be used to create a copy of another instance.

Useful from Perl or scripting languages

Parameters:
rightis the object to copy from
void copyFrom ( const ms_errors right ) [inherited]

Use this member to make a copy of another instance.

Parameters:
rightis the source to initialise from
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.
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.

Reimplemented in ms_mascotresfile.

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()

Reimplemented in ms_mascotresfile.

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.
bool getParent ( const int  id,
int &  ttParent,
int &  ttGenTable 
) const

Return the parent id and translation table id for a species.

See Multiple return values in Perl, Java, Python and C#.

Parameters:
[in]idis the NCBI taxonomy id for which to find the parent and translation table.
[out]ttParentis the parent id. This will be set to 0 if an entry is not found for id.
[out]ttGenTableis the genetic code translation table to be used for converting nucleic acid sequences to protein sequences.
Returns:
false if the id is < 1 or greater than the number of entries or if the id is not found in any of the tables.
ms_taxonomytree::TAX_TREE_NODES * getTaxIDArray (  )

Return a raw array of TAX_TREE_NODE values, with the array index being the id.

This function will only return a non zero value if the useIndex value passed to the constructor is set to false.

The calling function should not call delete on the pointer. The vector is deleted when the ms_taxonomytree object is deleted.

Returns:
a pointer to the taxonomy tree nodes or NULL
bool isIncludedIn ( const int  id,
const ms_taxonomychoice choice 
) const

Return true if the taxonomy id is included in the choice.

For example, take the definition of "Other Mammalia":

   Title:. . . . . . . . . . . . . . Other mammalia
   Include: 40674
   Exclude: 9443, 9989
 

If you pass 9606 (Human) and a choice of "Other Mammalia", this function would return false, because in this case, 9606 is part of 9443 (Primates).

Parameters:
idis the taxonomy id
choiceis the return from calling ms_taxonomyfile::getEntryByName
Returns:
true if taxonomy id is included in taxonomy choice, false otherwise
bool isSpeciesDescendantOf ( const int  parentID,
const int  id 
) const

Determine if a particular id is a child of the parentID.

Parameters:
parentIDis the taxonomy id of the parent
idis the taxonomy id to be tested
Returns:
true if the taxonomy is a descendent of the parentID
bool isValid (  ) const [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.

Returns:
True if no fatal error occured
See also:
getLastError(), getLastErrorString(), 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, peptide_list.cpp, resfile_summary.cpp, and tools_aahelper.cpp.
ms_taxonomytree & operator= ( const ms_taxonomytree right )

Assignment operator for C++ client applications.

Cannot be used from scripting languages

Parameters:
rightis the object to copy from
Returns:
a reference to 'this'

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

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