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
36namespace pwiz {
37namespace peptideid {
38
39/// This is an interface for classes that allow access to data sources
40/// of identified peptides.
41
43{
44public:
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) {}
68 Record(const Record& record)
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:
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{
139public:
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
#define PWIZ_API_DECL
Definition Export.hpp:32
Iterator(boost::shared_ptr< PeptideID::IteratorInternal > pimpl)
Definition PeptideID.hpp:98
boost::shared_ptr< PeptideID::IteratorInternal > pimpl
const PeptideID::Record & dereference() const
bool equal(const PeptideID::Iterator &li) const
This is an interface for classes that allow access to data sources of identified peptides.
Definition PeptideID.hpp:43
virtual Record record(const Location &location) const =0
virtual Iterator end() const =0
virtual Iterator begin() const =0
bool operator()(const PeptideID::Location &a, const PeptideID::Location &b) const
virtual bool equal(const boost::shared_ptr< IteratorInternal > &li) const =0
virtual const PeptideID::Record & dereference() const =0
Location(std::string nativeID, double retentionTimeSec, double mz)
Definition PeptideID.hpp:53
Record(const Record &record)
Definition PeptideID.hpp:68
bool operator()(const PeptideID::Record &a, const PeptideID::Record &b) const