コード例 #1
0
/// \brief TODOCUMENT
size_t geometric_mean_length_getter::do_get_length(const protein   &arg_protein_a,     ///< TODOCUMENT
                                                   const protein   &arg_protein_b      ///< TODOCUMENT
                                                   ) const {
	const size_t length_a       = arg_protein_a.get_length();
	const size_t length_b       = arg_protein_b.get_length();
	const double geom_mean_doub = sqrt( numeric_cast<double>( length_a * length_b ) );
	return numeric_cast<size_t>( round( geom_mean_doub ) );
}
コード例 #2
0
/// \brief TODOCUMENT
void cath::test::dssp_wolf_file_test_suite_fixture::check_pdb_and_dssp_built_protein(const string &arg_example_id ///< TODOCUMENT
                                                                                     ) {
	ostringstream build_prot_warn_stream;
	const auto the_pdb_file               = read_pdb_file (  pdb_file_of_example_id( arg_example_id ) );
	const auto the_dssp_file              = read_dssp_file( dssp_file_of_example_id( arg_example_id ) );
	const auto pdb_prot                   = build_protein_of_pdb( the_pdb_file, reference_wrapper<ostream>{ build_prot_warn_stream } );
	const auto num_non_null_dssp_residues = get_num_non_null_residues( the_dssp_file );
	const auto num_pdb_residues           = pdb_prot.get_length();
	BOOST_CHECK_EQUAL( build_prot_warn_stream.str(), "" );

	ostringstream test_ss;
	const log_to_ostream_guard the_guard{ test_ss };

	const protein      combi_prot_with_all_pdb_residues   = protein_from_dssp_and_pdb(the_dssp_file, the_pdb_file, dssp_skip_policy::DONT_SKIP__BREAK_ANGLES );
	const protein      combi_prot_with_dssp_only_residues = protein_from_dssp_and_pdb(the_dssp_file, the_pdb_file, dssp_skip_policy::SKIP__BREAK_ANGLES      );

	BOOST_REQUIRE_EQUAL( num_non_null_dssp_residues, combi_prot_with_dssp_only_residues.get_length() );
	BOOST_REQUIRE_EQUAL( num_pdb_residues,           combi_prot_with_all_pdb_residues.get_length()   );

	// Compare the combi's residues with the DSSP residues
	//( this requires two counters to handle skipping null DSSP residues)
	size_t combi_residue_ctr = 0;
	for (const residue dssp_residue : the_dssp_file) {

		// If this is a null DSSP residue then just move onto the next one
		if ( is_null_residue(dssp_residue) ) {
			continue;
		}
		const residue built_residue = combi_prot_with_dssp_only_residues.get_residue_ref_of_index( combi_residue_ctr );
		BOOST_CHECK_EQUAL( dssp_residue.get_pdb_residue_id(),   built_residue.get_pdb_residue_id()   );
		BOOST_CHECK_EQUAL( dssp_residue.get_sec_struc_number(), built_residue.get_sec_struc_number() );
		BOOST_CHECK_EQUAL( dssp_residue.get_sec_struc_type(),   built_residue.get_sec_struc_type()   );
//		cerr << dssp_residue  << endl;
//		cerr << built_residue << endl;
//		cerr << endl;
		++combi_residue_ctr;
	}

	for (size_t pdb_residue_ctr = 0; pdb_residue_ctr < num_pdb_residues; ++pdb_residue_ctr) {
		const pdb_residue the_pdb_residue = the_pdb_file.get_residue_cref_of_index__backbone_unchecked(pdb_residue_ctr);
		const residue     built_residue   = combi_prot_with_all_pdb_residues.get_residue_ref_of_index( pdb_residue_ctr );
		BOOST_CHECK_EQUAL( the_pdb_residue.get_residue_id(),                               built_residue.get_pdb_residue_id()     );
		BOOST_CHECK_EQUAL( get_carbon_alpha_coord( the_pdb_residue ),                      built_residue.get_carbon_alpha_coord() );
		BOOST_CHECK_EQUAL( get_or_predict_carbon_beta_coord_of_residue( the_pdb_residue ), built_residue.get_carbon_beta_coord()  );
//		cerr << pdb_residue   << endl;
//		cerr << built_residue << endl;
//		cerr << endl;
	}
}
コード例 #3
0
				/// \brief TODOCUMENT
				inline single_struc_res_pair_vec build_single_rep_pairs(const protein &arg_protein ///< TODOCUMENT
				                                                        ) {
					const auto num_residues     = debug_unwarned_numeric_cast<index_type>( arg_protein.get_length() );
					const auto scan_phi_angles  = make_scan_phi_angles     ( arg_protein );
					const auto scan_psi_angles  = make_scan_psi_angles     ( arg_protein );
					const auto scan_view_coords = make_scan_view_coords    ( arg_protein );
					const auto scan_frames      = make_scan_frame_quat_rots( arg_protein );
					single_struc_res_pair_vec results;
					results.reserve( num_residues * num_residues );
					const auto all_residues_range   = boost::irange<index_type>( 0, num_residues );
					for (const auto &x : common::cross( all_residues_range, all_residues_range ) ) {
						const auto &from_res_index = std::get<0>( x );
						const auto &to_res_index   = std::get<1>( x );
						results.emplace_back(
							rotate_copy(
								scan_frames     [ from_res_index ],
								scan_view_coords[ to_res_index   ] - scan_view_coords[ from_res_index ]
							),
							rotation_between_rotations(
								scan_frames[ from_res_index ],
								scan_frames[ to_res_index   ]
							),
							scan_phi_angles[ from_res_index ],
							scan_psi_angles[ from_res_index ],
							scan_phi_angles[ to_res_index   ],
							scan_psi_angles[ to_res_index   ],
							from_res_index,
							to_res_index
						);
					}
					return results;
				}
