Rosetta 3.5
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
protocols
jd2
SilentFileJobOutputter.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/jd2/SilentFileJobOutputter.hh
11
/// @brief header file for SilentFileJobOutputter class, part of August 2008 job distributor as planned at RosettaCon08
12
/// @author Oliver Lange olange@u.washington.edu
13
14
15
#ifndef INCLUDED_protocols_jd2_SilentFileJobOutputter_hh
16
#define INCLUDED_protocols_jd2_SilentFileJobOutputter_hh
17
18
//unit headers
19
#include <
protocols/jd2/SilentFileJobOutputter.fwd.hh
>
20
#include <
protocols/jd2/FileJobOutputter.hh
>
21
#include <
protocols/jd2/JobOutputter.hh
>
22
#include <
protocols/jd2/Job.fwd.hh
>
23
24
//project headers
25
#include <
core/pose/Pose.fwd.hh
>
26
#include <
core/types.hh
>
27
28
//utility headers
29
#include <utility/file/FileName.hh>
30
#include <utility/vector1.hh>
31
32
//C++ headers
33
#include <string>
34
35
namespace
protocols {
36
namespace
jd2 {
37
38
///@details this is a implementation of JobOutputter for silent-file-based output.
39
// todo:
40
// read designated silent-file in beginning and implement method
41
// job_completed()
42
class
SilentFileJobOutputter
:
public
protocols::jd2::FileJobOutputter
43
{
44
public
:
45
46
typedef
protocols::jd2::FileJobOutputter
parent
;
47
48
SilentFileJobOutputter
();
49
virtual
~SilentFileJobOutputter
();
50
51
///@brief this function flushes any internal buffers - see parent class for explanation
52
virtual
void
flush
();
53
54
//////////////////////////////creating output functions/////////////////////////////////////////
55
///@brief this function outputs the final result of a job.
56
virtual
57
void
final_pose
(
JobCOP
job,
core::pose::Pose
const
& pose );
58
59
/// @brief this function is intended for saving
60
/// mid-protocol poses; for example the final centroid
61
/// structure in a combined centroid/fullatom protocol.
62
/// --->these go to file silent_filename+tag
63
virtual
64
void
other_pose
(
JobCOP
job,
core::pose::Pose
const
& pose,
std::string
const
& tag,
int
copy_count = -1,
bool
score_only =
false
);
65
66
/////////////////////////////////state of output functions/////////////////////////////////
67
68
/// @brief this function is not used for output, but it
69
/// belongs here since it needs to check the same output
70
/// locations as the class normally writes to. This class
71
/// checks wherever output goes to see if the job's
72
/// expected output already exists (on disk or whatever).
73
/// This is the most basic form of checkpointing.
74
virtual
75
bool
job_has_completed
(
JobCOP
job );
76
77
public
:
// accessors
78
79
/// @brief this is the master function for determining the
80
/// unique output identifier for a job
81
virtual
82
std::string
output_name
(
JobCOP
job );
83
84
virtual
85
std::string
filename
(
JobCOP
)
const
{
86
return
silent_file_
;
87
}
88
89
void
90
set_silent_file_name
(
utility::file::FileName
name );
91
92
void
93
set_write_separate_scorefile
(
bool
write_separate_scorefile );
94
95
void
set_write_no_structures
(
bool
value =
true
) {
96
bWriteNoStructures_
= value;
97
bWriteIntermediateStructures_
= !value &&
bWriteIntermediateStructures_
;
98
}
99
100
//////////////////////////////////////scorefile functions/////////////////////////////////////
101
protected
:
102
//called by final_- and other_pose methods
103
core::io::silent::SilentStructOP
dump_pose
(
104
utility::file::FileName
const
&
filename
,
105
JobCOP
job,
106
core::pose::Pose
const
& pose,
107
bool
bWriteScoreOnly,
108
int
copy_count = -1
/* if 0 or positive attach as postfix to job-tag ONLY used in other_pose output*/
109
);
110
111
private
:
// methods
112
113
void
add_silent_struct
(
114
core::io::silent::SilentStructOP
ss,
115
utility::file::FileName
const
& fn
116
);
117
118
/// @brief called by the constructor to set filename and options
119
void
set_defaults
();
120
121
void
read_done_jobs
();
122
123
/// @brief this function is called at the end of job distribution to flush the buffers
124
void
write_all_structs
();
125
126
private
:
// members
127
128
// write intermediate files ( from calls to other_pose )
129
bool
bWriteIntermediateFiles_
;
130
131
// write also structural information to intermediate files
132
// ( from calls to other_pose )
133
bool
bWriteIntermediateStructures_
;
134
135
///@brief toggle to switch off writing of structures
136
bool
bWriteNoStructures_
;
137
138
///@brief whether to write a separate scorefile that contains
139
///the scorelines from the silent file
140
bool
write_separate_scorefile_
;
141
142
// file name for silent-output
143
utility::file::FileName
silent_file_
;
144
145
// list of tags already written
146
utility::vector1< std::string >
silent_file_tags_
;
147
148
// used for buffering output.
149
core::Size
n_to_buffer_
;
150
151
// when n_to_buffer_ is reached write all structures with a probability of ... (default 1)
152
core::Real
random_flush_frequency_
;
153
154
//utility::vector1< core::io::silent::SilentStructOP > saved_structs_;
155
utility::vector1< std::pair< core::io::silent::SilentStructOP, utility::file::FileName >
>
saved_structs_
;
156
};
// SilentFileJobOutputter
157
158
// This is necessary because some protocols append prefixes
159
// to the tags and thus a simple string comparison will not
160
// recognise that S_1234_4 and C_S_1234_4 are the same.
161
class
CompareTags
:
public
std::unary_function<std::string, bool > {
162
public
:
163
CompareTags
(
const
std::string
& querytag ):
querytag_
(querytag) {}
164
165
bool
operator ()
(
const
std::string
& compare_tag )
const
{
166
// Strings match if all the characters of the shorter string match all of the last characters of the other.
167
core::Size
offset1 = compare_tag.find(
"S_"
);
168
if
( offset1 == std::string::npos ) offset1 = 0;
169
core::Size
offset2 =
querytag_
.find(
"S_"
);
170
if
( offset2 == std::string::npos ) offset2 = 0;
171
172
return
( compare_tag.substr(offset1) ==
querytag_
.substr(offset2) );
173
}
174
private
:
175
const
std::string
querytag_
;
176
};
177
178
}
// namespace jd2
179
}
// namespace protocols
180
181
#endif //INCLUDED_protocols_jd2_SilentFileJobOutputter_HH
Generated on Sat Jun 1 2013 11:55:21 for Rosetta 3.5 by
1.8.4