14 #ifndef INCLUDED_protocols_moves_PyMolMover_CC
15 #define INCLUDED_protocols_moves_PyMolMover_CC
33 #include <basic/Tracer.hh>
38 #include <utility/vector1.hh>
39 #include <utility/io/zipstream.ipp>
41 #include <utility/PyAssert.hh>
44 #include <numeric/random/uniform.hh>
62 static basic::Tracer
TR(
"protocols.moves.PyMolMover");
68 numeric::random::uniform_RG_OP
getRG()
70 static numeric::random::uniform_RG_OP
RG = 0;
74 RG =
new numeric::random::standard_RG;
75 RG->setSeed( time(NULL) );
84 #ifndef __native_client__
104 socket_h_ = socket(AF_INET, SOCK_DGRAM, 0);
125 for(
int i=0; i<count; i++) {
127 if( last>msg.size() ) last = msg.size();
133 timespec ts; ts.tv_sec=0; ts.tv_nsec=1000000;
134 nanosleep(&ts, NULL);
144 #ifndef __native_client__
149 memcpy(&buf[i], &globalPacketID, 2); i+=2;
150 memcpy(&buf[i], &packetI, 2); i+=2;
151 memcpy(&buf[i], &packetCount, 2); i+=2;
152 memcpy(&buf[i], msg_begin, msg_end-msg_begin); i+=msg_end-msg_begin;
154 sendto(
socket_h_, &buf[0], buf.size(), 0 , (
struct sockaddr *)&
socket_addr_,
sizeof(
struct sockaddr_in));
169 return "PyMOL_Mover";
179 for(
unsigned int i=0; i<n.size(); i++)
180 if( n[i] ==
'/' ) n[i] =
'_';
192 double t = time(NULL);
202 TR.Trace <<
"PyMolMover::apply( Pose const & pose)..." << std::endl;
205 TR.Trace <<
"PyMOL_Mover::apply It is time!" << std::endl;
209 TR.Trace <<
"PyMOL_Mover::apply name:" << name << std::endl;
212 std::ostringstream os;
216 std::ostringstream zmsg;
217 zlib_stream::zip_ostream zipper(zmsg,
true);
219 zipper.zflush_finalize();
222 std::string message =
"PDB.gzipXX" + name + zmsg.str();
224 message[9] = name.size();
236 Pose const & p(pose);
255 for(
unsigned int i=1; i<=energies.size(); i++) {
259 chain = info->chain(i);
260 res = info->number(i);
263 sprintf(buf,
"%c%4d%02x", chain, res, energies[i]);
264 for(
int k=0; k<7; k++) msg[(i-1)*7+k] = buf[k];
269 std::ostringstream zmsg;
270 zlib_stream::zip_ostream zipper(zmsg,
true);
272 zipper.zflush_finalize();
278 + char(name.size()) + name \
279 +
char(sname.size()) + sname + zmsg.str();
295 for(
unsigned int i=1; i<=e.size(); i++) {
299 if( min > e[i] ) min = e[i];
300 if( max < e[i] ) max = e[i];
305 for(
unsigned int i=1; i<=e.size(); i++) {
309 chain = info->chain(i);
310 res = info->number(i);
313 e[i] = (e[i]-min)*255. / (max-min+1e-100);
314 sprintf(buf,
"%c%4d%02x", chain, res,
int(e[i]));
315 for(
int k=0; k<7; k++) msg[(i-1)*7+k] = buf[k];
320 std::ostringstream zmsg;
321 zlib_stream::zip_ostream zipper(zmsg,
true);
323 zipper.zflush_finalize();
329 + char(name.size()) + name \
330 +
char(sname.size()) + sname + zmsg.str();
350 for(std::map<int, int>:: const_iterator i = colors.begin(); i!=colors.end(); ++i) {
351 PyAssert( (*i).first >=1 && (*i).first <= pose.
total_residue(),
"PyMolMover::send_colors residue index is out of range!");
354 energies[ (*i).first ] = (*i).second;
376 o->pymol().keep_history(keep_history);
377 o->pymol().update_interval(update_interval);
386 #endif // INCLUDED_protocols_moves_PyMolMover_CC