Exemplo n.º 1
0
int main(int argc, char *argv[]){
  FILE *fptr;
  
  if (!(fptr = fopen(argv[1], "r"))){
    printf("Couldn't open file.");
    return 1;
  }

  char buf[1000]; //line size limitation, lame

  begin();
  
  char * ip;
  while (fgets(buf,1000, fptr)!=NULL){
    ip = buf;
    while (*ip){
      curr_state = bead(*ip++);
    }
  }

  printf("%s\n", c_file);
  
  fclose(fptr);
  return 0;
}
Exemplo n.º 2
0
void MultiChain::record() {
  //h_config = H5Gopen(h_file,"MultiChain");
  typedef Bead::RealType PosType;
  typedef Bead::Buffer_t Buffer_t;

  Buffer_t chain_buffer,bead_buffer;
  (*(this->begin()))->registerData(bead_buffer);

  chain_buffer.rewind();
  copyToBuffer(chain_buffer);

  HDFAttribIO<Buffer_t> mcout(chain_buffer);
  mcout.overwrite(h_config,"state");

  std::deque<Bead*>::iterator bead_it(this->begin());
  std::deque<Bead*>::iterator bead_end(this->end());
  //create the group and increment counter
  char GrpName[128];
  int ibead=0;
  while(bead_it != bead_end) {
    sprintf(GrpName,"bead%04d",ibead);
    hid_t bead_id = H5Gopen(h_config,GrpName);
    bead_buffer.rewind();
    Bead& bead(**bead_it);
    bead.copyToBuffer(bead_buffer);
    HDFAttribIO<Buffer_t> bout(bead_buffer);
    bout.overwrite(bead_id,"state");
    H5Gclose(bead_id);
    ++bead_it;
    ++ibead;
  }
}
Exemplo n.º 3
0
 void PDBtoCG::make_using_alpha_carbon()
 {
     int imp_all(0);
     for(std::vector<PDBChnSptr>::iterator iter = pure_pdb_style.begin();
         iter != pure_pdb_style.end(); ++iter)
     {
         bool filled(false);
         int counter(0);
         CGChnSptr chain(new CGChain);
         for(PDBChain::iterator aiter = (*iter)->begin();
             aiter != (*iter)->end(); ++aiter)
         {
             if(is_C_alpha((*aiter)->get_name()))
             {
                 ++counter;
                 Realvec pos((*aiter)->get_x(),
                             (*aiter)->get_y(),
                             (*aiter)->get_z());
                 BeadSptr bead(make_cg(*aiter, pos, imp_all, counter));
                 chain->push_back(bead);
                 if(!filled) filled = true;
             }
         }
         if(filled) cg_style_chain.push_back(chain);
         imp_all += counter;
     }
     return;
 }
Exemplo n.º 4
0
/** 
 * - MultiChain
 *   -- Version
 *   -- NumberOfBeads
 *   -- state: number of beads, grotwh direction etc, see MultiChain::copyToBuffer 
 *   -- bead0000
 *      -- state:  everything is stored in a buffer using PooledData<t>
 *      R, Drift, Multiple Gradients,
 *      properties, weights etc, see Bead::copyToBuffer
 */
