예제 #1
0
int main(int argc, char *argv[]) {

    Options opt = setupOptions(argc, argv);

    vector<string> lines;
    MslTools::readTextFile(lines,opt.pdblist);

    for (uint i = 0; i < lines.size();i++){

	System sys;
	sys.readPdb(lines[i]);

	// Each chain
	for (uint c = 0; c < sys.chainSize();c++){

	    stringstream ss;

	    // Walk through residues
	    Chain &ch = sys.getChain(c);
	    
	    char tmp[100];
	    sprintf(tmp,"%s_%1s.pdb",MslTools::getFileName(lines[i]).c_str(),ch.getChainId().c_str());

	    ss << tmp;
	    PDBWriter pout;
	    pout.open(ss.str());
	    pout.write(ch.getAtomPointers());
	    pout.close();
	}

    }

	

}
예제 #2
0
int main(){

	cout << "Read a string pdb 'fourHelixBundle'"<<endl;
	PDBReader pdbin;
	pdbin.read(fourHelixBundle);
	pdbin.close();

	System sys;
	sys.addAtoms(pdbin.getAtomPointers());
	sys.writePdb("/tmp/preFusion.pdb");
	HelixFusion hf;
	cout << "Chain Sizes: "<<sys("A").positionSize()<<" "<<sys("B").positionSize()<<endl;
	hf.setChains(sys("A"),sys("B"));

	hf.fusionByAtomicAlignment(0.3);




	for (uint f = 0; f< hf.getNumberFusions();f++){
		Chain &newChain = hf.getFusedChain(f);
		PDBWriter pdbout;
		char name[80];
		sprintf(name,"/tmp/fusedChain-%04d.pdb",f);
		pdbout.open((string)name);
		pdbout.write(newChain.getAtomPointers());
		pdbout.close();
	}



	hf.fusionByHelicalFrames();
}
예제 #3
0
void OutputFinalPDBPos::doFinalize(long step) {
  PDBWriter writer;
  if (!writer.open(filename))
    THROWS("Can't open " << getId() << " '" << filename << "'.");

  writer.setComment("Time : " + toString(app->outputCache.getTime()) +
                    ", step : " + toString(step) +
                    (minimalImage ? ", minimal Image" : "") + ".");

  const Vector3DBlock *pos =
    (minimalImage ? app->outputCache.getMinimalPositions() : &app->positions);

  if (!writer.write(*pos, app->outputCache.getAtoms()))
    THROWS("Could not write " << getId() << " '" << filename << "'.");
}
예제 #4
0
int main(int argc, char *argv[]){
	// Option Parser
	Options opt = setupOptions(argc,argv);
	
	// Read PDB
	System sys;
	sys.readPdb(opt.pdb);
	if (!sys.getPDBReader()->doesFileExist()) {
		cerr << "Pdb file does not exist, failing.\n";
		exit(1111);
	}
	
	AtomPointerVector centerAtoms;
	if (opt.sele != "") {
	    AtomSelection as(sys.getAtomPointers());
	    char selStr[80];
	    sprintf(selStr,"%s",opt.sele.c_str());
	    centerAtoms = as.select(selStr);
	}
	else {
	    centerAtoms = sys.getAtomPointers();
	}
	AtomPointerVector allAtoms = sys.getAtomPointers();
	
	CartesianPoint total(0.,0.,0.);
	for (uint i = 0; i < centerAtoms.size(); i++) {
	    total += centerAtoms[i]->getCoor();
	}
	CartesianPoint avg = total/centerAtoms.size();
	cout << "Average: " << avg.getX() << "\t" << avg.getY() << "\t" << avg.getZ() << endl;
	
	CartesianPoint newCenter(opt.x, opt.y, opt.z);
	for (uint i = 0; i < allAtoms.size(); i++) {
	    allAtoms[i]->getCoor() -= avg;
	    allAtoms[i]->getCoor() += newCenter;
	}
	
	PDBWriter writer;
	writer.open(opt.outfile);
	if (!writer.write(allAtoms)) {
	   cerr << "Problem writing " << opt.outfile << endl;
	}
	writer.close();
	
	exit(0); 
}
예제 #5
0
int main(int argc, char *argv[]){

	
	// Option Parser
	Options opt = setupOptions(argc,argv);

	System initialSystem;
	initialSystem.readPdb(opt.pdb);

	Quench quencher(opt.topfile, opt.parfile, opt.rotlib);


	// Set the number of rotamers you want for large and small side chains, respectively
	quencher.setVariableNumberRotamers(50,5);


	//System sys = quencher.runQuench(initialSystem);



	// Set which positions you want to repack (optional)
	vector<int> variablePositions;
	variablePositions.push_back(0);
	variablePositions.push_back(1);
	variablePositions.push_back(2);
	variablePositions.push_back(3);
	variablePositions.push_back(4);
	// Could instead use: variablePositions.push_back(initialSystem.getPositionIndex("A", "73");

	System sys = quencher.runQuench(initialSystem, variablePositions);
	// For all positions, use: System sys = quencher.runQuench(initialSystem);

	stringstream ss;
	ss << "/tmp/currentConformation.pdb";
	string filename = ss.str();
	cout << "Write pdb " << filename << endl;
	PDBWriter writer;
	writer.open(filename);
	if (!writer.write(sys.getAtomPointers())) {
		cerr << "Problem writing " << filename << endl;
	}
	writer.close();

}
예제 #6
0
int main(int argc, char *argv[]){
	// Option Parser
	Options opt = setupOptions(argc,argv);
	Transforms tr;

	// Super-helical Radius Loop
	for (double sr = opt.superHelicalRadius[0]; sr <= opt.superHelicalRadius[1]; sr += opt.superHelicalRadius[2]){

		// Alpha-helical Phase Angle Loop
		for (double aph = opt.alphaHelicalPhaseAngle[0]; aph < opt.alphaHelicalPhaseAngle[1];aph+=opt.alphaHelicalPhaseAngle[2]){

		  // Super-helical Pitch Angle loop added by David Slochower
		  for(double shpa = opt.superHelicalPitchAngle[0]; shpa < opt.superHelicalPitchAngle[1]; shpa+=opt.superHelicalPitchAngle[2]) {
		    double shPitch = (2*M_PI*sr)/tan(M_PI*shpa/180);

			// Generate a coiled helix
			CoiledCoils cc;
			// Values used for previous work: cc.northCoiledCoils(sr, 1.5232, shPitch, 2.25, opt.numberOfResidues, 103.195, aph);
			// March 31, 2010: Jason Donald
			// Hard code values of h (rise/residue) = 1.51, r1 (alpha-helical radius), and theta (alpha helical frequency)
                        // based on median values observed by Gevorg Grigoryan
			//cc.northCoiledCoils(sr, 1.51, shPitch, 2.26, opt.numberOfResidues, 102.8, aph);
			
			AtomPointerVector coil = cc.getCoiledCoil(sr, 1.51, shPitch, 2.26, 102.8, aph, 0.0,opt.numberOfResidues); 

			// Apply symmetry operations to create a bundle
			int C_axis = atoi(opt.symmetry.substr(1,(opt.symmetry.length()-1)).c_str());
			if (opt.symmetry.substr(0,1) == "C"){
				Symmetry sym;
				sym.applyCN(coil,C_axis);
	
				// Write out bundle
				char filename[80];
				sprintf(filename, "%s_%s_%03d_%05.2f_%05.2f_shp%05.2f.pdb", opt.name.c_str(),opt.symmetry.c_str(),opt.numberOfResidues, sr, aph, shpa);
			
				cout << "Writing "<<filename<<endl;
				PDBWriter pout;
				pout.open(filename);
				pout.write(sym.getAtomPointers());
				pout.close();
			}	
			else if (opt.symmetry.substr(0,1) == "D"){
				// Z Rotate 
				for (double spa = opt.superHelicalPhaseAngle[0]; spa < opt.superHelicalPhaseAngle[1]; spa += opt.superHelicalPhaseAngle[2]){
					coil.clearSavedCoor();
					coil.saveCoor("preSPA");

					Matrix zRot = CartesianGeometry::getZRotationMatrix(spa);
					//coil.rotate(zRot);
					tr.rotate(coil, zRot);
					
					// Z Trans
					for (double ztrans = opt.d2zTranslation[0];ztrans < opt.d2zTranslation[1]; ztrans += opt.d2zTranslation[2]){
						coil.saveCoor("preZtrans");

						CartesianPoint z(0,0,ztrans);
						//coil.translate(z);
						tr.translate(coil, z);

						Symmetry sym;
						sym.applyDN(coil,C_axis);
								
						// Write out bundle
						char filename[80];
						sprintf(filename, "%s_%s_%03d_%05.2f_%05.2f_shp%05.2f_%05.2f_%05.2f.pdb", opt.name.c_str(),opt.symmetry.c_str(),opt.numberOfResidues,sr, aph, shpa, spa, ztrans);
			
						cout << "Writing "<<filename<<endl;
						PDBWriter pout;
						pout.open(filename);
						pout.write(sym.getAtomPointers());
						pout.close();

						coil.applySavedCoor("preZtrans");
					} // Ztrans
					coil.applySavedCoor("preSPA");
				} // SHA
			} 
                }
           }
	}
}
예제 #7
0
/******************************************
 *  
 *         =======  MAIN  =======
 *
 ******************************************/
