Exemplo n.º 1
0
/// \brief Save the specified coord to the specified Boost Property Tree ptree
///
/// \relates coord
void cath::geom::save_to_ptree(ptree       &arg_ptree, ///< The ptree to which the coord should be saved
                               const coord &arg_coord  ///< The coord to be saved
                               ) {
	arg_ptree.put( "x", arg_coord.get_x() );
	arg_ptree.put( "y", arg_coord.get_y() );
	arg_ptree.put( "z", arg_coord.get_z() );
}
Exemplo n.º 2
0
/// \brief TODOCUMENT
///
/// \relates pdb_atom
ostream & cath::file::write_pdb_file_entry(ostream          &arg_os,      ///< TODOCUMENT
                                           const residue_id &arg_res_id,  ///< TODOCUMENT
                                           const pdb_atom   &arg_pdb_atom ///< TODOCUMENT
                                           ) {
	// Sanity check the inputs
	if ( arg_res_id.get_residue_name().is_null() ) {
		BOOST_THROW_EXCEPTION(invalid_argument_exception("Empty residue_name in cath::write_pdb_file_entry()"));
	}

	// Grab the necessary data
	const coord  atom_coord                        = arg_pdb_atom.get_coord();
	const string residue_name_with_insert_or_space = make_residue_name_string_with_insert_or_space(
		arg_res_id.get_residue_name()
	);

	// Output the entry to a temporary ostringstream
	// (to avoid needlessly messing around with the formatting options of the ostream)
	ostringstream atom_ss;
                                                                       // Comments with PDB format documentation
                                                                       // (http://www.wwpdb.org/documentation/format33/sect9.html#ATOM)
	atom_ss << left;
	atom_ss << setw( 6 ) << arg_pdb_atom.get_record_type();            //  1 -  6        Record name   "ATOM  " or "HETATM"
	atom_ss << right;
	atom_ss << setw( 5 ) << arg_pdb_atom.get_atom_serial();            //  7 - 11        Integer       serial       Atom  serial number.
	atom_ss << " ";
	atom_ss << setw( 4 ) << arg_pdb_atom.get_element_type_untrimmed(); // 13 - 16        Atom          name         Atom name.
	atom_ss <<              arg_pdb_atom.get_alt_locn();               // 17             Character     altLoc       Alternate location indicator.
	atom_ss <<              get_amino_acid_code( arg_pdb_atom );       // 18 - 20        Residue name  resName      Residue name.
	atom_ss << " ";
	atom_ss << arg_res_id.get_chain_label();                           // 22             Character     chainID      Chain identifier.
	                                                                   // 23 - 26        Integer       resSeq       Residue sequence number.
	atom_ss << setw( 5 ) << residue_name_with_insert_or_space;         // 27             AChar         iCode        Code for insertion of residues.
	atom_ss << "   ";
	atom_ss << fixed     << setprecision( 3 );
	atom_ss << setw( 8 ) << atom_coord.get_x();                        // 31 - 38        Real(8.3)     x            Orthogonal coordinates for X in Angstroms.
	atom_ss << setw( 8 ) << atom_coord.get_y();                        // 39 - 46        Real(8.3)     y            Orthogonal coordinates for Y in Angstroms.
	atom_ss << setw( 8 ) << atom_coord.get_z();                        // 47 - 54        Real(8.3)     z            Orthogonal coordinates for Z in Angstroms.
	atom_ss << fixed     << setprecision( 2 );
	atom_ss << setw( 6 ) << arg_pdb_atom.get_occupancy();              // 55 - 60        Real(6.2)     occupancy    Occupancy.
	atom_ss << setw( 6 ) << arg_pdb_atom.get_temp_factor();            // 61 - 66        Real(6.2)     tempFactor   Temperature  factor.
	                                                                   // 77 - 78        LString(2)    element      Element symbol, right-justified.
	                                                                   // 79 - 80        LString(2)    charge       Charge  on the atom.

	// Output the result to the ostream and return it
	arg_os << atom_ss.str();
	return arg_os;
}