ProteoWizard
PeptideDatabase.hpp
Go to the documentation of this file.
1 //
2 // $Id: PeptideDatabase.hpp 1191 2009-08-14 19:33:05Z chambm $
3 //
4 //
5 // Original author: Darren Kessner <darren@proteowizard.org>
6 //
7 // Copyright 2006 Louis Warschaw Prostate Cancer Center
8 // Cedars Sinai Medical Center, Los Angeles, California 90048
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 // Unless required by applicable law or agreed to in writing, software
17 // distributed under the License is distributed on an "AS IS" BASIS,
18 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 // See the License for the specific language governing permissions and
20 // limitations under the License.
21 //
22 
23 
24 #ifndef _PEPTIDEDATABASE_HPP_
25 #define _PEPTIDEDATABASE_HPP_
26 
27 
29 #include <string>
30 #include <memory>
31 
32 
33 namespace pwiz {
34 namespace proteome {
35 
36 
37 #pragma pack(1)
39 {
40  int C;
41  int H;
42  int N;
43  int O;
44  int S;
45 
46  PeptideDatabaseFormula(int c=0, int h=0, int n=0, int o=0, int s=0)
47  : C(c), H(h), N(n), O(o), S(s)
48  {}
49 };
50 #pragma pack()
51 
52 
53 PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const PeptideDatabaseFormula& formula);
54 
55 
56 #pragma pack(1)
58 {
59  int id_ipi;
60  double abundance;
61  double mass;
64 
66  : id_ipi(0), abundance(1), mass(0), sequenceKey(0)
67  {}
68 };
69 #pragma pack()
70 
71 
72 PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const PeptideDatabaseRecord& record);
73 PWIZ_API_DECL bool operator==(const PeptideDatabaseFormula& r, const PeptideDatabaseFormula& s);
74 
75 
77 {
78  public:
79 
80  static std::auto_ptr<PeptideDatabase> create();
81  static std::auto_ptr<const PeptideDatabase> create(const std::string& filename);
82  virtual ~PeptideDatabase(){}
83 
84  virtual int size() const = 0;
85  virtual const PeptideDatabaseRecord* records() const = 0;
86  virtual std::string sequence(const PeptideDatabaseRecord& record) const = 0;
87 
88  virtual void append(const PeptideDatabaseRecord& record, const std::string& sequence = "") = 0;
89  //virtual void append(const std::string& sequence) = 0;
90  virtual void write(const std::string& filename) const = 0;
91 
92  // sortByMass() (rewriteStringTable)
93 
94  // iterator interface
96  iterator begin() const {return records();}
97  iterator end() const {return records() + size();}
98 
99  // range access (binary search algorithms assume database is sorted by mass)
100  iterator mass_lower_bound(double mass) const;
101  iterator mass_upper_bound(double mass) const;
102 };
103 
104 
105 } // namespace pwiz
106 } // namespace proteome
107 
108 
109 #endif // _PEPTIDEDATABASE_HPP_
110