ProteoWizard
ProteinList_DecoyGenerator.hpp
Go to the documentation of this file.
1 //
2 // $Id: ProteinList_DecoyGenerator.hpp 4010 2012-10-17 20:22:16Z chambm $
3 //
4 //
5 // Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu>
6 //
7 // Copyright 2010 Vanderbilt University - Nashville, TN 37232
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 //
13 // http://www.apache.org/licenses/LICENSE-2.0
14 //
15 // Unless required by applicable law or agreed to in writing, software
16 // distributed under the License is distributed on an "AS IS" BASIS,
17 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 // See the License for the specific language governing permissions and
19 // limitations under the License.
20 //
21 
22 
23 #ifndef _PROTEINLIST_DECOYGENERATOR_HPP_
24 #define _PROTEINLIST_DECOYGENERATOR_HPP_
25 
26 
29 #include <boost/cstdint.hpp>
30 
31 
32 namespace pwiz {
33 namespace analysis {
34 
35 
36 using namespace pwiz::proteome;
37 
38 
39 /// ProteinList decoy generator for creating decoy proteins on the fly
41 {
42  public:
43 
44  /// client-implemented generator predicate -- called during construction of
45  /// ProteinList_DecoyGenerator to create a decoy protein from a target protein
47  {
48  /// return a decoy protein based on an input target protein
49  virtual ProteinPtr generate(const Protein& protein) const = 0;
50 
51  /// return the string prefixed to a protein id to indicate it is a decoy
52  virtual const std::string& decoyPrefix() const {return decoyPrefix_;}
53 
54  virtual ~Predicate() {}
55 
56  protected:
57  std::string decoyPrefix_;
58  };
59 
60  typedef boost::shared_ptr<Predicate> PredicatePtr;
61 
62  ProteinList_DecoyGenerator(const ProteinListPtr& original, const PredicatePtr& predicate);
63 
64  /// \name ProteinList interface
65  //@{
66  virtual size_t size() const;
67  virtual size_t find(const std::string& id) const;
68  virtual ProteinPtr protein(size_t index, bool getSequence = true) const;
69  //@}
70 
71  private:
72  struct Impl;
73  boost::shared_ptr<Impl> impl_;
76 };
77 
78 
79 /// creates a reversed copy of every target protein with the specified decoy string prefixed to the id
81 {
82  public:
83  ProteinList_DecoyGeneratorPredicate_Reversed(const std::string& decoyPrefix);
84 
85  virtual ProteinPtr generate(const Protein& protein) const;
86 };
87 
88 
89 /// creates a randomly shuffled copy of every target protein with the specified decoy string prefixed to the id
91 {
92  public:
93  ProteinList_DecoyGeneratorPredicate_Shuffled(const std::string& decoyPrefix, boost::uint32_t randomSeed = 0u);
94 
95  virtual ProteinPtr generate(const Protein& protein) const;
96 
97  private:
98  struct Impl;
99  boost::shared_ptr<Impl> impl_;
100 };
101 
102 
103 } // namespace analysis
104 } // namespace pwiz
105 
106 
107 #endif // _PROTEINLIST_DECOYGENERATOR_HPP_