int main(int argc, char *argv[]) {


        // Define Objects for the test
	CoiledCoils cc;
	CoiledCoilFitter ccf;
	PDBWriter pout;

	/******************************************************************************
	 *
	 *                   === GEVORG/CRICKS CC GENERATION ===
	 *
	 ******************************************************************************/





	//sys.writePdb(opt.fileName);
	cc.getCoiledCoilCricks(4.910, -4.027, -13.530, 2.267, 102.806, 149.984, 0.0, 26);
	AtomPointerVector cricks = cc.getAtomPointers();
	pout.open("/tmp/cricks.pdb");
	pout.write(cricks);
	pout.close();

	double shr = 4.910;
	double risePerRes = 1.51;
	double shp = 128.206;
	double ahr = 2.26;
	double ahp = 102.8;
	double ahphase = 149.984;
	double dZ  = 0.0; //meaningless parameter at the moment.
	cc.getCoiledCoil(shr, risePerRes, shp, ahr, ahp, ahphase, dZ, 26);
	AtomPointerVector norths = cc.getAtomPointers();
	pout.open("/tmp/norths.pdb");
	pout.write(norths);
	pout.close();

	Symmetry sym;
	sym.applyCN(norths,2);
	pout.open("/tmp/northC2.pdb");
	pout.write(sym.getAtomPointers());
	pout.close();

	System sys;
	sys.readPdb("/tmp/northC2.pdb");

	// Fitting procedure..

	// Add helix chain A
	ccf.addNextHelix(&sys.getChain("A").getAtomPointers());

	// Add helix chain B
	ccf.addNextHelix(&sys.getChain("B").getAtomPointers());	

	// Set symmetry
	ccf.setSymmetry("C");

	// Do fittin procedure
	ccf.fit();

	// Do something else..
	vector<double> params = ccf.getMinimizedParameters();

	if ( abs(params[0] - shr) > 0.1){
	  cerr << "ERROR Super-helical radius is off. Target = "<<shr<<" MinValue = "<<params[0]<<endl;
	} else if (abs(params[1] - risePerRes) > 0.1){
	  cerr << "ERROR RisePerRes is off. Target = "<<risePerRes<<" MinValue = "<<params[1]<<endl;
	} else if (abs(params[2] - shp) > 0.1){
	  cerr << "ERROR Super-helical pitch is off. Target = "<<shp<<" MinValue = "<<params[2]<<endl;
	} else if (abs(params[3] - ahr) > 0.1){
	  cerr << "ERROR Alpha-helical radius is off. Target = "<<ahr<<" MinValue = "<<params[3]<<endl;
	} else if (abs(params[4] - ahp) > 0.1){
	  cerr << "ERROR Alpha-helical pitch is off. Target = "<<ahp<<" MinValue = "<<params[4]<<endl;
	} else if (abs(params[5] - ahphase) > 0.1){
	  cerr << "ERROR Alpha-helical phase is off. Target = "<<ahphase<<" MinValue = "<<params[5]<<endl;
	} else if (abs(params[6] - dZ) > 0.1){
	  cerr << "ERROR deltaZ offset is off. Target = "<<dZ<<" MinValue = "<<params[6]<<endl;
	} else {
	  cout << "LEAD";
	}



}
예제 #8
0
void ManageDistanceMatrixResults::printResults(){

	cout << "Number of results to print: "<<allResults.size()<<endl;
 
	int numberAligned = 0;
	ofstream seqOut1;
	ofstream seqOut2;
	if (alignPdbs){
		seqOut1.open("seqAlignment1.txt", ios::out|ios::app);
		seqOut2.open("seqAlignment2.txt", ios::out|ios::app);
	}

	for (int i=0; i<allResults.size(); i++){


		//retrieve distance matrices
		DistanceMatrix dm1 = allResults[i][0].getDistanceMatrix1();
		DistanceMatrix dm2 = allResults[i][0].getDistanceMatrix2();
	
		//retrieve lists of matrix windows
		//print the name of PDBs we're comparing
		string PDBName1 = getFileName(dm1.getPDBid());
		string PDBName1Short = PDBName1.substr(0,17);

		string PDBName2 = getFileName(dm2.getPDBid());
		string PDBName2Short = PDBName2.substr(0,17);

		cout<<"Comparing PDBs: "<<PDBName1Short<<", "<<PDBName2Short<<endl;

	
		//for two fixed DM's (dm1, dm2), access and print the multiCompare results
		for(int j=0; j<allResults[i].size(); j++){

			//retrieve winning MWs and score from the Result
			DistanceMatrixResult & currentResult = allResults[i][j];
	    
			double minLikeness = currentResult.getLikeness(); 
			// compare function failed. Nothing to print--result has null windows. 
			if(minLikeness==1000000){
				cout<<"Badness, badness everywhere."<<endl;
				continue; //the compareFunction didn't find any matches
			} 

			MatrixWindow & minWindow1 = currentResult.getMatrixWindow1();
			MatrixWindow & minWindow2 = currentResult.getMatrixWindow2();
	    
			//print information
			int i1 = (minWindow1).getLeftR();
			int j1 = (minWindow1).getLeftC();
			int i2 = (minWindow2).getLeftR();
			int j2 = (minWindow2).getLeftC();
     
			string i1ID = dm1.getAtomVector()[i1]->getSegID().c_str();
			string j1ID = dm1.getAtomVector()[j1]->getSegID().c_str();
			string i2ID = dm2.getAtomVector()[i2]->getSegID().c_str();
			string j2ID = dm2.getAtomVector()[j2]->getSegID().c_str();
    
			if(i1ID=="" || j1ID=="" || i2ID=="" ||j2ID==""){
   
				i1ID = dm1.getAtomVector()[i1]->getChainId().c_str();
				j1ID = dm1.getAtomVector()[j1]->getChainId().c_str();
				i2ID = dm2.getAtomVector()[i2]->getChainId().c_str();
				j2ID = dm2.getAtomVector()[j2]->getChainId().c_str();
			}//end if

			int i1res = dm1.getAtomVector()[i1]->getResidueNumber();
			int j1res = dm1.getAtomVector()[j1]->getResidueNumber();
			int i2res = dm2.getAtomVector()[i2]->getResidueNumber();
			int j2res = dm2.getAtomVector()[j2]->getResidueNumber();


			fprintf(stdout, "\t\tWindow1 %3d,%3d (Residues: %1s %3d, %1s %3d)\tWindow2 %3d,%3d (Residues: %1s %3d, %1s %3d)\t%8.3f\n", i1, j1, i1ID.c_str(), i1res, j1ID.c_str(), j1res, i2, j2, i2ID.c_str(), i2res, j2ID.c_str(), j2res, minLikeness);


			if (alignPdbs){

			
				// Get AtomVectors of matching windows
				AtomPointerVector ca1 = minWindow1.getSmallAVec();
				AtomPointerVector ca2 = minWindow2.getSmallAVec();
//for(int i=0; i<ca2.size();i++) cout<<*ca2[i]<<endl;

				// Read PDB1 in 
				PDBReader r1;
				r1.open(dm1.getPDBid());
				r1.read();
				r1.close();
				AtomPointerVector &ref = r1.getAtomPointers();
				if (ref.size() == 0){
					cerr << "ERRROR 3453 in ManageDistanceMatrixResults::printResults while aligning pdbs, ref pdb not found?: "<<dm1.getPDBid()<<endl;
					exit(3453);
				}


				

				PDBReader r2;
				r2.open(dm2.getPDBid());
				r2.read();
				r2.close();
				AtomPointerVector &vec = r2.getAtomPointers();



				Transforms t;		    
//for(int i=0; i<vec.size();i++) cout<<*vec[i]<<endl;
//cout<<endl;
//				cout << ca2.size() << "\t" << ca1.size() << "\t" << vec.size() << endl;
				bool result = t.rmsdAlignment(ca2,ca1, vec);
// This align is to a get vec (full pdb coordinates)
//ca2,ca1 did not changed; vec changed
				if (!result){
					cerr << "Alignment has failed!"<<endl;
					exit(1211);
				}

				
				ca2.saveCoor("pre");
// here record old ca2 coordinates

				result = t.rmsdAlignment(ca2,ca1);
// this align is to get a new ca2 to calculate rmsd
				if (!result){
					cerr << "Alignment has failed!"<<endl;
					exit(1212);
				}
				
				double rmsd=ca1.rmsd(ca2);
				cout << "RMSD: "<<rmsd<<endl;
				if (rmsd <= rmsdTol){
// a smaller rmsd is to get optimized structures

					numberAligned++;
/*
					// Write out aligned PDB for dm2
					char a[80];
					sprintf(a, "%s.aligned.%5.3f.pdb",MslTools::getFileName(dm2.getPDBid()).c_str(),rmsd);

					PDBWriter w;
					w.open(a);
					w.write(vec);
					w.close();
*/

					// Setup a Polymer Sequence to print out the alignment...

					/*
					   Since chain A in dm1 can match chain A or chain B in dm2 , everything is named chain1 and chain2.
					   
					   Procedure:
					   1. Get chain1 and chain2 from all AtomVectors (ca1,ca2,ref) ; ref = ca1 , but includes all of the residues.
					   2. Create sequences for chain1s
					   3. Create a PolymerSequence for chain1s and print out.
					   .. chain2s

					 */
					AtomSelection selWin1(ca1);
					AtomPointerVector win1Ch1 = selWin1.select("chain "+ca1(0).getChainId()); 
					AtomPointerVector win1Ch2 = selWin1.select("chain "+ca1(ca1.size()/2).getChainId()); 

					AtomSelection selWin2(ca2);
					AtomPointerVector win2Ch1 = selWin2.select("chain "+ca2(0).getChainId()); 
					AtomPointerVector win2Ch2 = selWin2.select("chain "+ca2(ca2.size()/2).getChainId()); 

					AtomSelection selRef(ref);
					AtomPointerVector refCh1 = selRef.select("chain "+ca1(0).getChainId()); 
					AtomPointerVector refCh2 = selRef.select("chain "+ca1(ca2.size()/2).getChainId()); 

                                        // Write out aligned PDB for dm2
                                        char a[80];
                                        sprintf(a, "%s.aligned.%5.3f.pdb",MslTools::getFileName(dm2.getPDBid()).c_str(),rmsd);
//                                        sprintf(a, "SEQ.%s.SEQ.%s.%s.aligned.%5.3f.pdb",refCh1(0).getChainId().c_str(),refCh2(0).getChainId().c_str(),MslTools::getFileName(dm2.getPDBid()).c_str(),rmsd);

                                        PDBWriter w;
                                        w.open(a);
                                        w.write(vec);
//					w.write(ca2);
                                        w.close();

					// Create an input sequence for chain 1
					stringstream seqStr1;
					seqStr1 << win2Ch1(0).getChainId()<<" "<<win2Ch1(0).getResidueNumber()<<": ";
					seqStr1 << PolymerSequence::toThreeLetterCode(win2Ch1);
//seqStr1 << PolymerSequence::toOneLetterCode(win2Ch1); // it does not work as the whole one-letter code and "X" will be printed out as an unrecognized amino acid
//cout<<seqStr1.str()<<endl;
//for(int i=0; i<win2Ch1.size();i++) cout<<win2Ch1[i]->getResidueNumber()<<" "<<*win2Ch1[i]<<endl;
					// Create a polymer sequence for chain A
					PolymerSequence poly1;
					poly1.setName("SEQ"+refCh1(0).getChainId()+"-"+MslTools::getFileName(dm2.getPDBid()));
					poly1.setSequence(seqStr1.str());
poly1.setReferenceSequence(PolymerSequence::toOneLetterCode(refCh1).c_str(),"SEQ"+refCh1(0).getChainId()+"-REF-"+MslTools::getFileName(dm1.getPDBid()).c_str(),1,win1Ch1[0]->getResidueNumber(),win2Ch1[0]->getResidueNumber());
//cout <<"win1Ch1[0]->getResidueNumber(): "<<win1Ch1[0]->getResidueNumber()<<" win2Ch1([0]->getResidueNumber(): "<<win2Ch1[0]->getResidueNumber()<<endl;
//					poly1.setReferenceSequence(MslTools::getOneLetterCode(refCh1),"SEQ"+refCh1(0).getChainId().c_str()+"-REF",refCh1(0).getResidueNumber(),win1Ch1(0).getResidueNumber());


//cout<<poly1<<endl;
/*
vector<vector<vector<string> > > sequences = poly1.getSequence();
for(vector<vector<vector<string> > >::iterator it = sequences.begin(); it != sequences.end(); ++it) {
	for(vector<vector<string> >::iterator it2 = it->begin(); it2 != it->end(); ++it2) {
		for(vector<string>::iterator it3 = it2->begin(); it3 != it2->end(); ++it3) {
			cout << *it3 <<" ";
		}
	}
}
cout <<endl;
*/
					stringstream seqStr2;
					seqStr2 << win2Ch2(0).getChainId()<<" "<<win2Ch2(0).getResidueNumber()<<": ";
					seqStr2 << PolymerSequence::toThreeLetterCode(win2Ch2);
//seqStr2 << PolymerSequence::toOneLetterCode(win2Ch2);

					// Create a polymer sequence for chain A
					PolymerSequence poly2;
					poly2.setName("SEQ"+refCh2(0).getChainId()+"-"+MslTools::getFileName(dm2.getPDBid()));
					poly2.setSequence(seqStr2.str());
//					poly2.setReferenceSequence(MslTools::getOneLetterCode(refCh2),"SEQ"+refCh2(0).getChainId()+"-REF", refCh2(0).getResidueNumber(),win1Ch2(0).getResidueNumber());
poly2.setReferenceSequence(PolymerSequence::toOneLetterCode(refCh2),"SEQ"+refCh2(0).getChainId()+"-REF-"+MslTools::getFileName(dm1.getPDBid()).c_str(),1,win1Ch2[0]->getResidueNumber(),win2Ch2[0]->getResidueNumber());

					if (numberAligned == 1){
						seqOut1 << poly1.getReferenceHeader();
						seqOut2 << poly2.getReferenceHeader();
					}
					

					seqOut1 << poly1;
					seqOut2 << poly2;


				}

				ca2.applySavedCoor("pre");
		    // ca2 is changed to its former value
			}

		}//end for on j


	}//end for on i

	seqOut1.close();
	seqOut2.close();

}
int main(int argc, char *argv[]) {

	// the program requires the location of the "exampleFiles" as an argument
	if (argc < 1) {
		cerr << "USAGE:\nexample_coiled_coil_and_symmetric_bundles" << endl;
		exit(0);
	}

	cout << "  ***************************************************************************************" << endl;
	cout << "" << endl;
	cout << "     How to generate coiled-coils in MSL (" << MslTools::getMSLversion() << ")   " << endl;
	cout << "" << endl;
	cout << "  ***************************************************************************************" << endl;
	cout << endl;
	cout << endl;

	// CoiledCoils object used to create a coiled helix (by a number of algorithms)
	CoiledCoils cc;

	// A super-helical radius
	double sr = 6.5;

	// An alpha-helical phase angle
	double aph = 0.0;

	// A super-helical pitch angle, and pitch distance
	double shpa = 190;
	double shPitch = (2*M_PI*sr)/tan(M_PI*shpa/180);

	// Hard code values of h (rise/residue) = 1.51, r1 (alpha-helical radius), and theta (alpha helical frequency)
	double risePerResidue = 1.51;

        // Use observed medians by Gevorg Grigoryan (Probing Deisgnability via a Generalized Model of Helical Bundle Geometry, JMB 2010)
	double alphaHelicalRadius = 2.26;
	double alphaHelicalFrequency = 102.8;

	// Number of residues in coil ( lets do 4 heptads = 28 residues )
	double numberOfResidues = 28;

	// Generate a coiled coil, using specified parameters
    	//cc.northCoiledCoils(sr, risePerResidue, shPitch, alphaHelicalRadius, numberOfResidues, alphaHelicalFrequency, aph);

	// dZ
	double dZ = 0.0;

	// Get the atoms from the CoiledCoils object back (this is a single coiled-coil helix)
	AtomPointerVector coil = cc.getCoiledCoil(sr, risePerResidue, shPitch, alphaHelicalRadius, alphaHelicalFrequency,dZ, aph,numberOfResidues);

	cout << "Writing /tmp/singleHelixCoil.pdb"<<endl;
	PDBWriter pout;
	pout.open("/tmp/singleHelixCoil.pdb");
	pout.write(coil);
	pout.close();

	// Create a symmtery object to generate a coiled bundle ( C4 symmetric )
	Symmetry sym;

	// Apply C4 to "coil"
	sym.applyCN(coil,4);
	cout << "Writing /tmp/C4HelixCoil.pdb"<<endl;
	pout.open("/tmp/C4HelixCoil.pdb");
	pout.write(sym.getAtomPointers());
	pout.close();

	
}
예제 #10
0
int main(int argc, char *argv[]) {

	Options opt = setupOptions(argc, argv);

	cout << "Read in PDB structure"<<endl;
	System initSys;
	initSys.readPdb(opt.pdb);

	initSys.writePdb("/tmp/init.pdb");

	// Read through and mark positions that don't have full side chains?
	CharmmTopologyReader CTR(opt.topfile);
	CTR.read();

	vector<int> residuesToFill;
	for (uint r = 0; r < initSys.positionSize();r++){

		Residue &res = initSys.getResidue(r);

		// Default to HSD for HIS
		if (res.getResidueName() == "HIS") res.setResidueName("HSD");

		if (!CTR.residueExists(res.getResidueName())){
			cerr << "ERROR 2222 Residue: "<<res.toString()<<" ; residue type does not exist in topology file: "<<opt.topfile<<endl;
			exit(2222);
		}
		

		vector<string> topologyAtoms = CTR.getResidue(res.getResidueName()).getAllTopoAtomNames();

		for (uint t = 0; t < topologyAtoms.size();t++){
			
			// Skip over hydrogen atoms..
			if (topologyAtoms[t].substr(0,1) == "H") continue;

			// If ILE and CD, look for CD1
			if (res.getResidueName() == "ILE" && topologyAtoms[t] == "CD" && !res.atomExists(topologyAtoms[t]) && res.atomExists("CD1")){
				//res.getAtom("CD1").setName("CD");
				//res.updateAtomMap(res.getAtom("CD1"));
				continue;
			}


			if (!res.atomExists(topologyAtoms[t])){
				
				residuesToFill.push_back(r);
				cout << "*** Residue to fill: "<<res.toString()<<" due to atom from topology not found in pdb: "<<topologyAtoms[t]<<endl;
				break;
			}
		}

	}


	PolymerSequence seq(initSys);

	cout << "Build Charmm System"<<endl;
	System sys;

	CharmmSystemBuilder CSB(sys,opt.topfile,opt.parfile);
	CSB.setBuildNonBondedInteractions(false);
	CSB.buildSystem(seq);



	int numAssignedAtoms = sys.assignCoordinates(initSys.getAtomPointers());
	fprintf(stdout, "\tNumber of assigned atoms: %8d\n",numAssignedAtoms);
	if (numAssignedAtoms == 0){
		cerr << "ERROR 2222 zero assigned atoms, means after re-building from sequence we can not match chain,residue numbers with original coordinates.\n";
		exit(2222);
	}

	sys.buildAllAtoms();


	if (opt.debug) {
		string filename = "/tmp/initialBuild.pdb";
		cout << "Write initial build pdb " << filename << endl;
		PDBWriter writer;
		writer.open(filename);
		if (!writer.write(sys.getAtomPointers())) {
			cerr << "Problem writing " << filename << endl;
		}
		writer.close();
	}


	cout << "Read rotamer library " << opt.rotlib << " and load rotamers"<<endl;	

	SystemRotamerLoader sysRot(sys, opt.rotlib);


	// For each residue to fill add 100 rotamers
	for (uint r = 0; r < residuesToFill.size();r++){

		Residue  &res = sys.getResidue(residuesToFill[r]);
		Position *pos = res.getParentPosition();

		//sysRot.loadRotamers(pos, "BALANCED-200",res.getResidueName(),0,99);
		sysRot.loadRotamers(pos,res.getResidueName(),0,99,"");

	}

	
	// Quencher-type
	CharmmEnergyCalculator calculator(opt.parfile);
	for (uint p = 0; p < sys.positionSize();p++){
		Position &pos = sys.getPosition(p);

		if (pos.getTotalNumberOfRotamers() > 1){


			double minEnergy = MslTools::doubleMax;
			int    minIndex  = -1;
			for (uint c = 0; c < pos.getTotalNumberOfRotamers();c++){
				double self = calculator.calculateSelfEnergy(sys,p,c);
				double temp = calculator.calculateTemplateEnergy(sys,p,c);	


				if (temp+self < minEnergy){
					minEnergy = temp+self;
					minIndex  = c;
				}

			}

			if (minIndex == -1){
				cerr << "ERROR 8754 on position "<<pos.getCurrentIdentity().toString()<< " no low energy rotamer ? .. do nothing and continue."<<endl;
				continue;
			}

			// Set to lowest self+template energy rotamer.
			cout << "*** Setting "<<pos.getCurrentIdentity().toString()<<" to rotamer "<<minIndex<<" with self+template energy = "<<minEnergy<<endl;
			pos.setActiveRotamer(minIndex);

		}
	}


	
	sys.writePdb(opt.outpdb);
	
}