25 #include <basic/Tracer.hh>
32 #include <utility/exit.hh>
33 #include <utility/io/izstream.hh>
36 #if defined(WIN32) || defined(__CYGWIN__)
50 static basic::Tracer
TR(
"protocols.frag_picker.VallProvider");
53 namespace frag_picker {
61 for (
Size i = 1; i <= chunks_.size(); ++i) {
63 if (c->get_pdb_id().compare(pdb_id) != 0)
65 if (c->get_chain_id() != chain_id)
67 for (
Size j = 1; j < c->size(); ++j) {
68 if (c->at(j)->resi() == residue_id)
73 TR.Warning <<
"Can't find chunk that contains the residue number "
74 << residue_id <<
" in a protein " << pdb_id <<
" in a chain "
75 << chain_id << std::endl;
83 TR.Debug <<
"looking for a pose for " << key << std::endl;
84 if (key.compare(cached_pose_id_) == 0)
87 TR.Debug <<
"caching a pose for >" << key <<
"< the previous key was: >"
88 << cached_pose_id_ <<
"< (" << key.compare(cached_pose_id_)
91 for (
Size i = 1; i <= source_chunk->size(); ++i) {
93 cached_pose_->set_phi(i, r->phi());
94 cached_pose_->set_psi(i, r->psi());
95 cached_pose_->set_omega(i, r->omega());
97 TR.Debug <<
" has " << source_chunk->size() <<
" residues." << std::endl;
99 cached_pose_id_.clear();
100 cached_pose_id_.assign(key);
110 TR.Debug <<
"looking for a profile for " << key << std::endl;
111 if (key.compare(cached_profile_id_) == 0)
112 return cached_profile_;
113 TR.Debug <<
"caching a sequence profile for >" << key
114 <<
"< the previous key was: >" << cached_profile_id_ <<
"< ("
115 << key.compare(cached_pose_id_) <<
")... ";
118 for (
Size i = 1; i <= source_chunk->size(); ++i) {
119 prof.push_back(source_chunk->at(i)->profile());
121 cached_profile_id_.clear();
122 cached_profile_id_.assign(key);
124 if (cached_profile_ == 0)
126 cached_profile_->profile(prof);
127 cached_profile_->sequence(source_chunk->get_sequence());
129 TR.Debug <<
" has " << cached_profile_->length() <<
" columns."
132 return cached_profile_;
141 for ( iter it = fns.begin(),
end = fns.end(); it !=
end; ++it ) {
142 vallChunksFromLibrary( *it );
149 utility::io::izstream stream(filename);
151 utility_exit_with_message(
"can't open file: " + filename );
154 getline(stream, line);
155 while(line[0] ==
'#') {
156 getline(stream, line);
158 while(getline(stream,line)) {
166 TR.Info <<
"vallChunksFromLibrary" << std::endl;
168 utility::io::izstream stream(filename);
170 utility_exit_with_message(
"can't open file: " + filename );
175 TR.Info <<
"Reading Vall library from " << filename <<
" ... startline: " << startline <<
" endline: " << endline << std::endl;
177 time_t time_start = time(NULL);
180 if(chunks_.size() > 0) {
181 VallChunkOP last_chunk = chunks_[ chunks_.size() ];
182 last_key = last_chunk->at( last_chunk->size() )->key();
188 getline(stream, line);
189 while(line[0] ==
'#') getline(stream, line);
196 if (line.length() > 300)
197 firstRes->fill_from_string_version1(line);
198 else if (line.length() > 240)
199 firstRes->fill_from_string_cs(line);
200 else if (line.length() > 110)
201 firstRes->fill_from_string(line);
203 firstRes->fill_from_string_residue_depth_version1(line);
205 current_section->push_back(firstRes);
206 prior_id = firstRes->id();
207 prior_resi = firstRes->resi();
211 while (getline(stream, line)) {
213 if( n_lines < startline )
continue;
216 if( endline != 0 && n_lines > endline )
break;
220 if (line.length() > 300)
221 current_residue->fill_from_string_version1(line);
222 else if (line.length() > 240)
223 current_residue->fill_from_string_cs(line);
224 else if (line.length() > 110)
225 current_residue->fill_from_string(line);
227 current_residue->fill_from_string_residue_depth_version1(line);
229 current_residue->key( n_lines + last_key );
231 if ( (current_residue->resi() != prior_resi + 1)
232 || (current_residue->id() != prior_id)) {
233 push_back(current_section);
234 Size t = current_section->size();
235 if (t > largest_chunk_size_)
236 largest_chunk_size_ =
t;
237 TR.Debug <<
"Created a new chunk for : " << current_section->get_pdb_id()
238 <<
" having " << current_section->size() <<
" residues "
239 <<
" at index " <<
size() <<
". The largest chunk's size is: "
240 <<largest_chunk_size_<<std::endl;
242 prior_id = current_residue->id();
244 prior_resi = current_residue->resi();
245 current_section->push_back(current_residue);
253 push_back(current_section);
254 TR.Debug <<
"Created a new chunk for : " << current_section->get_pdb_id()
255 <<
" having " << current_section->size() <<
" residues "
256 <<
" at index " <<
size() << std::endl;
257 Size t = current_section->size();
258 if (t > largest_chunk_size_) largest_chunk_size_ =
t;
260 time_t time_end = time(NULL);
262 TR.Info <<
"... done. Read " << n_lines <<
" lines. Time elapsed: "
263 << (time_end - time_start) <<
" seconds." << std::endl;
265 TR.Info <<
"Total chunks: " <<
size() << std::endl;
266 TR.Info <<
"Largest chunk: " << largest_chunk_size_ <<
" aa" << std::endl;
269 for (
Size i = 1; i <= largest_chunk_size_; i++) poly_A_seq_ +=
"A";