Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FragmentCandidate.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/frag_picker/FragmentCandidate.hh
11 /// @brief Something that might become a fragment if its scores will be good enough
12 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
13 
14 #ifndef INCLUDED_protocols_frag_picker_FragmentCandidate_hh
15 #define INCLUDED_protocols_frag_picker_FragmentCandidate_hh
16 
17 // type headers
18 #include <core/types.hh>
19 
20 // package headers
27 #include <utility/pointer/ReferenceCount.hh>
28 
30 #include <utility/vector1.hh>
31 #include <ObjexxFCL/format.hh>
32 
33 
34 namespace protocols {
35 namespace frag_picker {
36 
37 using namespace core;
38 using namespace core::fragment;
39 
40 using ObjexxFCL::fmt::F;
41 using ObjexxFCL::fmt::I;
42 
44  VallProviderOP, Size max_nfrags_per_pos = 900000000);
45 
46 /// @brief Vector candidate says which X-mer from vall fits to a query sequence
47 /// @detailed Scores for a given fragment are stored separately in a FragmentScoreMap object
48 /// Therefore fragment containers hold std::pair<FragmentCandidateOP,FragmentScoreMapOP>
49 ///
51 public:
52 
53  FragmentCandidate(Size queryPosition, Size inChunkPosition,
54  VallChunkOP chunk, Size fragmentLength) :
55  chunk_(chunk) {
56 
57  assert(queryPosition>0);
58  assert(inChunkPosition>0);
59  queryResidueIndex_ = queryPosition;
60  vallResidueIndex_ = inChunkPosition;
61  fragmentLength_ = fragmentLength;
62  pool_name_ = NULL;
63  }
64 
65  virtual ~FragmentCandidate() { delete pool_name_; }
66 
67  /// @brief returns a pointer to the original chunk from vall the fragment comes from
68  inline VallChunkOP get_chunk() const {
69  return chunk_;
70  }
71 
72  /// @brief returns a given residue from this fragment
73  /// @detailed the irgument is in the range [1,fragmentLength]
74  inline VallResidueOP get_residue(Size whichOne) const {
75  runtime_assert( chunk_ );
76  runtime_assert( whichOne >= 1 && whichOne <= fragmentLength_ );
77  return chunk_->at(whichOne + vallResidueIndex_ - 1);
78  }
79 
80 
81  /// @brief creates a new string object that contains a sequence of this fragment
82  inline std::string sequence() { return chunk_->get_sequence().substr(vallResidueIndex_-1, fragmentLength_); }
83 
84  /// @brief returns an integer key identifying a fragment
85  inline Size key() const {
86  return chunk_->at(vallResidueIndex_)->key();
87  }
88 
89  /// @brief returns a PDB id of a protein from which the fragment has been extracted
90  inline std::string get_pdb_id() const {
91  return chunk_->get_pdb_id();
92  }
93 
94  /// @brief returns a chain id of a protein from which the fragment has been extracted
95  inline char get_chain_id() const {
96  return chunk_->get_chain_id();
97  }
98 
99  /// @brief returns the index of a very first residue in a query sequence that is covered by this fragment
101  return queryResidueIndex_;
102  }
103 
104  /// @brief returns the index of a very first residue in a Vall chunk that is covered by this fragment
105  inline Size get_first_index_in_vall() const {
106  return vallResidueIndex_;
107  }
108 
109  /// @brief returns a vall index of a middle residue in this fragment
110  /// @returns a position of the middle residue of this fragment in the vall sequence
112  return ( fragmentLength_/2 + 1) + ( vallResidueIndex_ ) - 1;
113  }
114 
115  /// @brief returns a query index of a middle residue in this fragment
116  /// @returns a position of the middle residue of this fragment in the query sequence
118  return ( fragmentLength_/2 + 1) + ( queryResidueIndex_ ) - 1;
119  }
120 
121  /// @brief returns the middle residue of this fragment candidate
123  return get_residue( fragmentLength_/2 + 1);
124  }
125  /// @brief returns secondary structure assigned to the middle residue of this fragment candidate
126  /// @returns secondary structure of the middle residue of this fragment, as extracted from Vall data
127  inline char get_middle_ss() const {
128 
129  return get_residue( fragmentLength_/2 + 1 )->ss();
130  }
131 
132  /// @brief returns the length of this fragment
133  inline Size get_length() const {
134  return fragmentLength_;
135  }
136 
138 
139  AnnotatedFragDataOP fragdata = new AnnotatedFragData(get_pdb_id(),
140  queryResidueIndex_);
141 
142  for (Size i = 1; i <= fragmentLength_; ++i) {
143  fragdata->add_residue(
144  chunk_->at(i + vallResidueIndex_ - 1)->bbtorsion_srfd());
145  }
146 
147  if (fragdata->size() > 0)
148  fragdata->set_valid();
149 
150  return fragdata;
151  }
152 
153  /// @brief Prints fragment data, the output can be directly loaded to minirosetta
154  void print_fragment(std::ostream& out, scores::FragmentScoreMapOP sc = NULL, scores::FragmentScoreManagerOP ms = NULL);
155 
156  /// @brief Prints fragment sequence, used for generating structure based sequence profiles
157  void print_fragment_seq(std::ostream& out);
158 
159  /// @brief Prints fragment to silent struct
160  void output_silent(core::io::silent::SilentFileData & sfd, const std::string sequence, const std::string silent_file_name, const std::string tag, scores::FragmentScoreMapOP sc, scores::FragmentScoreManagerOP ms);
161 
162  inline void set_pool_name(std::string pool_name) {
163  if(pool_name_!=NULL) delete pool_name_;
164  pool_name_= new std::string(pool_name);
165  }
166 
168  if(pool_name_==NULL) return unknown_pool_name_;
169  else return *pool_name_;
170  }
171 
172  bool same_chain( FragmentCandidateCOP fr );
173 
174 protected:
179 private:
182 };
183 
184 inline std::ostream& operator<<(std::ostream& out, FragmentCandidate const& fr) {
185  out << fr.get_pdb_id() << " " << fr.get_first_index_in_vall() << " : "
186  << fr.get_first_index_in_query() << " : ";
187  return out;
188 }
189 
190 inline std::ostream& operator<<(std::ostream& out, std::pair<
192 
193  out << pair.first->get_pdb_id() << " "
194  << pair.first->get_first_index_in_vall() << " : "
195  << pair.first->get_first_index_in_query() << " :";
196  utility::vector1<Real> c = pair.second->get_score_components();
197  for (Size i = 1; i <= c.size(); i++)
198  out << " " << c.at(i);
199  return out;
200 }
201 
202 } // frag_picker
203 } // protocols
204 
205 
206 #endif /* INCLUDED_protocols_frag_picker_FragmentCandidate_HH */