void MultiChain::open(const string& aroot) {
  hid_t h_file=-1;
  string h5file=aroot+".config.h5";
  h_file  =  H5Fopen(h5file.c_str(),H5F_ACC_RDWR,H5P_DEFAULT);
  h_config = H5Gcreate(h_file,"MultiChain",0);
  int m_version=1;
  HDFAttribIO<int> v(m_version);
  v.write(h_config,"Version");

  int nc=Beads.size();
  HDFAttribIO<int> c(nc);
  c.write(h_config,"NumberOfBeads");

  //typedef Bead::PosType PosType;
  typedef Bead::RealType PosType;
  typedef Bead::Buffer_t Buffer_t;

  Buffer_t chain_buffer,bead_buffer;
  (*(this->begin()))->registerData(bead_buffer);
  nc=bead_buffer.size();
  HDFAttribIO<int> c2(nc);
  c2.write(h_config,"BufferSize");

  chain_buffer.rewind();
  copyToBuffer(chain_buffer);

  HDFAttribIO<Buffer_t> mcout(chain_buffer);
  mcout.write(h_config,"state");

  std::deque<Bead*>::iterator bead_it(this->begin());
  std::deque<Bead*>::iterator bead_end(this->end());
  //create the group and increment counter
  char GrpName[128];
  int ibead=0;
  while(bead_it != bead_end) {
    sprintf(GrpName,"bead%04d",ibead);
    hid_t bead_id = H5Gcreate(h_config,GrpName,0);

    bead_buffer.rewind();
    Bead& bead(**bead_it);
    bead.copyToBuffer(bead_buffer);
    HDFAttribIO<Buffer_t> bout(bead_buffer);
    bout.write(bead_id,"state");

    H5Gclose(bead_id);
    ++bead_it;
    ++ibead;
  }
  if(h_file>-1) H5Fclose(h_file);
}
Exemplo n.º 5
0
    BeadSptr PDBtoCG::make_cg(AtomSptr& atom, Realvec pos, int imp_all, int imp_local)
    {
        BeadSptr bead(new CGBead);
        bead->set_headder("ATOM  ");//header
        bead->set_imp(imp_all + imp_local);//imp
        bead->set_beadname("CA");//bead
        bead->set_seq(atom->get_resName());//seq
        bead->set_chainID(atom->get_chainID());//ID
        bead->set_iResNum(atom->get_resSeq()); //resNum
        bead->set_coordx(pos[0]);
        bead->set_coordy(pos[1]);
        bead->set_coordz(pos[2]);

        return bead;
    }