コード例 #4
0
			void add_structure_to_store(T                         &arg_store,           ///< TODOCUMENT
			                            const index_type          &arg_structure_index, ///< TODOCUMENT
			                            const protein             &arg_protein,         ///< TODOCUMENT
			                            const scan_policy<KPs...> &arg_scan_policy,     ///< TODOCUMENT
			                            const scan_role           &arg_scan_role        ///< TODOCUMENT
			                            ) {
				const auto &the_keyer        = arg_scan_policy.get_keyer();
//				BOOST_LOG_TRIVIAL( warning ) << "Keyer is : " << the_keyer;
				const auto  roled_stride     = roled_scan_stride{ arg_scan_role, arg_scan_policy.get_scan_stride() };
				const auto  num_residues     = debug_unwarned_numeric_cast<index_type>( arg_protein.get_length() );
				const auto  from_rep_strider = get_this_from_strider( roled_stride );
				const auto  to_rep_strider   = get_this_to_strider  ( roled_stride );
				for (const auto &from_rep_index : get_rep_indices_range( from_rep_strider, num_residues ) ) {
//					 BOOST_LOG_TRIVIAL( warning ) << "\tFrom rep " << from_rep_index;
					for (const auto &to_rep_index : get_rep_indices_range( to_rep_strider, num_residues ) ) {

						if ( from_rep_index != to_rep_index ) {
							const auto the_res_pair = make_multi_struc_res_rep_pair(
								arg_protein.get_residue_ref_of_index( get_index_of_rep_index( from_rep_strider, from_rep_index ) ),
								arg_protein.get_residue_ref_of_index( get_index_of_rep_index( to_rep_strider,   to_rep_index   ) ),
								arg_structure_index,
								from_rep_index,
								to_rep_index
							);
//							BOOST_LOG_TRIVIAL( warning ) << "\t\tTo rep " << to_rep_index << " - the rep : " << the_res_pair;
							arg_store.push_back_entry_to_cell( the_keyer.make_key( the_res_pair ), the_res_pair );
						}
					}
				}
			}
