示例#1
0
文件: swig.cpp 项目: apolitis/imp
Particles _give_particles_copy(Model *m) {
  Particles ret;
  while (ret.size() < 10) {
    ret.push_back(new Particle(m));
  }
  return ret;
}
示例#2
0
文件: swig.cpp 项目: apolitis/imp
const Particles &_give_particles(Model *m) {
  static Particles ret;
  while (ret.size() < 10) {
    ret.push_back(new Particle(m));
  }
  return ret;
}
示例#3
0
void add_NuisanceMover(Particle *p, double dp, core::MonteCarloMovers &mvs) {
  // put particle in a list
  Particles ps;
  ps.push_back(p);
  // put nuisance floatkey in a list
  FloatKeys fks;
  fks.push_back(FloatKey("nuisance"));
  IMP_NEW(core::NormalMover, mv, (ps, fks, dp));
  mvs.push_back(mv);
}
SecondaryStructureResidues read_psipred(TextInput inf, Model* mdl) {
  Strings ss = parse_psipred_file(inf);
  int nres = ss[0].size();
  Particles ps;
  for (int nr = 0; nr < nres; nr++) {
    IMP_NEW(Particle, p, (mdl));
    ps.push_back(p);
  }
  return create_sses_from_strings(ss, ps);
}
示例#5
0
 inline explicit Simulation(const size_t np,
                            const size_t nw,
                            const double delta_lambda) :
 delta_lam(delta_lambda),
 delta_tau(delta_lam*delta_lam),
 workers(nw,as_capacity),
 running(),
 waiting(),
 ran(  )
 {
     ran.reseed( Randomized::Bits::Simple() );
     for(size_t i=np;i>0;--i) { running.push_back( new Particle() ); }
     for(size_t i=nw;i>0;--i) { const Worker::Pointer pW( new Worker() ); workers.push_back(pW); }
 }
示例#6
0
Hierarchy create_protein(Model *m,
                         std::string name,
                         double resolution,
                         int number_of_residues,
                         int first_residue_index,
                         double volume,
                         bool ismol) {
  double mass= atom::get_mass_from_number_of_residues(number_of_residues)/1000;
  if (volume < 0) {
    volume= atom::get_volume_from_mass(mass*1000);
  }
  // assume a 20% overlap in the beads to make the protein not too bumpy
  double overlap_frac=.2;
  std::pair<int, double> nr= compute_n(volume, resolution, overlap_frac);
  Hierarchy pd=Hierarchy::setup_particle(new Particle(m));
  if (ismol) Molecule::setup_particle(pd);
  pd->set_name(name);
  Particles ps;
  for (int i=0; i< nr.first; ++i) {
    Particle *pc= new Particle(m);
    std::ostringstream oss;
    oss << name << "-" << i;
    pc->set_name(oss.str());
    atom::Fragment pcd
      =atom::Fragment::setup_particle(pc);
    pd.add_child(pcd);
    core::XYZR xyzd=core::XYZR::setup_particle(pc);
    xyzd.set_radius(nr.second);
    xyzd.set_coordinates_are_optimized(true);
    ps.push_back(pc);
    Ints indexes;
    for (int j= i*(number_of_residues/nr.first)
           + first_residue_index; j <(i+1)*(number_of_residues/nr.first)
           + first_residue_index; ++j) {
      indexes.push_back(j);
    }
    pcd.set_residue_indexes(indexes);
    atom::Mass::setup_particle(pc, mass/nr.first);
  }
  IMP_INTERNAL_CHECK(pd.get_is_valid(true),
                     "Invalid hierarchy produced " << pd);
  return pd;
}
void CHARMMParameters::add_angle(Particle *p1, Particle *p2, Particle *p3,
                                 Particles &ps) const
{
  IMP_OBJECT_LOG;
  Angle ad = Angle::setup_particle(new Particle(p1->get_model()),
                                   core::XYZ(p1), core::XYZ(p2),
                                   core::XYZ(p3));
  try {
    const CHARMMBondParameters &p
          = get_angle_parameters(CHARMMAtom(p1).get_charmm_type(),
                                 CHARMMAtom(p2).get_charmm_type(),
                                 CHARMMAtom(p3).get_charmm_type());
    ad.set_ideal(p.ideal / 180.0 * PI);
    ad.set_stiffness(std::sqrt(p.force_constant * 2.0));
  } catch (const IndexException &e) {
    // If no parameters, warn only
    IMP_WARN(e.what());
  }
  ps.push_back(ad);
}
示例#8
0
 void detectImpact(const double     delta_lam,
                   IRandom         &ran) throw()
 {
     count = 0;
     Particles tmp;
     while(running.size>0)
     {
         Particle *p = running.pop_back();
         const int ans = p->moveAndDetectImpact(delta_lam,ran);
         if(ans!=0)
         {
             count += ans;
             waiting.push_back(p);
         }
         else
         {
             tmp.push_front(p);
         }
     }
     tmp.swap_with(running);
 }
