ProteoWizard
PeptideID.hpp
Go to the documentation of this file.
1 //
2 // $Id$
3 //
4 //
5 // Original author: Darren Kessner <darren@proteowizard.org>
6 // Modifying author: Robert Burke <Robert.Burke@cshs.org>
7 //
8 // Copyright 2008 Spielberg Family Center for Applied Proteomics
9 // Cedars-Sinai Medical Center, Los Angeles, California 90048
10 //
11 // Licensed under the Apache License, Version 2.0 (the "License");
12 // you may not use this file except in compliance with the License.
13 // You may obtain a copy of the License at
14 //
15 // http://www.apache.org/licenses/LICENSE-2.0
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 
25 #ifndef _PEPTIDEID_HPP_
26 #define _PEPTIDEID_HPP_
27 
28 
30 #include <boost/shared_ptr.hpp>
31 #include <boost/iterator/iterator_facade.hpp>
32 #include <string>
33 #include <vector>
34 #include <iterator>
35 
36 namespace pwiz {
37 namespace peptideid {
38 
39 /// This is an interface for classes that allow access to data sources
40 /// of identified peptides.
41 
43 {
44 public:
45 
47  {
48  std::string nativeID;
49  double mz;
51 
53  Location(std::string nativeID, double retentionTimeSec, double mz)
54  : nativeID(nativeID), mz(mz), retentionTimeSec(retentionTimeSec)
55  {}
56  };
57 
59  {
60  std::string nativeID;
61  std::string sequence;
62  std::string protein_descr;
63  double mz;
65  double normalizedScore; // in [0,1]
66 
67  Record() : normalizedScore(0) {}
69  : nativeID(record.nativeID),
70  sequence(record.sequence),
71  protein_descr(record.protein_descr),
72  mz(record.mz),
73  retentionTimeSec(record.retentionTimeSec),
74  normalizedScore(record.normalizedScore)
75  {
76  }
77  };
78 
79  /**
80  * Interface for
81  */
83  virtual void increment() = 0;
84  virtual bool equal(const boost::shared_ptr<IteratorInternal>& li) const = 0;
85  virtual const PeptideID::Record& dereference() const = 0;
86  };
87 
88  /**
89  * Iterator for
90  */
91  class Iterator : public boost::iterator_facade<Iterator,
92  const PeptideID::Record,
93  boost::forward_traversal_tag>
94  {
95  public:
96  Iterator() {}
97  Iterator(const Iterator& it) : pimpl(it.pimpl) {}
98  Iterator(boost::shared_ptr<PeptideID::IteratorInternal> pimpl)
99  : pimpl(pimpl)
100  {}
101 
102  protected:
103  friend class boost::iterator_core_access;
104 
105  void increment() { pimpl->increment(); }
106 
107  bool equal(const PeptideID::Iterator& li) const
108  {
109  return pimpl->equal(li.pimpl);
110  }
111 
113  {
114  return pimpl->dereference();
115  }
116 
117  boost::shared_ptr<PeptideID::IteratorInternal> pimpl;
118  };
119 
120  virtual Record record(const Location& location) const = 0;
121 
122  virtual ~PeptideID() {}
123 
124  virtual Iterator begin() const = 0;
125 
126  virtual Iterator end() const = 0;
127 };
128 
130 {
131  bool operator()(const PeptideID::Record& a, const PeptideID::Record& b) const
132  {
133  return atof(a.nativeID.c_str()) < atof(b.nativeID.c_str());
134  }
135 };
136 
138 {
139 public:
140  bool operator()(const PeptideID::Location& a, const PeptideID::Location& b) const
141  {
142  return a.nativeID.compare(b.nativeID) < 0 && a.mz < b.mz && a.retentionTimeSec < b.retentionTimeSec;
143  }
144 };
145 
146 } // namespace peptideid
147 } // namespace pwiz
148 
149 #endif // _PEPTIDEID_HPP_
150 
pwiz::peptideid::PeptideID::Record::nativeID
std::string nativeID
Definition: PeptideID.hpp:60
pwiz::peptideid::PeptideID::Iterator::Iterator
Iterator()
Definition: PeptideID.hpp:96
pwiz::peptideid::PeptideID::Record::normalizedScore
double normalizedScore
Definition: PeptideID.hpp:65
pwiz::peptideid::location_less::operator()
bool operator()(const PeptideID::Location &a, const PeptideID::Location &b) const
Definition: PeptideID.hpp:140
pwiz::peptideid::PeptideID::IteratorInternal
Interface for.
Definition: PeptideID.hpp:82
pwiz
Definition: ChromatogramList_Filter.hpp:36
pwiz::peptideid::PeptideID::Location
Definition: PeptideID.hpp:47
pwiz::peptideid::PeptideID::Record::mz
double mz
Definition: PeptideID.hpp:63
pwiz::peptideid::location_less
Definition: PeptideID.hpp:138
pwiz::peptideid::nativeID_less::operator()
bool operator()(const PeptideID::Record &a, const PeptideID::Record &b) const
Definition: PeptideID.hpp:131
pwiz::peptideid::PeptideID::Record::sequence
std::string sequence
Definition: PeptideID.hpp:61
pwiz::peptideid::PeptideID::end
virtual Iterator end() const =0
PWIZ_API_DECL
#define PWIZ_API_DECL
Definition: Export.hpp:32
pwiz::peptideid::PeptideID::Location::Location
Location()
Definition: PeptideID.hpp:52
pwiz::peptideid::PeptideID::~PeptideID
virtual ~PeptideID()
Definition: PeptideID.hpp:122
pwiz::peptideid::PeptideID::Iterator::dereference
const PeptideID::Record & dereference() const
Definition: PeptideID.hpp:112
pwiz::peptideid::PeptideID::Location::retentionTimeSec
double retentionTimeSec
Definition: PeptideID.hpp:50
pwiz::peptideid::PeptideID::begin
virtual Iterator begin() const =0
Export.hpp
pwiz::peptideid::PeptideID
This is an interface for classes that allow access to data sources of identified peptides.
Definition: PeptideID.hpp:43
pwiz::peptideid::PeptideID::IteratorInternal::increment
virtual void increment()=0
pwiz::peptideid::PeptideID::Iterator
Iterator for.
Definition: PeptideID.hpp:94
pwiz::peptideid::PeptideID::Record::protein_descr
std::string protein_descr
Definition: PeptideID.hpp:62
pwiz::peptideid::PeptideID::Record::Record
Record(const Record &record)
Definition: PeptideID.hpp:68
pwiz::peptideid::PeptideID::Iterator::pimpl
boost::shared_ptr< PeptideID::IteratorInternal > pimpl
Definition: PeptideID.hpp:117
pwiz::peptideid::PeptideID::record
virtual Record record(const Location &location) const =0
pwiz::proteome::AminoAcid::Info::record
PWIZ_API_DECL const Record & record(Type type)
returns the amino acid's Record by type
pwiz::peptideid::PeptideID::Record
Definition: PeptideID.hpp:59
pwiz::peptideid::PeptideID::Record::retentionTimeSec
double retentionTimeSec
Definition: PeptideID.hpp:64
pwiz::peptideid::PeptideID::Iterator::equal
bool equal(const PeptideID::Iterator &li) const
Definition: PeptideID.hpp:107
pwiz::peptideid::PeptideID::IteratorInternal::equal
virtual bool equal(const boost::shared_ptr< IteratorInternal > &li) const =0
pwiz::chemistry::Ion::mz
double mz(double neutralMass, int protonDelta, int electronDelta=0, int neutronDelta=0)
Definition: Ion.hpp:78
pwiz::peptideid::PeptideID::Location::nativeID
std::string nativeID
Definition: PeptideID.hpp:48
pwiz::peptideid::PeptideID::Iterator::increment
void increment()
Definition: PeptideID.hpp:105
pwiz::peptideid::PeptideID::Location::mz
double mz
Definition: PeptideID.hpp:49
pwiz::peptideid::PeptideID::Location::Location
Location(std::string nativeID, double retentionTimeSec, double mz)
Definition: PeptideID.hpp:53
pwiz::peptideid::PeptideID::Iterator::Iterator
Iterator(const Iterator &it)
Definition: PeptideID.hpp:97
pwiz::peptideid::PeptideID::IteratorInternal::dereference
virtual const PeptideID::Record & dereference() const =0
pwiz::peptideid::nativeID_less
Definition: PeptideID.hpp:130
pwiz::peptideid::PeptideID::Iterator::Iterator
Iterator(boost::shared_ptr< PeptideID::IteratorInternal > pimpl)
Definition: PeptideID.hpp:98
pwiz::peptideid::PeptideID::Record::Record
Record()
Definition: PeptideID.hpp:67