当前位置: 首页>>代码示例>>C++>>正文


C++ PDBFile::open方法代码示例

本文整理汇总了C++中PDBFile::open方法的典型用法代码示例。如果您正苦于以下问题:C++ PDBFile::open方法的具体用法?C++ PDBFile::open怎么用?C++ PDBFile::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PDBFile的用法示例。


在下文中一共展示了PDBFile::open方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv)
{

    if (argc != 3)
    {
        Log << "Usage:" << argv[0] << " <PDB infile> <PDB outfile> [<amber parameter file>]" << endl;

        return 1;
    }

    System system;

    PDBFile f;
    f.open(argv[1]);
    if (f.bad())
    {
        Log.error() << "cannot read PDB file " << argv[1] << endl;
        return 2;
    }
    f >> system;
    f.close();

    FragmentDB db("");

    // ResidueChecker check(db);
    // system.apply(check);


    db.normalize_names.setNamingStandard("Amber");
    system.apply(db.normalize_names);

    system.apply(db.build_bonds);

    Size cyx_counter = 0;
    Size hip_counter = 0;

    ResidueIterator it = system.beginResidue();
    for (; +it; ++it)
    {
        if (it->getFullName() == "CYS-S")
        {
            it->setName("CYX");
            cyx_counter++;
        }
        if (it->getFullName() == "HIS")
        {
            it->setName("HIP");
            hip_counter++;
        }
    }

    if (cyx_counter > 0)
    {
        Log.info() << "Renamed " << cyx_counter << " residues from CYS-S to CYX"
                   << endl;
    }

    if (hip_counter > 0)
    {
        Log.info() << "Renamed " << hip_counter << " residues from HIS to HIP"
                   << endl;
    }

    PDBFile g;
    g.open(argv[2], ios::out);
    if (g.bad())
    {
        Log.error() << "cannot write PDB file " << argv[2] << endl;
        return 2;
    }


    g << system;
    g.close();

    Log.info()
            << endl
            << "Conversion to AMBER naming scheme done. Please note that you might"
            << endl
            << "have to edit the resulting file by hand (if there are HIS or CYS"
            << endl
            << "residues in the original file, e. g.)"
            << endl
            << endl
            << "Good luck."
            << endl;

}
开发者ID:pbrach,项目名称:ball,代码行数:88,代码来源:pdb2amber_naming.C

示例2: main