Exemplo n.º 6
0
chain::chain(int N, vector<chain>* Chains,mt19937 *engine,list<pair<int,int>> ***Zellen, double * xVal, double * yVal, double * zVal,int *xTimes,int *yTimes,int *zTimes)
{
	engineX=engine;

    this->Zellen=Zellen;

	uniform_real_distribution<> distribution(0, 1);
	auto rnd = bind(distribution, ref(*engineX));

	uniform_real_distribution<> PIdistribution(0, PI);
	auto rndPI = bind(PIdistribution, ref(*engineX));

	uniform_real_distribution<> NEGdistribution(-1, 1);
	auto rndWAY = bind(NEGdistribution, ref(*engineX));

	uniform_int_distribution<> INTdistribution(0, N-1);
	auto INTrnd = bind(INTdistribution, ref(*engineX));
//	cout << "Konstruktor Chain" << endl;
	this->Chains=Chains;
//	cout << "Pushe in Chains" << endl;
//	Chains->push_back(*this);
	this->N=N;
	vektor<double> x;
//	x=vektor<double>(rnd()*XMAX,rnd()*YMAX,rnd()*ZMAX);
//	x=vektor<double>(.5*XMAX,.5*YMAX,.5*ZMAX);
//	if(k==0) x=vektor<double>(.5*XMAX+1.5*x0,.5*YMAX+x0/2+.1,.5*ZMAX-1.*x0);
//	else x=vektor<double>(.5*XMAX+x0,.5*YMAX-x0/2,.5*ZMAX-.5*x0);
//	cout << "..." << endl;
//	Beads.push_back(x);

//    vektor<double> ex;

	for(int i=0;i<N;i++)
		{
//			cout << "Bead " << i << endl;
//			double phi=2*rndPI();
//			double theta=acos(1-2*rnd());
//			ex=vektor<double>(sin(theta)*cos(phi),sin(theta)*sin(phi),cos(theta));
//			ex=vektor<double>(sin(phi),cos(phi),1);
//			if(k==0) ex=vektor<double>(-1,0,0);
//			else ex=vektor<double>(0,0,-1);
//			ex=vektor<double>(1,0,0);
//			if(i<N/4) ex=vektor<double>(-1,0,0);
//			if(i==N/4) ex=vektor<double>(0,-1,0);
//			if(i>N/4 && i< N/2) ex=vektor<double>(1,0,1);
//			if(i>=N/2 && i<3*N/4) ex=vektor<double>(0,0,-1);
//			if(i==3*N/4 || i==3*N/4+1) ex=vektor<double>(0,1,0);
//			if(i>3*N/4+1) ex=vektor<double>(0,0,1);
//			ex=ex/ex.Betrag()*x0;
			//vektor<double> x=Beads.at(i-1).ort-ex;
			Beads.push_back(bead(xVal[i],yVal[i],zVal[i],xTimes[i],yTimes[i],zTimes[i]));
//			Beads.at(i).verschiebe(ex);
		}

    for(int i=0;i<N-1;i++)
    {
        Bonds.push_back(bond(&Beads.at(i),&Beads.at(i+1)));
        Zellen[int(Bonds.at(i).Schwerpunkt.x/(Zellgroesse))][int(Bonds.at(i).Schwerpunkt.y/(Zellgroesse))][int(Bonds.at(i).Schwerpunkt.z/(Zellgroesse))].push_back(make_pair(Chains->size(),i));
        Bonds.at(i).self=Zellen[int(Bonds.at(i).Schwerpunkt.x/(Zellgroesse))][int(Bonds.at(i).Schwerpunkt.y/(Zellgroesse))][int(Bonds.at(i).Schwerpunkt.z/(Zellgroesse))].end();
        Bonds.at(i).self--;
//        cout << "Füge Schwerpunkt";
//        Bonds.at(i).Schwerpunkt.Ausgabe();
//        cout << "in Zelle" << int(Bonds.at(i).Schwerpunkt.x)/(Zellgroesse) << int(Bonds.at(i).Schwerpunkt.y)/(Zellgroesse) <<int(Bonds.at(i).Schwerpunkt.z)/(Zellgroesse) << "ein" << endl;
    }




}
Exemplo n.º 7
0
chain::chain(int N, vector<chain>* Chains,mt19937 *engine ,  list<pair<int,int>> ***Zellen)
{
	engineX=engine;

    this->Zellen=Zellen;

	uniform_real_distribution<> distribution(0, 1);
	auto rnd = bind(distribution, ref(*engineX));

	uniform_real_distribution<> PIdistribution(0, PI);
	auto rndPI = bind(PIdistribution, ref(*engineX));

	uniform_real_distribution<> NEGdistribution(-1, 1);
	auto rndWAY = bind(NEGdistribution, ref(*engineX));


//	cout << "Konstruktor Chain" << endl;
	this->Chains=Chains;
//	cout << "Pushe in Chains" << endl;
//	Chains->push_back(*this);
	this->N=N;
	vektor<double> x;
	x=vektor<double>(rnd()*XMAX,rnd()*YMAX,rnd()*ZMAX);
//	x=vektor<double>(.5*XMAX,.5*YMAX,.5*ZMAX);
//	if(k==0) x=vektor<double>(.5*XMAX+1.5*x0,.5*YMAX+x0/2+.1,.5*ZMAX-1.*x0);
//	else x=vektor<double>(.5*XMAX+x0,.5*YMAX-x0/2,.5*ZMAX-.5*x0);
//	cout << "..." << endl;
	Beads.push_back(x);

    vektor<double> ex;
//    int xtimes=0;
//    int ytimes=0;
//    int ztimes=0;
	for(int i=1;i<N;i++)
		{
//			cout << "Bead " << i << endl;
			double phi=2*rndPI();
			double theta=acos(1-2*rnd());
			ex=vektor<double>(sin(theta)*cos(phi),sin(theta)*sin(phi),cos(theta));
//			ex=vektor<double>(sin(phi),cos(phi),1);
//			if(k==0) ex=vektor<double>(-1,0,0);
//			else ex=vektor<double>(0,0,-1);
//			ex=vektor<double>(1,0,0);
//			if(i<N/4) ex=vektor<double>(-1,0,0);
//			if(i==N/4) ex=vektor<double>(0,-1,0);
//			if(i>N/4 && i< N/2) ex=vektor<double>(1,0,1);
//			if(i>=N/2 && i<3*N/4) ex=vektor<double>(0,0,-1);
//			if(i==3*N/4 || i==3*N/4+1) ex=vektor<double>(0,1,0);
//			if(i>3*N/4+1) ex=vektor<double>(0,0,1);

			ex=ex/ex.Betrag()*x0;



			//vektor<double> x=Beads.at(i-1).ort-ex;
			Beads.push_back(bead(Beads.at(i-1).ort));
//			vektor<double> newOrt=Beads.at(i-1).ort.add(ex);
//			if (newOrt.x>XMAX) xtimes++;
//			else if(newOrt.x<0) xtimes--;
//			if (newOrt.y>YMAX) ytimes++;
//			else if(newOrt.y<0) ytimes--;
//			if (newOrt.x>XMAX) xtimes++;
//			else if(newOrt.x<0) xtimes--;
			Beads.at(i).verschiebe(ex);
			Beads.at(i).xtimes+=Beads.at(i-1).xtimes;
			Beads.at(i).ytimes+=Beads.at(i-1).ytimes;
			Beads.at(i).ztimes+=Beads.at(i-1).ztimes;
		}

    for(int i=0;i<N-1;i++)
    {
        Bonds.push_back(bond(&Beads.at(i),&Beads.at(i+1)));
        Zellen[int(Bonds.at(i).Schwerpunkt.x/(Zellgroesse))][int(Bonds.at(i).Schwerpunkt.y/(Zellgroesse))][int(Bonds.at(i).Schwerpunkt.z/(Zellgroesse))].push_back(make_pair(Chains->size(),i));
        Bonds.at(i).self=Zellen[int(Bonds.at(i).Schwerpunkt.x/(Zellgroesse))][int(Bonds.at(i).Schwerpunkt.y/(Zellgroesse))][int(Bonds.at(i).Schwerpunkt.z/(Zellgroesse))].end();
        Bonds.at(i).self--;
//        cout << "Füge Schwerpunkt";
//        Bonds.at(i).Schwerpunkt.Ausgabe();
//        cout << "in Zelle" << int(Bonds.at(i).Schwerpunkt.x)/(Zellgroesse) << int(Bonds.at(i).Schwerpunkt.y)/(Zellgroesse) <<int(Bonds.at(i).Schwerpunkt.z)/(Zellgroesse) << "ein" << endl;
    }
//    cout << "maxSize=" <<  midBead.max_size() << endl;




}
Exemplo n.º 8
0
bool MultiChain::read(hid_t grp){

  hid_t hgrp = H5Gopen(grp,"MultiChain");

  int m_version=1;
  HDFAttribIO<int> v(m_version);
  v.read(hgrp,"Version");

  int nc(0);
  HDFAttribIO<int> c(nc);
  c.read(hgrp,"NumberOfBeads");
  if(nc != Beads.size()) {
    WARNMSG("The number of chains is different. Previous = "  << nc << " Current = " << Beads.size())
  }

  typedef Bead::RealType PosType;
  typedef Bead::Buffer_t Buffer_t;

  Buffer_t chain_buffer,bead_buffer;
  (*(this->begin()))->registerData(bead_buffer);

  HDFAttribIO<int> c2(nc);
  c2.read(hgrp,"BufferSize");
  if(nc != bead_buffer.size()) {
    ERRORMSG("The buffer size is different. Ignore restart data")
        H5Gclose(hgrp);
    return false;
  }

  chain_buffer.rewind();
  copyToBuffer(chain_buffer);

  HDFAttribIO<Buffer_t> mcin(chain_buffer);
  mcin.read(hgrp,"state");
  chain_buffer.rewind();
  copyFromBuffer(chain_buffer);

  std::deque<Bead*>::iterator bead_it(this->begin());
  std::deque<Bead*>::iterator bead_end(this->end());
  //create the group and increment counter
  char GrpName[128];
  int ibead=0;
  while(bead_it != bead_end) {
    sprintf(GrpName,"bead%04d",ibead);
    hid_t bead_id = H5Gopen(hgrp,GrpName);

    Bead& bead(**bead_it);

    HDFAttribIO<Buffer_t> bout(bead_buffer);
    bout.read(bead_id,"state");

    bead_buffer.rewind();
    bead.copyFromBuffer(bead_buffer);

    H5Gclose(bead_id);
    ++bead_it;
    ++ibead;
  }

  H5Gclose(hgrp);

  return true;
}