コード例 #5
0
				/// \brief TODOCUMENT
				inline single_struc_res_pair_list_vec build_rep_sets(const protein           &arg_protein,          ///< TODOCUMENT
				                                                     const roled_scan_stride &arg_roled_scan_stride ///< TODOCUMENT
				                                                     ) {
					const auto  num_residues         = debug_unwarned_numeric_cast<index_type>( arg_protein.get_length() );
					const auto &all_single_res_pairs = build_single_rep_pairs( arg_protein );

					const auto from_range = get_indices_range( get_this_from_strider( arg_roled_scan_stride ), num_residues );
					const auto to_range   = get_indices_range( get_this_to_strider  ( arg_roled_scan_stride ), num_residues );

					single_struc_res_pair_list_vec results;
					results.reserve( from_range.size() * to_range.size() );

					for (const auto &x : common::cross( from_range, to_range ) ) {
//						std::cerr << "Building rep: [" << std::get<0>( x ) << ", " << std::get<1>( x ) << "]\n";
						results.emplace_back();
						detail::add_stride_neighbours(
							results.back(),
							num_residues,
							all_single_res_pairs,
							std::get<0>( x ),
							std::get<1>( x ),
							from_co_stride( arg_roled_scan_stride ),
							to_co_stride  ( arg_roled_scan_stride )
						);
					}
					return results;
				}
コード例 #6
0
				/// \brief TODOCUMENT
				inline frame_quat_rot_vec make_scan_frame_quat_rots(const protein &arg_protein ///< TODOCUMENT
				                                                    ) {
					frame_quat_rot_vec results;
					results.reserve( arg_protein.get_length() );
					for (const auto &x : arg_protein) {
						results.emplace_back( geom::make_quat_rot_from_rotation<frame_quat_rot_type>( x.get_frame() ) );
					}
					return results;
				}
コード例 #7
0
				/// \brief TODOCUMENT
				inline view_type_vec make_scan_view_coords(const protein &arg_protein ///< TODOCUMENT
				                                           ) {
					view_type_vec results;
					results.reserve( arg_protein.get_length() );
					for (const auto &x : arg_protein) {
						results.emplace_back( x.get_carbon_beta_coord() );
					}
					return results;
				}
コード例 #8
0
				/// \brief TODOCUMENT
				inline angle_type_vec make_scan_psi_angles(const protein &arg_protein ///< TODOCUMENT
				                                           ) {
					angle_type_vec results;
					results.reserve( arg_protein.get_length() );
					for (const auto &x : arg_protein) {
						results.emplace_back( geom::convert_angle_type<angle_base_type>( x.get_psi_angle() ) );
					}
					return results;
				}
コード例 #9
0
		/// \brief TODOCUMENT
		view_cache_index_entry_vec view_cache_index_entry_test_suite_fixture::build_random_vcies(const size_t  &arg_num_entries, ///< TODOCUMENT
		                                                                                         const protein &arg_protein,     ///< TODOCUMENT
		                                                                                         mt19937       &arg_rng          ///< TODOCUMENT
		                                                                                         ) {
			if ( arg_protein.get_length() < 2 ) {
				BOOST_THROW_EXCEPTION(invalid_argument_exception("Cannot build random vcies if the protein has fewer than two residues"));
			}
			const auto &length = arg_protein.get_length();
			return generate_n_build<view_cache_index_entry_vec>(
				arg_num_entries,
				[&] () {
					const auto index_pair = pick_random_pair( 0_z, length - 1, arg_rng );
					return make_view_cache_index_entry(
						arg_protein,
						index_pair.first,
						index_pair.second
					);
				}
			);
		}
