Ints ExampleSubsetFilterTable::get_indexes( const domino::Subset& s, const domino::Subsets& prior_subsets) const { // this method is only called from setup code, so it doesn't // have to be too fast Ints ret(ps_.size(), -1); for (unsigned int i = 0; i < s.size(); ++i) { for (unsigned int j = 0; j < ps_.size(); ++j) { if (s[i] == ps_[j]) { ret[j] = i; break; } } } for (unsigned int i = 0; i < ret.size(); ++i) { if (ret[i] == -1) return Ints(); } // check if we have seen them already). for (unsigned int i = 0; i < prior_subsets.size(); ++i) { unsigned int count = 0; for (unsigned j = 0; j < prior_subsets[i].size(); ++j) { for (unsigned int k = 0; k < ps_.size(); ++k) { if (prior_subsets[i][j] == ps_[k]) { ++count; break; } } } if (count == ps_.size()) { return Ints(); } } return ret; }
// for C++ Selection::Selection(Hierarchy h, std::string molname, int residue_index) : radius_(-1) { set_hierarchies(h.get_model(), kernel::ParticleIndexes(1, h.get_particle_index())); set_molecules(Strings(1, molname)); set_residue_indexes(Ints(1, residue_index)); }
Ints ClassnamePredicate::get_value(const PLURALVARIABLETYPE &o) const { IMPKERNEL_DEPRECATED_METHOD_DEF(2.1, "Use index version"); if (o.empty()) return Ints(); Ints ret(o.size()); Model *m = internal::get_model(o[0]); for (unsigned int i = 0; i < o.size(); ++i) { ret[i] += get_value_index(m, internal::get_index(o[i])); } return ret; }
unsigned int MSConnectivityRestraint::ParticleMatrix::add_type( const ParticlesTemp &ps) { protein_by_class_.push_back(Ints()); for (unsigned int i = 0; i < ps.size(); ++i) { unsigned int n = particles_.size(); particles_.push_back(ParticleData(ps[i], current_id_)); protein_by_class_.back().push_back(n); } return current_id_++; }
IntsList DensitySegmentationByCommunities::calculate_connected_components() { Ints component(num_vertices(g_)); int num = boost::connected_components(g_, &component[0]); Ints::size_type i; IntsList cc_inds; cc_inds.insert(cc_inds.end(), num, Ints()); for (i = 0; i != component.size(); ++i) { cc_inds[component[i]].push_back(node2voxel_ind_[node_index_[i]]); } return cc_inds; }
void RestraintCache::load_cache(const kernel::ParticlesTemp &particle_ordering, RMF::HDF5::ConstGroup group) { ParticleIndex particle_index = get_particle_index(particle_ordering); base::map<RestraintID, kernel::Restraint *> index; for (KnownRestraints::const_iterator it = known_restraints_.begin(); it != known_restraints_.end(); ++it) { index[get_restraint_id(particle_index, it->second, restraint_index_.find(it->first)->second)] = it->first; } kernel::RestraintsTemp restraints; for (unsigned int i = 0; i < group.get_number_of_children(); ++i) { RMF::HDF5::ConstGroup ch = group.get_child_group(i); int restraint_index = ch.get_attribute<RMF::HDF5::IndexTraits>("restraint")[0]; RMF::HDF5::Indexes particle_indexes = ch.get_attribute<RMF::HDF5::IndexTraits>("particles"); RestraintID rid(restraint_index, base::ConstVector<unsigned int>(Ints( particle_indexes.begin(), particle_indexes.end()))); kernel::Restraint *r = index.find(rid)->second; restraints.push_back(r); IMP_LOG_TERSE("Matching " << Showable(r) << " with " << ch.get_name() << std::endl); } Orders orders = get_orders(known_restraints_, restraints, particle_ordering); for (unsigned int i = 0; i < group.get_number_of_children(); ++i) { RMF::HDF5::ConstGroup ch = group.get_child_group(i); RMF::HDF5::FloatConstDataSet1D scores = ch.get_child_float_data_set_1d("scores"); RMF::HDF5::IntConstDataSet2D assignments = ch.get_child_int_data_set_2d("assignments"); for (unsigned int j = 0; j < scores.get_size()[0]; ++j) { double s = scores.get_value(RMF::HDF5::DataSetIndex1D(j)); RMF::HDF5::Ints rw = assignments.get_row(RMF::HDF5::DataSetIndex1D(j)); Ints psit(rw.begin(), rw.end()); Assignment ass = orders[i].get_subset_ordered(psit); cache_.insert(Key(restraints[i], ass), s); } } validate(); }
Assignments get_state_clusters(const Subset &subset, const Assignments &states, ParticleStatesTable *pst, double resolution) { Vector<Ints> rotated(subset.size(), Ints(states.size(), -1)); for (unsigned int i = 0; i < states.size(); ++i) { for (unsigned int j = 0; j < states[i].size(); ++j) { rotated[j][i] = states[i][j]; } } for (unsigned int i = 0; i < rotated.size(); ++i) { std::sort(rotated[i].begin(), rotated[i].end()); rotated[i].erase(std::unique(rotated[i].begin(), rotated[i].end()), rotated[i].end()); } Vector<Ints> clustering(states.size()); for (unsigned int i = 0; i < subset.size(); ++i) { IMP::PointerMember<ParticleStates> ps = pst->get_particle_states(subset[i]); Ints c = get_state_clusters(subset[i], ps, rotated[i], resolution); clustering[i] = c; } return filter_states(subset, states, clustering); }
Ints get_partial_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded) { for (unsigned int i=0; i< excluded.size(); ++i) { bool all=true; for (unsigned int j=0; j< particles.size(); ++j) { if (!std::binary_search(excluded[i].begin(), excluded[i].end(), particles[j])) { all=false; break; } } if (all) { return Ints(); } } Ints ret(particles.size(), -1); for (unsigned int i=0; i< particles.size(); ++i) { Subset::const_iterator it= std::lower_bound(subset.begin(), subset.end(), particles[i]); if (it!= subset.end() && *it == particles[i]) { ret[i]= it-subset.begin(); } } IMP_IF_LOG(VERBOSE) { IMP_LOG(VERBOSE, "Returning "); for (unsigned int i=0; i< ret.size(); ++i) { IMP_LOG(VERBOSE, ret[i] << " "); } IMP_LOG(VERBOSE, "for "); for (unsigned int i=0; i< particles.size(); ++i) { IMP_LOG(VERBOSE, particles[i]->get_name() << " "); } IMP_LOG(VERBOSE, " subset " << subset << std::endl); } return ret; }
Ints SingleAvroFile::get_children_frame(int node) const { return Ints(get_frame(node).children.begin(), get_frame(node).children.end()); }
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded) { Ints pi= get_partial_index(particles, subset, excluded); if (std::find(pi.begin(), pi.end(), -1) != pi.end()) return Ints(); else return pi; }