ProteoWizard
MzidPredicates.hpp
Go to the documentation of this file.
1 //
2 // $Id: MzidPredicates.hpp 2820 2011-06-27 22:51:16Z chambm $
3 //
4 //
5 // Origional author: Robert Burke <robert.burke@proteowizard.org>
6 //
7 // Copyright 2010 Spielberg Family Center for Applied Proteomics
8 // University of Southern California, Los Angeles, California 90033
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 //
14 // http://www.apache.org/licenses/LICENSE-2.0
15 //
16 
17 // Unless required by applicable law or agreed to in writing, software
18 // distributed under the License is distributed on an "AS IS" BASIS,
19 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 // See the License for the specific language governing permissions and
21 // limitations under the License.
22 //
23 
24 #ifndef MZID_MZIDPREDICATE_HPP
25 #define MZID_MZIDPREDICATE_HPP
26 
27 
28 #include "IdentData.hpp"
29 #include <string>
30 #include <boost/shared_ptr.hpp>
31 #include <boost/algorithm/string/predicate.hpp>
32 
33 namespace pwiz {
34 namespace identdata {
35 
36 template<typename T>
37 struct id_p
38 {
39  const std::string id;
40 
41  id_p(const std::string id) : id(id) {}
42 
43  bool operator()(const boost::shared_ptr<T>& t) const
44  {
45  return t->id == id;
46  }
47 };
48 
49 struct software_p
50 {
51  CVID id;
52 
53  software_p(const CVID id) : id(id) {}
54 
55  bool operator()(const AnalysisSoftwarePtr p)
56  {
57  bool result = false;
58 
59  if (p.get())
60  result = p->softwareName.hasCVParam(id);
61 
62  return result;
63  }
64 };
65 
66 struct sequence_p
67 {
68  const std::string seq;
69 
70  sequence_p(const std::string& seq) : seq(seq) {}
71 
72  bool operator()(const PeptidePtr& p) const
73  {
74  return (p->peptideSequence == seq);
75  }
76 };
77 
78 struct seq_p
79 {
80  const std::string seq;
81 
82  seq_p(const std::string& seq) : seq(seq) {}
83 
84  bool operator()(const DBSequencePtr& dbs) const
85  {
86  return (dbs->seq == seq);
87  }
88 };
89 
91 {
92  const std::string seq;
93  const std::string accession;
94 
95  dbsequence_p(const std::string& seq,
96  const std::string accession)
97  : seq(seq), accession(accession) {}
98 
99  bool operator()(const DBSequencePtr& p) const
100  {
101  return boost::iequals(p->seq, seq) &&
102  boost::iequals(p->accession, accession);
103  }
104 };
105 
107 {
108  bool operator()(ContactPtr contact)
109  {
110  return typeid(contact.get()).name() == typeid(Organization*).name();
111  }
112 };
113 
114 struct person_p
115 {
116  bool operator()(ContactPtr contact)
117  {
118  return typeid(contact.get()).name() == typeid(Person*).name();
119  }
120 };
121 
122 } // namespace pwiz
123 } // namespace identdata
124 
125 #endif // MZID_MZIDPREDICATE_HPP
126