GtkTreeModel * get_filter_model (gboolean first) { GtkTreeModelFilter *model; model = (GtkTreeModelFilter *)gtk_tree_model_filter_new (get_model (), NULL); gtk_tree_model_filter_set_visible_func (model, visible_func, GINT_TO_POINTER (first), NULL); return (GtkTreeModel *) model; }
ParticleIndexes DummyPairContainer::get_all_possible_indexes() const { kernel::ParticleIndexes ret = c_->get_all_possible_indexes(); kernel::ModelObjectsTemp mos = cpf_->get_inputs(get_model(), c_->get_indexes()); for (unsigned int i = 0; i < mos.size(); ++i) { kernel::ModelObject *o = mos[i]; kernel::Particle *p = dynamic_cast<kernel::Particle *>(o); if (p) ret.push_back(p->get_index()); } return ret; }
void MolecularDynamics::propagate_coordinates(const ParticleIndexes &ps, double ts) { for (unsigned int i = 0; i < ps.size(); ++i) { Float invmass = 1.0 / Mass(get_model(), ps[i]).get_mass(); core::XYZ d(get_model(), ps[i]); LinearVelocity v(get_model(), ps[i]); algebra::Vector3D coord = d.get_coordinates(); algebra::Vector3D dcoord = d.get_derivatives(); // calculate velocity at t+(delta t/2) from that at t algebra::Vector3D velocity = v.get_velocity(); velocity += 0.5 * dcoord * deriv_to_acceleration * invmass * ts; for (unsigned int j = 0; j < 3; ++j) { cap_velocity_component(velocity[j]); } v.set_velocity(velocity); // calculate position at t+(delta t) from that at t coord += velocity * ts; d.set_coordinates(coord); } }
// // Function: ffll_close_model() // // Purpose: Closes the model for the index passed in. // // Arguments: // // int model_idx - index of the model // // Returns: // // 0 - success // non-zero - failure // // Author: Michael Zarozinski // Date: 2/02 // // Modification History // Author Date Modification // ------ ---- ------------ // Michael Z 4/15/03 Ignore null model... // int WIN_FFLL_API ffll_close_model(int model_idx) { ModelContainer* container = get_model(model_idx); if (container->model != NULL) return 0; delete container; return 0; }; // end ffll_close_model()
int main(int argc ,char * argv[]){ int model; char target_path[max_len]; //char* buf; //system("./terminal.sh"); //buf=getenv("VAR_CLOUMS"); //printf("%s\n",buf); init_screen(); get_model(argc,argv,&model,target_path); my_ls(target_path,model); return 0; }
void TransformMover::do_reject() { //RigidBody d(get_model(), pi_); //d.set_reference_frame(algebra::ReferenceFrame3D(last_transformation_)); //last_transformation_ = algebra::Transformation3D(); for (unsigned int i=0;i<pixyzs_.size();i++) { core::XYZ d(get_model(), pixyzs_[i]); d.set_coordinates(xyzs_[i]); //core::transform(d,c_); //core::transform(d,t_.get_inverse()); //core::transform(d,c_.get_inverse()); } for (unsigned int i=0;i<pirbs_.size();i++){ core::RigidBody d(get_model(), pirbs_[i]); d.set_reference_frame(algebra::ReferenceFrame3D(rbts_[i])); //core::transform(d,c_); //core::transform(d,t_.get_inverse()); //core::transform(d,c_.get_inverse()); } }
void ModelManager::set_node_defaults_( index model_id, const DictionaryDatum& params ) { params->clear_access_flags(); get_model( model_id )->set_status( params ); ALL_ENTRIES_ACCESSED( *params, "ModelManager::set_node_defaults_", "Unread dictionary entries: " ); }
ParticleIndexPairs BondPairContainer::get_range_indexes() const { ParticleIndexes ia = sc_->get_range_indexes(); ParticleIndexPairs ret; ret.reserve(ia.size()); for (unsigned int i = 0; i < ia.size(); ++i) { Bond b(get_model(), ia[i]); ret.push_back( ParticleIndexPair(b.get_bonded(0).get_particle_index(), b.get_bonded(1).get_particle_index())); } return ret; }
ModelObjectsTemp WeightedExcludedVolumeRestraint::do_get_inputs() const { kernel::ModelObjectsTemp ret = rb_refiner_->get_inputs(get_model(), IMP::get_indexes(kernel::ParticlesTemp(particles_begin(), particles_end()))); for (ParticleConstIterator it= particles_begin(); it != particles_end(); ++it) { kernel::ParticlesTemp curr= rb_refiner_->get_refined(*it); ret += curr; } return ret; }
// ------------------------------------------------------------- // animated, mobile object for adventure map // ------------------------------------------------------------- void t_actor::set_direction( t_direction direction ) { t_model const& model = get_model(); on_move_begin(); m_direction = direction; m_current_sequence = model.get_sequence_cache( m_action, m_direction ).get(); m_frame_count = model.get_frame_count( m_action, m_direction ); if (m_frame_count <= m_frame) m_frame = m_frame_count - 1; m_start_time = get_time(); on_move_end(); }
/* Apply the pair score to each particle pair listed in the container. */ void ExampleRestraint::do_add_score_and_derivatives(ScoreAccumulator sa) const { IMP_OBJECT_LOG; core::XYZ d(get_model(), p_); IMP_LOG_VERBOSE("The z coordinate of " << d->get_name() << " is " << d.get_z() << std::endl); double score = .5 * k_ * square(d.get_z()); if (sa.get_derivative_accumulator()) { double deriv = k_ * d.get_z(); d.add_to_derivative(2, deriv, *sa.get_derivative_accumulator()); } sa.add_score(score); }
void ModelObject::validate_inputs() const { if (!get_has_dependencies()) return; IMP_IF_CHECK(USAGE_AND_INTERNAL) { ModelObjectsTemp ret = do_get_inputs(); std::sort(ret.begin(), ret.end()); ret.erase(std::unique(ret.begin(), ret.end()), ret.end()); // since I/O nodes are considered outputs ModelObjectsTemp saved = get_model()->get_dependency_graph_inputs(this) + get_model()->get_dependency_graph_outputs(this); std::sort(saved.begin(), saved.end()); ModelObjectsTemp intersection; std::set_intersection(saved.begin(), saved.end(), ret.begin(), ret.end(), std::back_inserter(intersection)); IMP_USAGE_CHECK( intersection.size() == ret.size(), "Dependencies changed without invalidating dependencies." << " Make sure you call set_has_dependencies(false) any " << "time the list of dependencies changed. Object is " << get_name() << " of type " << get_type_name() << " -- " << ret << " vs " << saved); } }
IMPISD_BEGIN_NAMESPACE // MarginalNOERestraint::MarginalNOERestraint() {} // add a contribution: simple case void MarginalNOERestraint::add_contribution(Particle *p1, Particle *p2, double Iexp) { ParticleIndexPair pc(p1->get_index(), p2->get_index()); ParticleIndexPairs pct(1, pc); IMP_NEW(container::ListPairContainer, cont, (get_model(), pct)); // container::ListPairContainer cont(pct); add_contribution(cont, Iexp); }
void InternalDynamicListTripletContainer ::remove_particle_triplets(const ParticleTripletsTemp &c) { if (c.empty()) return; get_model()->reset_dependencies(); ParticleIndexTriplets cp= IMP::internal::get_index(c); remove_from_list(cp); IMP_IF_CHECK(base::USAGE) { for (unsigned int i=0; i< c.size(); ++i) { IMP_USAGE_CHECK(IMP::internal::is_valid(c[i]), "Passed Triplet cannot be nullptr (or None)"); } } }
/* Apply the restraint to two atoms, two Scales, one experimental value. */ double AmbiguousNOERestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { IMP_OBJECT_LOG; IMP_USAGE_CHECK(get_model(), "You must at least register the restraint with the model" << " before calling evaluate."); /* compute Icalc = 1/(gamma*d^6) where d = (sum d_i^-6)^(-1/6) */ double vol = 0; Floats vols; IMP_CONTAINER_FOREACH(PairContainer, pc_, { core::XYZ d0(get_model(), _1[0]); core::XYZ d1(get_model(), _1[1]); algebra::Vector3D c0 = d0.get_coordinates(); algebra::Vector3D c1 = d1.get_coordinates(); //will raise an error if c0 == c1 double tmp = 1.0/(c0-c1).get_squared_magnitude(); vols.push_back(IMP::cube(tmp)); // store di^-6 vol += vols.back(); });
void NaviModules::on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time) { // Combining full path to module GtkTreeRowReference* grr = (GtkTreeRowReference*) context->get_data(Glib::Quark("gtk-tree-view-source-row")); Gtk::TreeRowReference rr = Glib::wrap(grr); Gtk::TreePath path = rr.get_path(); Glib::RefPtr<Gtk::TreeModel> mdl = get_model(); Gtk::TreeIter it = mdl->get_iter(path); string modname = (*it).get_value(iColRec.name); string modpath = iDesEnv->Provider()->ModulesPath(); string data = "file:" + modpath + modname + "#"; selection_data.set_text(data); }
// // Function: ffll_new_child() // // Purpose: Create a new child for the model passed in. // // Arguments: // // int model_idx - index of the model // // Returns: // // The index of the child for the model // non-zero - failure // // Author: Michael Zarozinski // Date: 9/01 // // Modification History // Author Date Modification // ------ ---- ------------ // // int WIN_FFLL_API ffll_new_child(int model_idx) { ModelContainer* container = get_model(model_idx); assert(container->model != NULL); // make sure you call ffll_load_fcl_file() before this func. ModelChild* child = new ModelChild(container->model); container->child_list.push_back(child); return container->child_list.size() - 1; }; // end ffll_get_child()
double MonteCarlo::do_optimize(unsigned int max_steps) { IMP_OBJECT_LOG; IMP_CHECK_OBJECT(this); if (get_number_of_movers() == 0) { IMP_THROW("Running MonteCarlo without providing any" << " movers isn't very useful.", ValueException); } ParticleIndexes movable = get_movable_particles(); // provide a way of feeding in this value last_energy_ = do_evaluate(movable); if (return_best_) { best_ = new Configuration(get_model()); best_energy_ = last_energy_; } reset_statistics(); update_states(); IMP_LOG_TERSE("MC Initial energy is " << last_energy_ << std::endl); for (unsigned int i = 0; i < max_steps; ++i) { if (get_stop_on_good_score() && get_scoring_function()->get_had_good_score()) { break; } do_step(); if (best_energy_ < get_score_threshold()) break; } IMP_LOG_TERSE("MC Final energy is " << last_energy_ << std::endl); if (return_best_) { // std::cout << "Final score is " << get_model()->evaluate(false) //<< std::endl; best_->swap_configuration(); IMP_LOG_TERSE("MC Returning energy " << best_energy_ << std::endl); IMP_IF_CHECK(USAGE) { IMP_LOG_TERSE("MC Got " << do_evaluate(get_movable_particles()) << std::endl); /*IMP_INTERNAL_CHECK((e >= std::numeric_limits<double>::max() && best_energy_ >= std::numeric_limits<double>::max()) || std::abs(best_energy_ - e) < .01+.1* std::abs(best_energy_ +e), "Energies do not match " << best_energy_ << " vs " << e << std::endl);*/ } return do_evaluate(movable); } else { return last_energy_;
MonteCarloMoverResult NormalMover::do_propose() { IMP_OBJECT_LOG; boost::normal_distribution<double> mrng(0, stddev_); boost::variate_generator<RandomNumberGenerator &, boost::normal_distribution<double> > sampler(random_number_generator, mrng); for (unsigned int i = 0; i < pis_.size(); ++i) { for (unsigned int j = 0; j < keys_.size(); ++j) { originals_[i][j] = get_model()->get_attribute(keys_[j], pis_[i]); } for (unsigned int j = 0; j < keys_.size(); ++j) { IMP_USAGE_CHECK( get_model()->get_is_optimized(keys_[j], pis_[i]), "NormalMover can't move non-optimized attribute. " << "particle: " << get_model()->get_particle_name(pis_[i]) << "attribute: " << keys_[j]); get_model()->set_attribute(keys_[j], pis_[i], originals_[i][j] + sampler()); } } return MonteCarloMoverResult(pis_, 1.0); }
bool MolecularDynamics::get_is_simulation_particle(ParticleIndex pi) const { Particle *p=get_model()->get_particle(pi); bool ret=IMP::core::XYZ::particle_is_instance(p) && IMP::core::XYZ(p).get_coordinates_are_optimized() && Mass::particle_is_instance(p); if (ret) { for (unsigned int i=0; i< 3; ++i) { if (!p->has_attribute(vs_[i])) { p->add_attribute(vs_[i], 0.0, false); } } } return ret; }
double WIN_FFLL_API ffll_get_output_value(int model_idx, int child_idx) { ModelContainer* container = get_model(model_idx); // get the child ModelChild* child = container->child_list[child_idx]; // pass in the input value for each input variable and the array // of DOMs for the output sets RealType out_val = container->model->calc_output(child->var_idx_arr, child->out_set_dom_arr); return out_val; }; // end ffll_get_output_value()
// // Function: ffll_set_value() // // Purpose: Set the variable's index for the value passed in. // // Arguments: // // int model_idx - index of the model // int child_idx - index of the child // int var_idx - index of the variable // RealType value - value to set the variable to // // Returns: // // 0 - success // non-zero - failure // // Author: Michael Zarozinski // Date: 9/01 // // Modification History // Author Date Modification // ------ ---- ------------ // // int WIN_FFLL_API ffll_set_value(int model_idx, int child_idx, int var_idx, double value) { ModelContainer* container = get_model(model_idx); ModelChild* child = container->child_list[child_idx]; // convert value to an index into the values[] array ValuesArrCountType idx = container->model->convert_value_to_idx(var_idx, value); child->var_idx_arr[var_idx] = idx; return 0; }; // end ffll_set_value()
IncrementalScoringFunction::Data IncrementalScoringFunction::create_data( ParticleIndex pi, RestraintsTemp cr, const boost::unordered_map<Restraint *, int> &all, const Restraints &dummies) const { IMP_LOG_TERSE("Dependent restraints for particle " << get_model()->get_particle_name(pi) << " are " << cr << std::endl); Data ret; for (unsigned int j = 0; j < cr.size(); ++j) { if (all.find(cr[j]) != all.end()) { int index = all.find(cr[j])->second; IMP_INTERNAL_CHECK( std::find(ret.indexes.begin(), ret.indexes.end(), index) == ret.indexes.end(), "Found duplicate restraint " << Showable(cr[j]) << " in list " << cr); ret.indexes.push_back(index); } } cr += RestraintsTemp(dummies.begin(), dummies.end()); ret.sf = new IncrementalRestraintsScoringFunction( cr, 1.0, NO_MAX, get_model()->get_particle_name(pi) + " restraints"); return ret; }
bool MolecularDynamics::get_is_simulation_particle(ParticleIndex pi) const { Particle *p = get_model()->get_particle(pi); bool ret = IMP::core::XYZ::get_is_setup(p) && IMP::core::XYZ(p).get_coordinates_are_optimized() && Mass::get_is_setup(p); if (ret) { IMP_LOG_VERBOSE(p->get_name() << " is md particle" << std::endl); if (!LinearVelocity::get_is_setup(p)) { LinearVelocity::setup_particle(p); } } return ret; }
GtkWidget * Ekiga::GActorMenu::get_menu (const Ekiga::GActorMenuStore & store) { GMenuModel *model = get_model (store, false); if (!model) return NULL; GtkWidget *menu = gtk_menu_new_from_model (model); gtk_widget_insert_action_group (menu, context.c_str (), G_ACTION_GROUP (g_application_get_default ())); g_object_ref (menu); return menu; }
double CAAngleRestraint::unprotected_evaluate(DerivativeAccumulator *) const { Model *m = get_model(); core::XYZ d0(m, p_[0]); core::XYZ d1(m, p_[1]); core::XYZ d2(m, p_[2]); double phi0 = core::internal::angle(d0, d1, d2, nullptr, nullptr, nullptr); int index = get_closest(phi0_,phi0); return score_[index]; }
void DistributeQuadsScoreState ::update_lists_if_necessary() const { if (updated_ && !input_->get_is_changed()) return; updated_=true; base::Vector<ParticleIndexQuads> output(data_.size()); IMP_FOREACH_QUAD_INDEX(input_, { for (unsigned int i=0; i< data_.size(); ++i) { if (data_[i].get<1>()->get_value_index(get_model(), _1) == data_[i].get<2>()) { output[i].push_back(_1); } } });
IMPATOM_BEGIN_NAMESPACE HelixRestraint::HelixRestraint(Residues rs, bool ideal) : Restraint(rs[0]->get_model(), "HelixRestraint%1%") { //dihedral info //Float dih1,std1,dih2,std2,distON,kON; Float dih1 = -1.117010721276371; //mean = -64deg, std = 6deg Float std1 = 0.10471975511965977; Float dih2 = -0.715584993317675; //mean = -41deg, std = 8deg Float std2 = 0.13962634015954636; Float corr = -0.25; Float weight = 0.5; core::BinormalTerm bt; bt.set_means(std::make_pair(dih1,dih2)); bt.set_standard_deviations(std::make_pair(std1,std2)); bt.set_correlation(corr); bt.set_weight(weight); //bond info Float distON = 2.96; Float kON = core::Harmonic::get_k_from_standard_deviation(0.11); //will expand to more bonds and residue types bond_ON_score_ = new core::HarmonicDistancePairScore(distON,kON); if (rs.size()>=3){ for(size_t nr=0;nr<rs.size()-2;nr++){ core::XYZ a1(get_atom(rs[nr],AT_C)); core::XYZ a2(get_atom(rs[nr+1],AT_N)); core::XYZ a3(get_atom(rs[nr+1],AT_CA)); core::XYZ a4(get_atom(rs[nr+1],AT_C)); core::XYZ a5(get_atom(rs[nr+2],AT_N)); IMP_NEW(core::MultipleBinormalRestraint, mbr,(get_model(), ParticleIndexQuad(a1,a2,a3,a4), ParticleIndexQuad(a2,a3,a4,a5))); mbr->add_term(bt); dihedral_rs_.push_back(mbr); } } if (rs.size()>=5){ for(size_t nr=0;nr<rs.size()-4;nr++){ bonds_ON_.push_back(ParticleIndexPair( get_atom(rs[nr],AT_O).get_particle_index(), get_atom(rs[nr+4],AT_N).get_particle_index())); } } }
void final_snapshot::launch_with_estimator() { while(true) { std::size_t steps_left = m_final_estimator_ptr->estimate(); if(0 == steps_left) break; bool ok = m_advancer_ptr->advance(steps_left); if(!ok) break; } m_stream_printer_ptr->write_dataframe(get_model().current_configuration()); }
Float HelixRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { Float score = 0.0; Model *m = get_model(); for (IMP::Vector<IMP::PointerMember< core::MultipleBinormalRestraint> >::const_iterator td = dihedral_rs_.begin(); td != dihedral_rs_.end(); ++td){ score += (*td)->unprotected_evaluate(accum); } for (ParticleIndexPairs::const_iterator tb = bonds_ON_.begin(); tb != bonds_ON_.end(); ++tb) { score += bond_ON_score_->evaluate_index(m, *tb, accum); } return score; }