int main(int argc, char* argv[])
{
	FDPB fdpb;

	// instantiate CommandlineParser object
	CommandlineParser parpars("CalculateSolvationFreeEnergy", "calculate solvation free energy of a protein using AMBER ", VERSION, String(__DATE__), "ForceFields");
	parpars.registerParameter("pdb",  "input pdb file ", INFILE,  true);
	parpars.registerParameter("epsilon_medium", "dielectric constant in medium", DOUBLE, false,  fdpb.options.getReal(FDPB::Option::SOLVENT_DC));
	parpars.registerParameter("epsilon_vacuum", "dielectric constant in vacuum", DOUBLE, false, 1);

	// the manual
	String man = String("This tool computes the solvation free energy of a pdb file using the Jackson-Sternberg approach (bonded energy using a force field and a non bonded energy (electrostatics only) by solving the Poisson-Boltzmann equation. Parameters are the dielectric constants for the medium (-epsilon_medium) and the vacuum (-epsilon_vacuum).");

	parpars.setToolManual(man);

	parpars.setSupportedFormats("pdb", "pdb");

	// parse the command line
	parpars.parse(argc, argv);


	PDBFile pdb;
	pdb.open(parpars.get("pdb"), std::ios::in);

	if (!pdb)
	{
		// if file does not exist: complain and abort
		Log.error() << "error opening " << parpars.get("pdb") << " for input." << std::endl;
		exit(2);
	}

	System sys;
	pdb >> sys;
	pdb.close();

	// normalize the names and build all bonds
	FragmentDB db("");
	sys.apply(db.normalize_names);
	sys.apply(db.build_bonds);

	// TODO: Ask ResidueChecker if everything is ok! see tool CalculateEnergy

	// create an AMBER force field without non-bonded interactions
	AmberFF FF(sys);

	// calculate the total energy
	float total_energy = FF.updateEnergy();
	//Log << FF.getResults() << std::endl;
	//Log << "   total energy using force field evaluation: " << total_energy << " kJ/mol" << std::endl;

	//Log << "removing non bonded energy terms ..." << std::endl;
	FF.removeComponent("Amber NonBonded");

	// calculate the internal energy (neglecting internal VdW interactions)
	float internal_energy = FF.updateEnergy();
	//Log << FF.getResults() << std::endl;
	Log << "  internal energy: " << internal_energy << " kJ/mol" << std::endl;

	// assign atom radii
	AssignRadiusProcessor radius_processor("radii/PARSE.siz");
	sys.apply(radius_processor);

	// calculate the electrostatic part of the solvation energy	
	//FDPB fdpb;

	float dielectric_const = fdpb.options.getReal(FDPB::Option::SOLVENT_DC);
	if (parpars.has("epsilon_medium"))
		dielectric_const = parpars.get("epsilon_medium").toFloat();
	fdpb.options[FDPB::Option::SOLVENT_DC] = dielectric_const;
	Log << "... using dielectric constant in medium: " << fdpb.options[FDPB::Option::SOLVENT_DC].toFloat() << std::endl;

	fdpb.setup(sys);
	fdpb.solve();

	float solvent_energy = fdpb.getEnergy();

	dielectric_const = 1.0;
	if (parpars.has("epsilon_vacuum"))
		dielectric_const = parpars.get("epsilon_vacuum").toFloat();
	fdpb.options[FDPB::Option::SOLVENT_DC] = dielectric_const;
	Log << "... using dielectric constant in vacuum: " << fdpb.options[FDPB::Option::SOLVENT_DC].toFloat() << std::endl;

	fdpb.setup(sys);
	fdpb.solve();

	float vacuum_energy = fdpb.getEnergy();
	Log << "\n  electrostatic solvation free energy: "	<< solvent_energy - vacuum_energy << std::endl;

	Log << "\n  total energy using a combination of force field and FDPB evaluation: "
		  << internal_energy - vacuum_energy + solvent_energy << " kJ/mol" << std::endl;

	return 0;
}
开发者ID:anhi,项目名称:ball,代码行数:93,代码来源:CalculateSolvationFreeEnergy.C

示例3: main

