static PyObject *calculate_MHD(PyObject *self, PyObject *args) { PyObject *list_a, *list_b; double **a = NULL; double **b = NULL; int a_len, b_len, a_dim, b_dim; if (!PyArg_ParseTuple(args, "OO", &list_a, &list_b)) { printf("Problem Parsing Arguments!\n"); return NULL; } if( convert_2d_pylist( list_a, &a, &a_len, &a_dim ) != 0 ) { printf("Problem converting list #1\n"); return NULL; } if( convert_2d_pylist( list_b, &b, &b_len, &b_dim) != 0 ) { printf("Problem converting list #2\n"); return NULL; } if( a_dim != b_dim) { printf("Dimension mismatch!\n"); return NULL; } return Py_BuildValue("d", mhd( a, b, a_len, b_len, a_dim ) ); }
Atom get_atom(Residue rd, AtomType at) { Hierarchy mhd(rd.get_particle()); for (unsigned int i=0; i< mhd.get_number_of_children(); ++i) { Atom a(mhd.get_child(i)); if (a.get_atom_type() == at) return a; } IMP_LOG(VERBOSE, "Atom not found " << at << std::endl); return Atom(); }
Residue get_residue(Atom d, bool nothrow) { Hierarchy mhd(d.get_particle()); do { mhd= mhd.get_parent(); if (mhd== Hierarchy()) { if (nothrow) return Residue(); else { IMP_THROW("Atom is not the child of a residue " << d, ValueException); } } } while (!Residue::particle_is_instance(mhd.get_particle())); Residue rd(mhd.get_particle()); return rd; }
int main(int argc, char** argv) { ledger_rest::args args(argc, argv); ledger_rest::stderr_logger logger(args.get_log_level()); ledger_rest::ledger_rest_runnable ledger(args, logger); ledger_rest::mhd mhd(args, logger, ledger); std::list<ledger_rest::runnable*> runners{ &mhd, &ledger }; ledger_rest::runner runner(logger, runners); ledger_rest::set_runner(&runner); if (std::signal(SIGINT, ledger_rest::stop_runner) == SIG_ERR) { logger.log(5, "Error setting signal handler."); exit(EXIT_FAILURE); } runner.run(); return 0; }