コード例 #10
0
/// \brief TODOCUMENT
void cath::test::dssp_wolf_file_test_suite_fixture::compare_residue_frames_from_pdb_vs_wolf(const string &arg_example_id ///< TODOCUMENT
                                                                                            ) {
	ostringstream build_prot_warn_stream;
	const wolf_file            the_wolf_file     = read_wolf(     wolf_file_of_example_id( arg_example_id ) );
	const pdb                  the_pdb_file      = read_pdb_file(  pdb_file_of_example_id( arg_example_id ) );
	const protein              pdb_prot          = build_protein_of_pdb( the_pdb_file, reference_wrapper<ostream>{ build_prot_warn_stream });
	const wolf_file::size_type num_wolf_residues = the_wolf_file.get_num_residues();
	const size_t   num_pdb_residues  = pdb_prot.get_length();

	BOOST_CHECK_EQUAL( build_prot_warn_stream.str(), "" );

	BOOST_REQUIRE_EQUAL(num_pdb_residues, num_wolf_residues);

	doub_angle_vec angles_between_frame_pairs;
	for (size_t residue_ctr = 0; residue_ctr < num_pdb_residues; ++residue_ctr) {
		const residue &wolf_residue     = the_wolf_file.get_residue_of_index( residue_ctr );
		const residue &pdb_prot_residue = pdb_prot.get_residue_ref_of_index( residue_ctr );

		BOOST_REQUIRE_EQUAL( pdb_prot_residue.get_pdb_residue_id(), wolf_residue.get_pdb_residue_id() );

		const rotation   raw_wolf_frame   = wolf_residue.get_frame();
		const rotation   wolf_frame       = tidy_copy(raw_wolf_frame, 0.001);
		const rotation   pdb_frame        = pdb_prot_residue.get_frame();
		const doub_angle the_angle        = angle_between_rotations( wolf_frame, pdb_frame );
		angles_between_frame_pairs.push_back( the_angle );
	}

	BOOST_REQUIRE_GT( angles_between_frame_pairs.size(), 0_z );

	// Sort the list of angles in ascending order
	sort( angles_between_frame_pairs );

	// Check that around 95% of the way through the list of angles, the values are still
	// less than 3 degrees (in radians)
	const size_t ninety_fifth_perc_index = numeric_cast<size_t>(
		round( 0.95 * numeric_cast<double>( angles_between_frame_pairs.size() ) )
	);
	BOOST_CHECK_LT(
		angles_between_frame_pairs[ ninety_fifth_perc_index ],
		make_angle_from_degrees<double>( 3.0 )
	);
}
コード例 #11
0
/// \brief Private static method that implements the process of building the views from proteins
coord_vec_vec view_cache::build_views(const protein &arg_protein ///< The protein which the view_cache should be built to represent
                                      ) {
	// Grab the number of residues and prepare the views accordingly
	const size_t num_residues = arg_protein.get_length();
	coord_vec_vec new_views( num_residues );
	for (coord_vec &view_of : new_views) {
		view_of.reserve( num_residues );
	}

	// Loop over the all from-versus-to residue pairs and add the resulting views
	for (const size_t &from_res_ctr : irange( 0_z, num_residues ) ) {
		for (const size_t &to_res_ctr : irange( 0_z, num_residues ) ) {
			coord_vec &view_of_from = new_views[ from_res_ctr ];
			view_of_from.push_back( view_vector_of_residue_pair(
				arg_protein.get_residue_ref_of_index( from_res_ctr ),
				arg_protein.get_residue_ref_of_index( to_res_ctr   )
			) );
		}
	}
	return new_views;
}
コード例 #12
0
/// \brief TODOCUMENT
size_t residue_querier::do_get_length(const protein &arg_protein ///< TODOCUMENT
                                      ) const {
	return arg_protein.get_length();
}
コード例 #13
0
/// \brief TODOCUMENT
size_t length_of_second_getter::do_get_length(const protein &/*arg_protein_a*/, ///< TODOCUMENT
                                              const protein &arg_protein_b      ///< TODOCUMENT
                                              ) const {
	return arg_protein_b.get_length();
}
コード例 #14
0
/// \brief TODOCUMENT
pair<str_vec, str_vec> check_scan_on_final_alignment::get_rep_name_lists(const protein           &arg_protein,          ///< TODOCUMENT
                                                                         const roled_scan_stride &arg_roled_scan_stride ///< TODOCUMENT
                                                                         ) const {
//	const auto        &num_residues  = arg_protein.get_length();
	const auto rep_list_indices      = get_rep_index_lists( arg_roled_scan_stride, numeric_cast<index_type>( arg_protein.get_length() ) );
	const auto residue_name_of_index = [&] (const index_type &x) { return get_pdb_residue_name_string( arg_protein.get_residue_ref_of_index( x ) ); };
	return make_pair(
		transform_build<str_vec>( rep_list_indices.first,  residue_name_of_index ),
		transform_build<str_vec>( rep_list_indices.second, residue_name_of_index )
	);
}
コード例 #15
0
			void dense_add_structure_to_store(T                         &arg_store,           ///< TODOCUMENT
			                                  const index_type          &arg_structure_index, ///< TODOCUMENT
			                                  const protein             &arg_protein,         ///< TODOCUMENT
			                                  const scan_policy<KPs...> &arg_scan_policy,     ///< TODOCUMENT
			                                  const scan_role           &arg_scan_role        ///< TODOCUMENT
			                                  ) {
				const auto &the_criteria     = arg_scan_policy.get_criteria();
				const auto &the_keyer        = arg_scan_policy.get_keyer();
//				BOOST_LOG_TRIVIAL( warning ) << "Keyer is : " << the_keyer;
				const auto  roled_stride     = roled_scan_stride{ arg_scan_role, arg_scan_policy.get_scan_stride() };
				const auto  num_residues     = debug_unwarned_numeric_cast<index_type>( arg_protein.get_length() );
				const auto  from_rep_strider = get_this_from_strider( roled_stride );
				const auto  to_rep_strider   = get_this_to_strider  ( roled_stride );
				for (const auto &from_rep_index : get_rep_indices_range( from_rep_strider, num_residues ) ) {
//					BOOST_LOG_TRIVIAL( warning ) << "\tFrom rep " << from_rep_index;
					for (const auto &to_rep_index : get_rep_indices_range( to_rep_strider, num_residues ) ) {
//						BOOST_LOG_TRIVIAL( warning ) << "\t\tTo rep " << to_rep_index;
						if ( from_rep_index != to_rep_index ) {
							const auto the_res_pair = make_multi_struc_res_rep_pair(
								arg_protein.get_residue_ref_of_index( get_index_of_rep_index( from_rep_strider, from_rep_index ) ),
								arg_protein.get_residue_ref_of_index( get_index_of_rep_index( to_rep_strider, to_rep_index )   ),
								arg_structure_index,
								from_rep_index,
								to_rep_index
							);
//							BOOST_LOG_TRIVIAL( warning ) << "\t\tMade multi_struc_res_rep_pair : " << the_res_pair;
//							const auto the_key    = the_keyer.make_key       ( the_res_pair );
//							BOOST_LOG_TRIVIAL( warning ) << "\t\tThe actual key itself is      : " << output_key(the_key );

							const auto close_keys = the_keyer.make_close_keys( the_res_pair, the_criteria );
//							BOOST_LOG_TRIVIAL( warning ) << "\t\t\t(from_phi : "
//							                             << the_res_pair.get_res_pair_core().get_from_phi_angle()
//							                             << ") There are "
//							                             << boost::distance( common::cross( close_keys ) )
//							                             << " keys close to "
//							                             << output_key( the_keyer.make_key( the_res_pair ) );

//							BOOST_LOG_TRIVIAL( warning ) << "\t\tRange 0 : \"" << boost::algorithm::join ( std::get<0>( close_keys ) | boost::adaptors::transformed( [](const uint8_t &x) { return std::to_string( static_cast<size_t>( x) ); } ) , "\", \"") << "\"";
//							BOOST_LOG_TRIVIAL( warning ) << "\t\tRange 1 : \"" << boost::algorithm::join ( std::get<1>( close_keys ) | boost::adaptors::transformed( [](const uint8_t &x) { return std::to_string( static_cast<size_t>( x) ); } ) , "\", \"") << "\"";
//							BOOST_LOG_TRIVIAL( warning ) << "\t\tRange 2 : \"" << boost::algorithm::join ( std::get<2>( close_keys ) | boost::adaptors::transformed( [](const uint8_t &x) { return std::to_string( static_cast<size_t>( x) ); } ) , "\", \"") << "\"";
//							BOOST_LOG_TRIVIAL( warning ) << "\t\tRange 3 : \"" << boost::algorithm::join ( std::get<3>( close_keys ) | boost::adaptors::transformed( [](const uint8_t &x) { return std::to_string( static_cast<size_t>( x) ); } ) , "\", \"") << "\"";
//							BOOST_LOG_TRIVIAL( warning ) << "\t\tRange 4 : \"" << boost::algorithm::join ( std::get<4>( close_keys ) | common::lexical_casted<std::string>() , "\", \"") << "\"";
//							BOOST_LOG_TRIVIAL( warning ) << "\t\tRange 5 : \"" << boost::algorithm::join ( std::get<5>( close_keys ) | common::lexical_casted<std::string>() , "\", \"") << "\"";
//							BOOST_LOG_TRIVIAL( warning ) << "\t\tRange 6 : \"" << boost::algorithm::join ( std::get<6>( close_keys ) | common::lexical_casted<std::string>() , "\", \"") << "\"";
//							BOOST_LOG_TRIVIAL( warning ) << "\t\tRange 7 : \"" << boost::algorithm::join ( std::get<7>( close_keys ) | common::lexical_casted<std::string>() , "\", \"") << "\"";

//							KEYER_PARTS: tuple<
//								res_pair_phi_psi_angle_keyer_part<res_pair_from_phi_keyer_part_spec>,
//								res_pair_phi_psi_angle_keyer_part<res_pair_from_psi_keyer_part_spec>,
//								res_pair_phi_psi_angle_keyer_part<res_pair_to_phi_keyer_part_spec>,
//								res_pair_phi_psi_angle_keyer_part<res_pair_to_psi_keyer_part_spec>,
//								res_pair_index_dirn_keyer_part,
//								res_pair_view_axis_keyer_part<res_pair_view_x_keyer_part_spec>,
//								res_pair_view_axis_keyer_part<res_pair_view_y_keyer_part_spec>,
//								res_pair_view_axis_keyer_part<res_pair_view_z_keyer_part_spec>
//							>
//							KEY: tuple<unsigned char, unsigned char, unsigned char, unsigned char, res_pair_dirn, short, short, short>
//							CLOSE_KEYS: tuple<
//								joined_range<const integer_range<unsigned char>, const integer_range<unsigned char> >,
//								joined_range<const integer_range<unsigned char>, const integer_range<unsigned char> >,
//								joined_range<const integer_range<unsigned char>, const integer_range<unsigned char> >,
//								joined_range<const integer_range<unsigned char>, const integer_range<unsigned char> >,
//								array<res_pair_dirn, 1u>,
//								integer_range<short int>,
//								integer_range<short int>,
//								integer_range<short int>
//							>;
//							ELEMENT_OF_CLOSE_KEYS: tuple<unsigned char, unsigned char, unsigned char, unsigned char, const res_pair_dirn &, short, short, short>

//							const bool contains_key = common::contains( common::cross( close_keys ), the_keyer.make_key( the_res_pair ) );
//							if ( contains_key ) {
//								BOOST_LOG_TRIVIAL( warning ) << "\t\t\tDoes contain the central key";
//							}
//							else {
//								BOOST_LOG_TRIVIAL( warning ) << "\t\t\t***** Doesn't contain the central key";
//							}

//							size_t counter = 0;
							for (const auto &x : common::cross( close_keys ) ) {
//								if ( ! contains_key ) {
//									BOOST_LOG_TRIVIAL( warning ) << "\t\t\t\t[" << counter << "] : Adding entry for close key " << output_key( x );
//								}
								arg_store.push_back_entry_to_cell( x, the_res_pair );
//								++counter;
							}
						}
					}
				}
				arg_store.summarize();
			}