int main(int argc, char** argv)
{
    CommandlineParser parpars("PoseIndices2PDB", "converts pose indices into PDB files ", VERSION, String(__DATE__), "Convert, combine and store");

    parpars.registerMandatoryInputFile("i_clust", "input cluster index file");
    parpars.registerMandatoryInputFile("i_trans", "input tranformation file");
    parpars.registerMandatoryInputFile("i_pdb",   "input reference pdb file");

    parpars.registerMandatoryOutputFile("o", "output file name prefix for resulting pdb files");
    parpars.setParameterAsHidden("o");

    // parameters for galaxy for handling multiple output files
    parpars.registerOptionalGalaxyOutputId("o_id", "output file name prefix for 2nd to last pdb file", "$o.id");
    // need to be hidden in command line mode
    parpars.setParameterAsHidden("o_id");
    parpars.setParameterAsAdvanced("o_id");

    // parameters for galaxy for handling multiple output files
    parpars.registerOptionalGalaxyOutputFolder("o_dir", "output directory for 2nd to last pdb file", "$__new_file_path__");
    // need to be hidden in command line mode
    parpars.setParameterAsHidden("o_dir");
    parpars.setParameterAsAdvanced("o_dir");

    // the manual
    String man = "This tool converts all pose indices from a given transformation file and the corresponding reference PDBFile into separate PDBFiles.\n\nParameters are the input pose index file (-i_clust), the original transformation file (-i_trans), the corresponding reference pdb file (-i_pdb) and a naming schema for the resulting pdb files (-o). \n\nOutput of this tool is a set of PDBFiles representing the docking poses belonging to the given input cluster.";

    parpars.setToolManual(man);

    // here we set the types of I/O files
    parpars.setSupportedFormats("i_clust","txt");
    parpars.setSupportedFormats("i_trans","dcd");
    parpars.setSupportedFormats("i_pdb","pdb");
    parpars.setSupportedFormats("o","pdb");

    parpars.parse(argc, argv);

    //////////////////////////////////////////////////

    // read the input
    PDBFile pdb;
    pdb.open(parpars.get("i_pdb"));
    System sys;
    pdb.read(sys);

    PoseClustering pc;

    if (parpars.has("i_trans"))
    {
        pc.options.set(PoseClustering::Option::RMSD_TYPE, PoseClustering::RIGID_RMSD);
        pc.setBaseSystemAndTransformations(sys, parpars.get("i_trans"));
    }

    //std::vector< std::set<Index> > clusters;

    LineBasedFile file(parpars.get("i_clust"), std::ios::in);
    vector<String> fields;

    String cluster_id = -1;
    String pose_id    = -1;

    // called as command line or e.g. via galaxy?
    bool is_cmd =    !parpars.has("env")
                     || ((parpars.has("env") && parpars.get("env")=="cmdline"));
    bool first_sol = true;

    while (file.LineBasedFile::readLine())
    {
        // get the line
        String current_cluster = file.getLine();
        if (current_cluster.getField(1) == "cluster")
        {
            cluster_id = current_cluster.getField(2);
            pose_id = -1;

            if (file.LineBasedFile::readLine())
            {
                current_cluster = file.getLine();
                fields.clear();
                current_cluster.split(fields);
                for (Size i=0; i < fields.size(); i++)
                {
                    System new_pose_sys(sys);

                    pose_id = fields[i];
                    pc.applyTransformation2System(pose_id.toInt(), new_pose_sys);

                    // create the output name
                    String outfile_name = String(parpars.get("o"))
                                          + "_clust_" + cluster_id
                                          + "_pose_" + String(pose_id) + ".pdb";

                    if (parpars.has("o_dir") && is_cmd && (parpars.get("o_dir") != "$__new_file_path__"))
                    {
                        outfile_name =  String(parpars.get("o_dir")) + "/" + outfile_name;
                    }

                    // NOTE: Galaxy requires this strange naming convention
                    //       including the fact, that zero-th element has a different name
                    if (!is_cmd)
                    {
//.........这里部分代码省略.........
开发者ID:pbrach,项目名称:ball,代码行数:101,代码来源:PoseIndices2PDB.C

示例4: main

int main(int argc, char* argv[])
{
	// instantiate CommandlineParser object
	CommandlineParser parpars("CalculateEnergy", "calculate free energy of a protein ", VERSION, String(__DATE__), "ForceFields");
	parpars.registerMandatoryInputFile("pdb", "input pdb file ");

	// TODO: offer upload of a distinguished fragDB file?

	// choice of force field
	parpars.registerOptionalStringParameter("force_field", "force field (AMBER, MMFF94)", "AMBER");
	list<String> force_fields;
	force_fields.push_back("AMBER");
	force_fields.push_back("MMFF94");
	// TODO: shall we offer CHARM as well?
	parpars.setParameterRestrictions("force_field", force_fields);

	// TODO: shall we offer a force field parameter file upload?

	// TODO: check the naming!
	parpars.registerOptionalDoubleParameter("non_bond_cutoff",  "cutoff radius in calculations of nonbonded interactions", 20.0);
	parpars.registerOptionalDoubleParameter("elec_stat_cuton", "electrostatic cuton", 13.0);
	parpars.registerOptionalDoubleParameter("elec_stat_cutoff", "electrostatic cutoff", 15.0);
	parpars.registerFlag("dist_dep_dielec", "apply distance dependent dielectric constant", false);
	// NOTE: assign is the default
	//parpars.registerFlag("assign_typenames","automatically assign type names to the system", false);
	//parpars.registerFlag("assign_types","automatically assign types to the system if missing", false);
	//parpars.registerFlag("assign_charges", "automatically assign charges to the system if missing", false);
	// TODO: if we only allow PDBFile to upload then from where do we get stuff to overwrite?? 
	parpars.registerFlag("overwrite_types", "overwrite even non-empty type names", false);
	parpars.registerFlag("overwrite_charges","overwrite even non-zero charges", false);

	// the manual
	String man = String("This tool computes the free energy of a pdb file using a specified force field (-force_field) and force field parameters (-non_bond_cutoff, -elec_stat_cuton ... ).");

	parpars.setToolManual(man);

	parpars.setSupportedFormats("pdb", "pdb");

	// parse the command line
	parpars.parse(argc, argv);


	PDBFile pdb;
	pdb.open(parpars.get("pdb"), std::ios::in);

	if (!pdb)
	{
		// if file does not exist: complain and abort
		Log.error() << "error opening " << parpars.get("pdb") << " for input." << std::endl;
		exit(2);
	}

	System sys;
	pdb >> sys;
	pdb.close();

	// normalize the names and build all bonds
	FragmentDB db("");
	sys.apply(db.normalize_names);
	sys.apply(db.build_bonds);

	// check the structure
	Log.info() << " checking residues..." << std::endl;
	ResidueChecker rc(db);
	sys.apply(rc);

	if (!rc.getStatus())
	{
		Log.error() << "There are errors in the given structure. Use the ResidueChecker tool for further investigation." << std::endl;
		exit(2);
	}

	// create a force field	
	AmberFF* amber_force_field = NULL;
	MMFF94*  mmff_force_field = NULL;
	ForceField* force_field = NULL;

	if (parpars.has("force_field"))
	{
		String penalty_table = parpars.get("force_field");
		if (penalty_table == "AMBER")
		{
			amber_force_field = new AmberFF();
			force_field = amber_force_field;
			Log << " using the amber force field" << std::endl;
		}
		else if (penalty_table == "MMFF94")
		{
			mmff_force_field = new MMFF94();
			force_field = mmff_force_field;
			Log << " using the MMFF94 force field" << std::endl;
		}
		else
		{
			Log.error() << "Unknown force field " << parpars.get("force_field") << " Abort." << std::endl;
			exit(2);
		}
	}

	if (!amber_force_field && !mmff_force_field)
//.........这里部分代码省略.........
开发者ID:HeyJJ,项目名称:ball,代码行数:101,代码来源:CalculateEnergy.C

示例5: main


//.........这里部分代码省略.........

	// here we set the types of I/O files
	parpars.setSupportedFormats("i_dcd","dcd");
	parpars.setSupportedFormats("i_pdb","pdb");
	parpars.setSupportedFormats("i_trans","txt");
	parpars.setSupportedFormats("o_index_list","txt");
	parpars.setSupportedFormats("o_score_matrix","txt");
	parpars.setSupportedFormats("o_dcd","dcd");
	parpars.setSupportedFormats("o_red_dcd","dcd");
	parpars.setSupportedFormats("o_cluster_tree","dat");

	parpars.parse(argc, argv);

	//////////////////////////////////////////////////

	if (parpars.has("o_dcd"))
	{
		if (!parpars.has("o_dcd_dir") || !parpars.has("o_dcd_id"))
		{
			Log << "Output type \"dcd\" requires setting the options \"o_dir\" \"o_id\"! Abort!" << endl;
			return 1;
		}
	}

	if (     parpars.has("o_cluster_tree")
			&& (!parpars.has("alg") || parpars.get("alg") != "NEAREST_NEIGHBOR_CHAIN_WARD"))
	{
		Log << "Output of cluster tree requires Ward algorithm! Abort!" << endl;
		return 1;
	}

	// read the input	
	PDBFile pdb;
	pdb.open(parpars.get("i_pdb"));
	System sys;
	pdb.read(sys);

	ConformationSet cs;
	cs.setup(sys);

	if (parpars.has("i_dcd"))
	{
		cs.readDCDFile(parpars.get("i_dcd"));
	}

	cs.resetScoring();

	PoseClustering pc;

	if (parpars.has("i_trans"))
	{
		pc.setBaseSystemAndTransformations(sys, parpars.get("i_trans"));
	}

	if (parpars.has("rmsd_cutoff"))
	{
		float rmsd = parpars.get("rmsd_cutoff").toInt();
		pc.options.setReal(PoseClustering::Option::DISTANCE_THRESHOLD, rmsd);
	}

	if (parpars.has("scope"))
	{
		String scope = parpars.get("scope");
		if (scope == "C_ALPHA")
			pc.options.set(PoseClustering::Option::RMSD_LEVEL_OF_DETAIL, PoseClustering::C_ALPHA);
		else if (scope == "BACKBONE")
开发者ID:HeyJJ,项目名称:ball,代码行数:67,代码来源:DockPoseClustering.C


注:本文中的PDBFile::open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。