Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
ControlledVocabulary.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2017.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Marc Sturm, Andreas Bertsch, Mathias Walzer $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_FORMAT_CONTROLLEDVOCABULARY_H
36 #define OPENMS_FORMAT_CONTROLLEDVOCABULARY_H
37 
38 #include <OpenMS/DATASTRUCTURES/ListUtils.h> // StringList
42 
43 #include <set>
44 
45 namespace OpenMS
46 {
55  class OPENMS_DLLAPI ControlledVocabulary
56  {
57  friend OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const ControlledVocabulary& cv);
58 
59 public:
61  struct OPENMS_DLLAPI CVTerm
62  {
64  enum XRefType
65  {
66  XSD_STRING = 0, // xsd:string A string
67  XSD_INTEGER, // xsd:integer Any integer
68  XSD_DECIMAL, // xsd:decimal Any real number
69  XSD_NEGATIVE_INTEGER, // xsd:negativeInteger Any negative integer
70  XSD_POSITIVE_INTEGER, // xsd:positiveInteger Any integer > 0
71  XSD_NON_NEGATIVE_INTEGER, // xsd:nonNegativeInteger Any integer >= 0
72  XSD_NON_POSITIVE_INTEGER, // xsd:nonPositiveInteger Any integer < 0
73  XSD_BOOLEAN, // xsd:boolean True or false
74  XSD_DATE, // xsd:date An XML-Schema date
75  XSD_ANYURI, // xsd:anyURI uniform resource identifier
76  NONE
77  };
78 
79  static String getXRefTypeName(XRefType type);
80  //static bool isSearchEngineSpecificScore();
81  static bool isHigherBetterScore(ControlledVocabulary::CVTerm term);
82 
85  std::set<String> parents;
86  std::set<String> children;
87  bool obsolete;
93  std::set<String> units;
94 
96  CVTerm();
97 
98  CVTerm(const CVTerm& rhs);
99 
100  CVTerm& operator=(const CVTerm& rhs);
101 
103  String toXMLString(const String& ref, const String& value = String("")) const;
104 
106  String toXMLString(const String& ref, const DataValue& value) const;
107 
108  };
109 
112 
114  virtual ~ControlledVocabulary();
115 
117  const String& name() const;
118 
125  void loadFromOBO(const String& name, const String& filename);
126 
128  bool exists(const String& id) const;
129 
131  bool hasTermWithName(const String& name) const;
132 
138  const CVTerm& getTerm(const String& id) const;
139 
145  const CVTerm& getTermByName(const String& name, const String& desc = "") const;
146 
147 
149  const Map<String, CVTerm>& getTerms() const;
150 
158  void getAllChildTerms(std::set<String>& terms, const String& parent) const;
159 
165  bool isChildOf(const String& child, const String& parent) const;
166 
167 protected:
173  bool checkName_(const String& id, const String& name, bool ignore_case = true);
174 
181  };
182 
184  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const ControlledVocabulary& cv);
185 
186 
187 } // namespace OpenMS
188 
189 #endif // OPENMS_FORMAT_CONTROLLEDVOCABULARY_H
Definition: ControlledVocabulary.h:68
Representation of a CV term.
Definition: ControlledVocabulary.h:61
A more convenient string class.
Definition: String.h:57
Map< String, CVTerm > terms_
Map from ID to CVTerm.
Definition: ControlledVocabulary.h:176
String id
Identifier.
Definition: ControlledVocabulary.h:84
Definition: ControlledVocabulary.h:75
StringList xref_binary
xref binary-data-type for the CV-term (list of all allowed data value types for the current binary da...
Definition: ControlledVocabulary.h:92
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Definition: ControlledVocabulary.h:74
StringList unparsed
Unparsed lines from the definition file.
Definition: ControlledVocabulary.h:90
bool obsolete
Flag that indicates of the term is obsolete.
Definition: ControlledVocabulary.h:87
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:57
Representation of a controlled vocabulary.
Definition: ControlledVocabulary.h:55
XRefType
define xsd types allowed in cv term to specify their value-type
Definition: ControlledVocabulary.h:64
Map< String, String > namesToIds_
Map from name to id.
Definition: ControlledVocabulary.h:178
std::set< String > units
unit accession ids, defined by relationship has units
Definition: ControlledVocabulary.h:93
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
XRefType xref_type
xref value-type for the CV-term
Definition: ControlledVocabulary.h:91
String name
if it is a score type, lookup has_order
Definition: ControlledVocabulary.h:83
StringList synonyms
List of synonyms.
Definition: ControlledVocabulary.h:89
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:74
std::set< String > parents
The parent IDs.
Definition: ControlledVocabulary.h:85
std::set< String > children
The child IDs.
Definition: ControlledVocabulary.h:86
Definition: ControlledVocabulary.h:73
Definition: ControlledVocabulary.h:67
String name_
Name set in the load method.
Definition: ControlledVocabulary.h:180
Map class based on the STL map (containing several convenience functions)
Definition: Map.h:51
String description
Term description.
Definition: ControlledVocabulary.h:88

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:21:59 using doxygen 1.8.13