ProteoWizard
PeptideID_flat.hpp
Go to the documentation of this file.
1 //
2 // $Id: PeptideID_flat.hpp 3095 2011-11-01 21:12:23Z broter $
3 //
4 //
5 // Original author: Robert Burke <robert.burke@cshs.org>
6 //
7 // Copyright 2007 Spielberg Family Center for Applied Proteomics
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 #ifndef _PEPTIDEID_FLAT_HPP_
24 #define _PEPTIDEID_FLAT_HPP_
25 
26 #include <map>
27 #include <vector>
28 #include <string>
29 #include <iostream>
30 #include <boost/shared_ptr.hpp>
31 
33 #include "PeptideID.hpp"
34 
35 namespace pwiz {
36 namespace peptideid {
37 
39 {
40 public:
41  virtual ~FlatRecordBuilder() {}
42 
43  virtual PeptideID::Record build(const std::vector<std::string>& fields) const;
44 
45  virtual bool header() const;
46 
47  virtual double epsilon() const;
48 
49  virtual bool operator()(const PeptideID::Record& a, const PeptideID::Record& b) const;
50 
51  virtual bool operator()(const PeptideID::Record& a, const PeptideID::Location& ) const;
52 };
53 
55 {
56 public:
58 
59  virtual PeptideID::Record build(const std::vector<std::string>& fields) const;
60 
61  virtual bool header() const;
62 
63  virtual double epsilon() const;
64 
65  virtual bool operator()(const PeptideID::Record& a, const PeptideID::Record& b) const;
66 
67  virtual bool operator()(const PeptideID::Record& a, const PeptideID::Location& ) const;
68 };
69 
70 /// This class allows access to peptides listed in a flat tab
71 /// delimited text file
72 
73 /// A PeptideID_flat object is contructed with either the path to a
74 /// tab delimited file (*.txt/*.tab), or an std::istream open to
75 /// the beginning of a tab delimited file.
76 
78 {
79 public:
80  /// Constructor taking path to input file in std::string.
81  PeptideID_flat(const std::string& filename,
82  boost::shared_ptr<FlatRecordBuilder> builder =
83  boost::shared_ptr<FlatRecordBuilder>(new FlatRecordBuilder()));
84 
85  /// Constructor taking std::istream as input.
86  PeptideID_flat(std::istream* in,
87  boost::shared_ptr<FlatRecordBuilder> builder =
88  boost::shared_ptr<FlatRecordBuilder>(new FlatRecordBuilder()));
89 
90  /// Destructor.
91  virtual ~PeptideID_flat() {}
92 
93  /// Returns the Record object associated with the given nativeID.
94 
95  /// A range_error is thrown if the nativeID isn't associated with
96  /// a Record.
97  virtual Record record(const Location& location) const;
98 
99  virtual Iterator begin() const;
100  virtual Iterator end() const;
101 
102 private:
103  class Impl;
104  boost::shared_ptr<Impl> pimpl;
105 };
106 
107 } // namespace peptideid
108 } // namespace pwiz
109 
110 #endif // _PEPTIDEID_FLAT_HPP_