Exemple #1
0
int main(int argc, char** argv)
{
	Path path;
	String tmp;
	String configuration_string = "";

	CommandlineParser parpars("SLICK", "scoring protein-carbohydrate interactions", VERSION, String(__DATE__), "Scoring");
	parpars.registerFlag("E", "compute only SLICKEnergy");
	parpars.registerFlag("S", "compute only SLICKScore");
	parpars.registerFlag("u", "unite atoms");
	parpars.registerFlag("n", "read radius rules for the nonpolar solvation from FILE");
	parpars.registerFlag("N", "scale nonpolar radii by FACTOR");
	parpars.registerFlag("log", "write log file");
	parpars.registerMandatoryInputFile("rec", "input receptor file");
	parpars.registerMandatoryInputFile("lig", "input ligand file");
	parpars.registerOptionalInputFile("cr", "charge rules");
	parpars.registerOptionalInputFile("pr", "radius rules for the polar solvation");
	parpars.registerOptionalInputFile("lj", "use FILE for LJ parameters");
	parpars.registerOptionalInputFile("op", "read options from FILE (command line overrides!)");
	parpars.registerOptionalIntegerParameter("v", "verbosity to level");
	parpars.registerOptionalDoubleParameter("s", "scaling factor for receptor charges");
	parpars.registerOptionalDoubleParameter("t", "scaling factor for ligand charges");
	parpars.setSupportedFormats("rec","PDB");
	parpars.setSupportedFormats("lig","HIN");
	parpars.setSupportedFormats("cr","rul");
	parpars.setSupportedFormats("pr","rul");
	parpars.setSupportedFormats("lj","rul");
	parpars.setSupportedFormats("op", "ini");

	String man = "This tool calculates the SLICKEnergy / SLICK Score for protein-carbohydrate complexes.";
	parpars.setToolManual(man);

	parpars.parse(argc, argv);

	Options options;
	ScoringFunction::getDefaultOptions(options);

	unsigned int verbosity = 0;
	if (parpars.get("v") != CommandlineParser::NOT_FOUND)
	{
		verbosity = parpars.get("v").toInt();
		options.setInteger("verbosity", verbosity);
	}

	float receptor_charge_scaling_factor = 1.0f;
	if (parpars.get("s") != CommandlineParser::NOT_FOUND)
	{
		receptor_charge_scaling_factor = parpars.get("s").toFloat();
		configuration_string += "scale_receptor_charges " + parpars.get("s") + "\n";
	}

	float ligand_charge_scaling_factor = 1.0f;
	if (parpars.get("t") != CommandlineParser::NOT_FOUND)
	{
		ligand_charge_scaling_factor = parpars.get("t").toFloat();
		configuration_string += "scale_ligand_charges " + parpars.get("t") + "\n";
	}

	String protein_file_name = parpars.get("rec");
	if (protein_file_name == CommandlineParser::NOT_FOUND)
	{
		Log.error() << "Missing protein file name." << endl;
		return 1;
	}
	configuration_string += "protein_file_name " + protein_file_name + "\n";

	String ligand_file_name = parpars.get("lig");
	if (ligand_file_name == CommandlineParser::NOT_FOUND)
	{
		Log.error() << "Missing ligand file name." << endl;
		return 1;
	}
	configuration_string += "ligand_file_name " + ligand_file_name + "\n";

	if (verbosity > 0)
	{
		Log.info() << "Initializing residue checker." << endl;
	}
	FragmentDB db("fragments/Fragments.db");
	ResidueChecker check(db);


	time_t rawtime;
	time(&rawtime);
	String time_string("start: " + String(asctime(localtime(&rawtime))));

	// now load the molecules and assign radii and charges depending on
	// what the user wants
	System system;

	PDBFile protein_file(protein_file_name);
	protein_file >> system;
	protein_file.close();
	Molecule* protein = system.getMolecule(0);

	if (verbosity > 0)
	{
		Log.info() << "Normalizing names (protein)." << endl;
	}
	system.apply(db.normalize_names);

	if (verbosity > 0)
	{
		Log.info() << "Building bonds (protein)." << endl;
	}
	system.apply(db.build_bonds);

	HINFile ligand_hin_file;
	ligand_hin_file.open(ligand_file_name);
	ligand_hin_file >> system;
	ligand_hin_file.close();
	Molecule* ligand = system.getMolecule(1);


	// Read and apply charge rules
	String charge_rule_file_name = parpars.get("cr");
	if (charge_rule_file_name == CommandlineParser::NOT_FOUND)
	{
		charge_rule_file_name = "solvation/PARSE+ions.rul";
	}
	else
	{
		configuration_string += "use_charge_rules " + charge_rule_file_name + "\n";

		tmp = path.find(charge_rule_file_name);
		if (tmp != "")
		{
			charge_rule_file_name = tmp;
		}

		if (verbosity > 0)
		{
			Log.info() << "Using " << charge_rule_file_name << " as charge rule file" << endl;
		}

		INIFile charge_ini(charge_rule_file_name);
		charge_ini.read();
		ChargeRuleProcessor charge_rules(charge_ini);
		system.apply(charge_rules);
	}


	// Read and apply polar charge rules
	String polar_radius_rule_file_name = parpars.get("pr");
	if (polar_radius_rule_file_name == CommandlineParser::NOT_FOUND)
	{
		polar_radius_rule_file_name = "solvation/PARSE+ions.rul";
	}
	else
	{
		configuration_string += "use_polar_radius_rules " + polar_radius_rule_file_name + "\n";

		tmp = path.find(polar_radius_rule_file_name);
		if (tmp != "")
		{
			polar_radius_rule_file_name = tmp;
		}
		if (verbosity > 0)
		{
			Log.info() << "Using " << polar_radius_rule_file_name << " as polar radius rule file" << endl;
		}

		INIFile radius_ini(polar_radius_rule_file_name);
		radius_ini.read();
		RadiusRuleProcessor radius_rules(radius_ini);
		system.apply(radius_rules);
	}

	if (verbosity > 8)
	{
		Log.info() << "system statistics:" << endl;
		Log.info() << "molecules: " << system.countMolecules() << endl;
		Log.info() << "proteins:  " << system.countProteins() << endl;
		Log.info() << "fragments: " << system.countFragments() << endl;
		Log.info() << "atoms:     " << system.countAtoms() << endl;
	}


	// check for uassigned type names
	AtomIterator it;
	int count = 0;
	for (it = system.beginAtom(); +it; ++it)
	{
		count++;
		if (it->getElement().getSymbol() == "?")
		{
			Log.info() << "Got symbol \"?\": " << it->getFullName() << endl;
		}
		if (it->getCharge() > 8.0)
		{
			Log.error() << "Mysterious charge: " << it->getCharge() << "\t"
				<< it->getFullName() << "\t" << count << "\t" << it->getElement().getSymbol() << endl;
		}
	}

	// scale charges
	if (verbosity > 0)
	{
		Log.info() << "Scaling receptor charges by " << receptor_charge_scaling_factor << endl;
	}
	if (parpars.has("s"))
	{
		for (it = protein->beginAtom(); +it; ++it)
		{
			it->setCharge(it->getCharge() * receptor_charge_scaling_factor);
		}
	}

	if (verbosity > 0)
	{
		Log.info() << "Scaling ligand charges by " << ligand_charge_scaling_factor << endl;
	}
	if (parpars.has("t"))
	{
		for (it = ligand->beginAtom(); +it; ++it)
		{
			it->setCharge(it->getCharge() * ligand_charge_scaling_factor);
		}
	}


	String options_file_name = parpars.get("op");
	if (options_file_name != CommandlineParser::NOT_FOUND)
	{
		options.readOptionFile(options_file_name);
		configuration_string += "read_options_file " + options_file_name;
	}

	String lj_parameter_file_name = parpars.get("lj");
	if (lj_parameter_file_name == CommandlineParser::NOT_FOUND)
	{
		lj_parameter_file_name = "Amber/amber94gly.ini";
	}
	else
	{
		configuration_string = configuration_string + "lj_parameter_file_name " + lj_parameter_file_name;
	}

	options.set(VanDerWaalsSlick::Option::LENNARD_JONES_FILE, lj_parameter_file_name);

	if (parpars.has("u"))
	{
		options.setBool(PolarSolvation::Option::UNITE_ATOMS, true);
		cout << "Uniting atoms." << endl;
		configuration_string += "unite_atoms true\n";
	}
	else
	{
		options.setBool(PolarSolvation::Option::UNITE_ATOMS, false);
		cout << "Not uniting atoms." << endl;
	}

	String nonpolar_radius_rule_file_name = parpars.get("n");
	if (nonpolar_radius_rule_file_name == CommandlineParser::NOT_FOUND)
	{
		nonpolar_radius_rule_file_name = "solvation/bondi.rul";
	}
	else
	{
		cout << "Using " << nonpolar_radius_rule_file_name << " for nonpolar radii" << endl;
		configuration_string += "use_nonpolar_radius_rules " + nonpolar_radius_rule_file_name + "\n";

		options.setBool(NonpolarSolvation::Option::NONPOLAR_OVERWRITE_RADII, true);
		options.set(NonpolarSolvation::Option::NONPOLAR_RADIUS_RULES, nonpolar_radius_rule_file_name);
	}



	float score = 0.0f;

	if (!parpars.has("S"))
	{
		configuration_string = configuration_string + "calculate_energy\n";

		SLICKEnergy slick(*protein, *ligand, options);
		score = slick.calculateScore();

		cout << endl << "SLICK/energy is " << score << " kJ/mol" << endl;

		if (verbosity > 1)
		{
			cout << endl << "Scores (w/o coefficients)" << endl << endl;
			cout << "Hydrogen bonds     " << slick.getHydrogenBondScore() << endl;
			cout << "CHPI               " << slick.getCHPIScore() << endl;
			cout << "VanDerWaalsSlick   " << slick.getVDWScore() << endl;
			cout << "Nonpolar solvation " << slick.getNonpolarSolvationScore() << endl;
			cout << "Polar Solvation    " << slick.getPolarSolvationScore() << endl;
		}

#ifdef OLD_DATAFILE_FORMAT
		String dat_file_name;
		String component;
		File datfile;

		component = "SLICKenergy";
		dat_file_name = component + ".dat";
		datfile.open(dat_file_name, std::ios::out);
		datfile << protein_file_name << " " << ligand_file_name << " " << score << " " << component << endl;
		datfile.close();

		component = "HB";
		dat_file_name = component + ".dat";
		datfile.open(dat_file_name, std::ios::out);
		datfile << protein_file_name << " " << ligand_file_name << " " << slick.getHydrogenBondScore()
			<< " " << component << endl;
		datfile.close();

		component = "CHPISlick";
		dat_file_name = component + ".dat";
		datfile.open(dat_file_name, std::ios::out);
		datfile << protein_file_name << " " << ligand_file_name << " " << slick.getCHPIScore()
			<< " " << component << endl;
		datfile.close();

		component = "VDW5";
		dat_file_name = component + ".dat";
		datfile.open(dat_file_name, std::ios::out);
		datfile << protein_file_name << " " << ligand_file_name << " " << slick.getVDWScore()
			<< " " << component << endl;
		datfile.close();

		component = "NONPOLAR2";
		dat_file_name = component + ".dat";
		datfile.open(dat_file_name, std::ios::out);
		datfile << protein_file_name << " " << ligand_file_name << " " << slick.getNonpolarSolvationScore()
			<< " " << component << endl;
		datfile.close();

		component = "DESOLV4";
		dat_file_name = component + ".dat";
		datfile.open(dat_file_name, std::ios::out);
		datfile << protein_file_name << " " << ligand_file_name << " " << slick.getPolarSolvationScore()
			<< " " << component << endl;
		datfile.close();
#endif

		time(&rawtime);
		time_string = time_string + String("stop:  " + String(asctime(localtime(&rawtime))));

		if (parpars.has("log"))
		{
			File logfile("SLICKenergy.log", std::ios::out);
			logfile << configuration_string << endl;
			logfile << time_string << endl;
			logfile.close();
		}
	}


	if (!parpars.has("E"))
	{
		configuration_string = configuration_string + "calculate_score\n";

		SLICKScore slick(*protein, *ligand, options);
		score = slick.calculateScore();

		cout << endl << "SLICK/score is " << score << " (arb. units)" << endl;

		if (verbosity > 1)
		{
			cout << endl << "Scores (w/o coefficients)" << endl << endl;
			cout << "Hydrogen bonds     " << slick.getHydrogenBondScore() << endl;
			cout << "CHPI               " << slick.getCHPIScore() << endl;
			cout << "VanDerWaalsSlick   " << slick.getVDWScore() << endl;
			cout << "Electrostatic int. " << slick.getPolarSolvationScore() << endl;
		}

#ifdef OLD_DATAFILE_FORMAT
		String dat_file_name;
		String component;
		File datfile;

		component = "SLICKenergy";
		dat_file_name = component + ".dat";
		datfile.open(dat_file_name, std::ios::out);
		datfile << protein_file_name << " " << ligand_file_name << " " << score << " " << component << endl;
		datfile.close();

		component = "HB";
		dat_file_name = component + ".dat";
		datfile.open(dat_file_name, std::ios::out);
		datfile << protein_file_name << " " << ligand_file_name << " " << slick.getHydrogenBondScore() << " " << component << endl;
		datfile.close();

		component = "CHPISlick";
		dat_file_name = component + ".dat";
		datfile.open(dat_file_name, std::ios::out);
		datfile << protein_file_name << " " << ligand_file_name << " " << slick.getCHPIScore() << " " << component << endl;
		datfile.close();

		component = "VDW5";
		dat_file_name = component + ".dat";
		datfile.open(dat_file_name, std::ios::out);
		datfile << protein_file_name << " " << ligand_file_name << " " << slick.getVDWScore() << " " << component << endl;
		datfile.close();

		component = "COULOMB";
		dat_file_name = component + ".dat";
		datfile.open(dat_file_name, std::ios::out);
		datfile << protein_file_name << " " << ligand_file_name << " " << slick.getPolarSolvationScore() << " " << component << endl;
		datfile.close();
#endif

		time(&rawtime);
		time_string = time_string + String("stop:  " + String(asctime(localtime(&rawtime))));

		if (parpars.has("log"))
		{
			File logfile("SLICKscore.log", std::ios::out);
			logfile << configuration_string << endl;
			logfile << time_string << endl;
			logfile.close();
		}
	}
}
Exemple #2
0
CHECK(AntechamberFile::AntechamberFile(const String& filename, File::OpenMode open_mode))
	// checking for default mode: reading
	AntechamberFile f(BALL_TEST_DATA_PATH(AntechamberFile_test1.ac));
	TEST_EQUAL(f.isValid(), true)