示例#9
0
	void remove(Particle *p) 
	{ 
		removeList.push_back(p);
	}
示例#10
0
	void add(Particle *p) 
	{ 
		particles.push_back(p); 
	}
示例#11
0
int main(int argc, char ** argv)
{
	invalid_argument er(
		"Bond angle correlation function\n"
#ifdef use_periodic
		"Syntax : periodic_g6 [path]filename NbOfBins Nb dx dy dz [mode=0 [l=6]]\n"
#else
		"Syntax : g6 [path]filename radius NbOfBins range [mode=0 [l=6 [zmin zmax]]]\n"
		" range is in diameter unit\n"
#endif
		" mode\t0 raw boo\n"
		"     \t1 coarse grained boo\n"
		);

    try
    {

		if(argc<3) throw er;

		const string filename(argv[1]);
		const string inputPath = filename.substr(0,filename.find_last_of("."));

		vector<size_t> inside;

		//construct the particle container out of the datafile
#ifdef use_periodic
		if(argc<7) throw er;
		const size_t Nbins = atoi(argv[2]);
		const size_t Nb = atoi(argv[3]);
		double nbDiameterCutOff =atof(argv[4]);
		BoundingBox b;
		for(size_t d=0;d<3;++d)
		{
			b.edges[d].first=0.0;
			b.edges[d].second = atof(argv[4+d]);
			if(nbDiameterCutOff>b.edges[d].second)
                nbDiameterCutOff=b.edges[d].second;
		}
		nbDiameterCutOff /=4.0;
		const bool mode = (argc<8)?0:atoi(argv[7]);
		const size_t l = (argc<9)?6:atoi(argv[8]);
		PeriodicParticles Centers(Nb,b,filename,1.0);
		cout << "With periodic boundary conditions"<<endl;
#else
        const double radius = atof(argv[2]),
				nbDiameterCutOff = atof(argv[4]);
        const size_t Nbins = atoi(argv[3]);
        const bool mode = (argc<6)?0:atoi(argv[5]);
        const size_t l = (argc<7)?6:atoi(argv[6]);
		Particles Centers(filename,radius);
#endif
		cout << Centers.size() << " particles ... ";

		//read q6m
		vector<BooData> rawBoo, allBoo;
		Centers.load_qlm(inputPath+".qlm", rawBoo);
		if(mode)
		{
		    Centers.makeNgbList(loadBonds(inputPath+".bonds"));
		    //select all particles who's all neighbours' qlms are not null
		    vector<size_t> second_inside;
		    second_inside.reserve(Centers.size());
		    for(size_t p=0; p<Centers.getNgbList().size(); ++p)
		    {
		        bool hasNullNgb = false;
		        for(size_t n=0; n<Centers.getNgbList()[p].size(); ++n)
                    hasNullNgb = (hasNullNgb || rawBoo[Centers.getNgbList()[p][n]].isnull());
                if(!hasNullNgb)
                    second_inside.push_back(p);
		    }
		    cout<< second_inside.size()<< " have coarse grained qlms ... ";
		    Centers.getCgBOOs(second_inside, rawBoo, allBoo);
		}
		else
            allBoo=rawBoo;

#ifndef use_periodic
        vector<size_t> slab;
        slab.reserve(Centers.size());
        //Case where we ask to discard all points out of the interval [zmin, zmax]
        if(argc>8)
        {
            const double zmin = atof(argv[7]),
                        zmax = atof(argv[8]);
            //look for the particles that are in the slab and have non null qlm
            for(size_t p=0; p<Centers.size(); ++p)
                if(Centers[p][2]>zmin && Centers[p][2]<zmax && !allBoo[p].isnull())
                    slab.push_back(p);
        }
        else
            for(size_t p=0; p<Centers.size(); ++p)
                if(!allBoo[p].isnull())
                    slab.push_back(p);

        //reduce the centers list
        Particles cen;
        cen.radius = Centers.radius;
        cen.reserve(slab.size());
        for(size_t p=0; p<slab.size(); ++p)
            cen.push_back(Centers[slab[p]]);
        Centers.swap(cen);
        Centers.delNgbList();

        //reduce the qlm
        vector<BooData> boo(slab.size());
        for(size_t p=0; p<slab.size(); ++p)
            boo[p] = allBoo[slab[p]];
        allBoo.swap(boo);
#endif
        vector<size_t> nb(Nbins, 0);
        vector<double> gl(Nbins, 0.0);
        const double maxdistsq = pow(2.0*nbDiameterCutOff, 2);
        for(size_t p=0; p<Centers.size(); ++p)
            for(size_t q=p+1; q<Centers.size(); ++q)
            {
                Coord diff = Centers.getDiff(p, q);
                const double distsq = (diff*diff).sum();
                if(distsq<maxdistsq)
                {
                    const size_t r = sqrt(distsq) / (2.0*nbDiameterCutOff) * Nbins;
                    nb[r]++;
                    gl[r] += allBoo[p].innerProduct(allBoo[q], l);
                }
            }

        cout << " done !" << endl;
		ostringstream rdffilename;
		rdffilename << inputPath << (mode?".cg":".g") << l;
		ofstream rdfFile(rdffilename.str().c_str(), ios::out | ios::trunc);
		rdfFile << "#r\tg"<<l<<"(r)\tg(r)"<<endl;
		for(size_t r=0; r<Nbins; ++r)
			rdfFile<< r/(double)Nbins*nbDiameterCutOff <<"\t"<< gl[r] <<"\t"<< nb[r] <<"\n";

        //all particles are "inside"
        /*inside.reserve(Centers.size());
        for(size_t p=0; p<Centers.size(); ++p)
            inside[p] = p;
        cout << Centers.size() << " inside ... ";

        Centers.makeRTreeIndex();*/
		//create binner
		//Particles::GlBinner binner(Centers, Nbins, nbDiameterCutOff, allBoo, l);

		//select particles and bin them
		//vector<size_t> inside = Centers.selectInside(2.0*radius*(nbDiameterCutOff+(1+mode)*1.3/2));
		//Case where we ask to discard all points out of the interval [zmin, zmax]
		/*if(argc>8)
		{
		    const double zmin = atof(argv[7]),
                        zmax = atof(argv[8]);
            //cout<<"\tl="<<l<<"\tzmin="<<zmin<<"\tzmax="<<zmax;
            vector<size_t> in;
            in.reserve(inside.size());
            for(vector<size_t>::const_iterator p=inside.begin(); p!=inside.end(); ++p)
                if(Centers[*p][2]>=zmin && Centers[*p][2]<=zmax)
                    in.push_back(*p);
            in.swap(inside);
		}*/

		/*binner << inside;

		//binner.normalize(inside.size());
		cout << " done !" << endl;
		ostringstream rdffilename;
		rdffilename << inputPath << (mode?".cg":".g") << l;
		ofstream rdfFile(rdffilename.str().c_str(), ios::out | ios::trunc);
		rdfFile << "#r\tg"<<l<<"(r)\tg(r)"<<endl;
		for(size_t r=0; r<Nbins; ++r)
			rdfFile<< r/(double)Nbins*nbDiameterCutOff <<"\t"<< binner.gl[r] <<"\t"<< binner.g[r] <<"\n";*/

    }
    catch(const std::exception &e)
    {
        cerr<<e.what() << endl;
        return EXIT_FAILURE;
    }
    return EXIT_SUCCESS;
}