RESULT


CHECK(AntechamberFile::read(System& system))
  AntechamberFile f(BALL_TEST_DATA_PATH(AntechamberFile_test2.ac));
	System S;
	f.read(S);
	f.close();

	TEST_EQUAL(S.countAtoms(), 2)	
	AtomIterator it = S.beginAtom();
	TEST_EQUAL(it->getElement().getSymbol(), "H")
	TEST_REAL_EQUAL(it->getPosition().x, 0.0)
	TEST_REAL_EQUAL(it->getPosition().y, 1.0)
	TEST_REAL_EQUAL(it->getPosition().z, 2.0)
	it++;
	TEST_EQUAL(it->getElement().getSymbol(), "O")
	TEST_REAL_EQUAL(it->getPosition().x, 3.0)
	TEST_REAL_EQUAL(it->getPosition().y, 4.0)
	TEST_REAL_EQUAL(it->getPosition().z, 5.0)
RESULT


CHECK(AntechamberFile::read(System& system))
  AntechamberFile f(BALL_TEST_DATA_PATH(AntechamberFile_test1.ac));
	System S;
	f.read(S);
Exemple #3
0
double Polarity::updateScore()
{
	score_ = 0.0;
	//float val = 0.0;
	//float distance;
	//float R1;
	//float R2;

	const HashGrid3<Atom*>* hashgrid = scoring_function_->getHashGrid();
	int radius = 1;
	Size no_neighbor_cells = (Size)pow((double)(radius*2+1), 3);  // radius of 1 cell == > 3 cells on each axis

	double total_sum = 0;
	AtomPairVector::const_iterator it;
	for (AtomIterator it = scoring_function_->getLigand()->beginAtom(); +it; it++)
	{
		int no_positive_contacts = 0;
		int no_negative_contacts = 0;
		bool ligandatom_is_lipophilic = isLipophilic_(&*it);

		if (!ligandatom_is_lipophilic)
		{
			continue;
		}

		const HashGridBox3<Atom*>* box = hashgrid->getBox(it->getPosition());

		// ligand atom lies outside of grid
		if (!box) continue;

		Position pos_x, pos_y, pos_z;
		hashgrid->getIndices(*box, pos_x, pos_y, pos_z);

		// indices in HashGrid, where the search for interacting target atoms should begin ( != position of ligand atom)
		int i = ((int)pos_x)-radius; if (i < 0){i = 0; }
		int j0 = ((int)pos_y)-radius; if (j0 < 0){j0 = 0; }
		int k0 = ((int)pos_z)-radius; if (k0 < 0){k0 = 0; }
		int x_size = (int)hashgrid->getSizeX();
		int y_size = (int)hashgrid->getSizeY();
		int z_size = (int)hashgrid->getSizeZ();

		for (; i <= pos_x+radius && i < x_size; i++)
		{
			for (int j = j0; j <= pos_y+radius && j < y_size; j++)
			{
				for (int k = k0; k <= pos_z+radius && k < z_size; k++)
				{
					const HashGridBox3<Atom*>* box = hashgrid->getBox(i, j, k);
					if (!box->isEmpty())
					{
						double cell_score = 0;

						for (HashGridBox3 < Atom* > ::ConstDataIterator d_it = box->beginData(); d_it != box->endData(); d_it++)
						{
							if (isBackboneAtom_(*d_it)) continue;
							bool rec_polar = isPolar_(*d_it);
							bool rec_lipophilic = 0;
							if (!rec_polar) rec_lipophilic = isLipophilic_(*d_it);

							if (!rec_polar && ! rec_lipophilic) continue;

							double distance = ((*d_it)->getPosition()-it->getPosition()).getLength();
							if (distance > (*d_it)->getElement().getVanDerWaalsRadius()+it->getElement().getVanDerWaalsRadius()+1.5) continue;

							double val;
							if (distance > 1) val = 1/distance;
							else val = 1;

							// lipophilic--lipophilic interaction; else polar rec. -- lipophilic ligand atom
							if (rec_lipophilic)
							{
								val *= -1;
							}

							cell_score += val;
							total_sum += val;

							if (scoring_function_->storeInteractionsEnabled())
							{
								val = scaleScore(val);
								it->addInteraction(*d_it, "pol", val);
								(*d_it)->addInteraction(&*it, "pol", val);
							}
						}

						if (cell_score < -0.1) no_positive_contacts++;
						else if (cell_score > 0.1) no_negative_contacts++;
					}
					// if there is no neighboring receptor atom, there will be water ...
// 					else if(i!=pos_x||j!=pos_y||k!=pos_z)
// 					{
// 						if(ligandatom_is_lipophilic)
// 						{
// 							no_negative_contacts++;
// 							double scaled_atom_score = 1.0/no_neighbor_cells;
// 							scaleScore(scaled_atom_score);
// 							total_sum += scaled_atom_score;
// 							it->addInteraction("pol",scaled_atom_score);
// 						}
// 					}
				}
			}
		}
		score_ += (no_negative_contacts-no_positive_contacts)/((double)no_neighbor_cells);
		//cout<<it->getFullName()<<" : "<<no_negative_contacts<<", "<<no_positive_contacts<<"  "<<(no_negative_contacts-no_positive_contacts)/((double)no_neighbor_cells)<<endl;
	}

// 	scaleScore();

//	cout<<"polarity: total sum="<<total_sum<<endl;
//	cout<<"polarity: score="<<score_<<endl;

// 	return score_;

	return getScaledScore();
}