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 );
						}
					}
				}
			}
/// \brief TODOCUMENT
///
/// Things for investigation:
///  * raw/final score from alignment
///  * expected raw/final score
///  * top categorised reasons by raw score
///  * repeat for varying scan_stride (can just be called by nmnf fn)
alignment_scan_comparison check_scan_on_final_alignment::do_check(const alignment     &arg_alignment,  ///< TODOCUMENT
                                                                  const protein       &arg_protein_a,  ///< TODOCUMENT
                                                                  const protein       &arg_protein_b,  ///< TODOCUMENT
                                                                  const quad_criteria &arg_criteria,   ///< TODOCUMENT
                                                                  const scan_stride   &arg_scan_stride ///< TODOCUMENT
                                                                  ) const {
	const auto aln_range = irange( 0_z, arg_alignment.length() );
	cerr << "SHOULD THE RANGE BE 7.0 RATHER THAN SQRT(40.0)????\n";
	return accumulate(
		cross( aln_range, aln_range ),
		alignment_scan_comparison{},
		[&] (alignment_scan_comparison x, const size_size_tpl &y) {
			const size_t aln_from_ctr   = get<0>( y );
			const size_t aln_to_ctr     = get<1>( y );
			const bool   from_alns_both = has_both_positions_of_index( arg_alignment, aln_from_ctr );
			const bool   to_alns_both   = has_both_positions_of_index( arg_alignment, aln_to_ctr   );

			if ( from_alns_both && to_alns_both ) {

				const auto a_from     = get_a_position_of_index( arg_alignment, aln_from_ctr );
				const auto b_from     = get_b_position_of_index( arg_alignment, aln_from_ctr );
				const auto a_to       = get_a_position_of_index( arg_alignment, aln_to_ctr   );
				const auto b_to       = get_b_position_of_index( arg_alignment, aln_to_ctr   );
				const bool a_included = difference( a_from, a_to ) > NUM_EXCLUDED_ON_SIDES;
				const bool b_included = difference( b_from, b_to ) > NUM_EXCLUDED_ON_SIDES;

				if ( a_included && b_included ) {
					const auto the_distance = distance_between_points(
						view_vector_of_residue_pair(
							arg_protein_a.get_residue_ref_of_index( a_from ),
							arg_protein_a.get_residue_ref_of_index( a_to   )
						),
						view_vector_of_residue_pair(
							arg_protein_b.get_residue_ref_of_index( b_from ),
							arg_protein_b.get_residue_ref_of_index( b_to   )
						)
					);
//					const auto score       = ( the_distance >= 7.0 ) ? 0.0 : ( 1.0 - the_distance / 7.0 );
					const auto score       = ( the_distance >= sqrt( 40.0 ) ) ? 0.0 : ( 1.0 - the_distance / 7.0 );
					if ( score > 0.0 ) {
						const auto scan_result = quad_and_rep_criteria_result_of(
							arg_protein_a,
							arg_protein_b,
							arg_criteria,
							arg_scan_stride,
							numeric_cast<index_type>( a_from ),
							numeric_cast<index_type>( a_to   ),
							numeric_cast<index_type>( b_from ),
							numeric_cast<index_type>( b_to   )
						);
						x += make_pair( scan_result, score );
					}
				}
			}

			return x;
		}
	);
}
/// \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 ) );
}
			/// \brief Get the (wrapped) difference between the two pairs' to_residue psi angles
			inline angle_type to_psi_angle_difference(const size_size_pair &arg_indices_a, ///< The indices of the from/to residues in the first  protein
			                                          const size_size_pair &arg_indices_b, ///< The indices of the from/to residues in the second protein
			                                          const protein        &arg_protein_a, ///< The first  protein
			                                          const protein        &arg_protein_b  ///< The second protein
			                                          ) {
				const residue    &to_a_res = arg_protein_a.get_residue_ref_of_index( arg_indices_a.second );
				const residue    &to_b_res = arg_protein_b.get_residue_ref_of_index( arg_indices_b.second );
				const angle_type &to_psi_a = geom::make_angle_from_radians<angle_base_type>( angle_in_radians( to_a_res.get_psi_angle() ) );
				const angle_type &to_psi_b = geom::make_angle_from_radians<angle_base_type>( angle_in_radians( to_b_res.get_psi_angle() ) );
				return wrapped_difference( to_psi_a, to_psi_b );
			}
			/// \brief Get the (wrapped) difference between the two pairs' from_residue psi angles
			inline angle_type from_psi_angle_difference(const size_size_pair &arg_indices_a, ///< The indices of the from/to residues in the first  protein
			                                            const size_size_pair &arg_indices_b, ///< The indices of the from/to residues in the second protein
			                                            const protein        &arg_protein_a, ///< The first  protein
			                                            const protein        &arg_protein_b  ///< The second protein
			                                            ) {
				const residue &from_a_res = arg_protein_a.get_residue_ref_of_index( arg_indices_a.first );
				const residue &from_b_res = arg_protein_b.get_residue_ref_of_index( arg_indices_b.first );
				const auto     from_psi_a = geom::convert_angle_type<angle_base_type>( from_a_res.get_psi_angle() );
				const auto     from_psi_b = geom::convert_angle_type<angle_base_type>( from_b_res.get_psi_angle() );
				return wrapped_difference( from_psi_a, from_psi_b );
			}
/// \brief TODOCUMENT
///
/// Provide functions that allow this function to be expressed slightly more tightly
quad_criteria_result check_scan_on_final_alignment::rep_quad_criteria_result_of(const protein            &arg_query_protein,    ///< TODOCUMENT
                                                                                const protein            &arg_index_protein,    ///< TODOCUMENT
                                                                                const quad_criteria      &arg_criteria,         ///< TODOCUMENT
                                                                                const scan_stride        &arg_scan_stride,      ///< TODOCUMENT
                                                                                const index_type         &arg_query_from_index, ///< TODOCUMENT
                                                                                const index_type         &arg_query_to_index,   ///< TODOCUMENT
                                                                                const index_type         &arg_index_from_index, ///< TODOCUMENT
                                                                                const index_type         &arg_index_to_index    ///< TODOCUMENT
                                                                                ) {
	const auto from_rep_indices = get_from_rep_of_indices( arg_scan_stride, arg_query_from_index, arg_index_from_index );
	const auto to_rep_indices   = get_to_rep_of_indices  ( arg_scan_stride, arg_query_to_index,   arg_index_to_index   );

	if ( ! from_rep_indices || ! to_rep_indices ) {
		return quad_criteria_result::HAS_NO_REP;
	}

	const auto query_from_rep_index = from_rep_indices->first;
	const auto query_to_rep_index   = to_rep_indices->first;
	const auto index_from_rep_index = from_rep_indices->second;
	const auto index_to_rep_index   = to_rep_indices->second;
	const auto query_res_pair       = make_multi_struc_res_rep_pair(
		arg_query_protein.get_residue_ref_of_index( get_index_of_rep_index( arg_scan_stride.get_query_from_strider(), query_from_rep_index ) ),
		arg_query_protein.get_residue_ref_of_index( get_index_of_rep_index( arg_scan_stride.get_query_to_strider  (), query_to_rep_index   ) ),
		0,
		query_from_rep_index,
		query_to_rep_index
	);
	const auto index_res_pair       = make_multi_struc_res_rep_pair(
		arg_index_protein.get_residue_ref_of_index( get_index_of_rep_index( arg_scan_stride.get_index_from_strider(), index_from_rep_index ) ),
		arg_index_protein.get_residue_ref_of_index( get_index_of_rep_index( arg_scan_stride.get_index_to_strider  (), index_to_rep_index   ) ),
		0,
		index_from_rep_index,
		index_to_rep_index
	);
	const auto result               = criteria_result_of( arg_criteria, query_res_pair, index_res_pair );
//	if ( result != quad_criteria_result::PASS && result != quad_criteria_result::QUERY_FAILS_SINGLE_CHECKS && result != quad_criteria_result::INDEX_FAILS_SINGLE_CHECKS ) {
//		quad_criteria_result::PASS;
		cerr << "Quad: [("  << setw(  2 ) << right << arg_query_from_index
		     << ","         << setw(  2 ) << right << arg_index_from_index
		     << ")->("      << setw(  2 ) << right << arg_query_to_index
		     << ","         << setw(  2 ) << right << arg_index_to_index
		     << ")], Rep[(" << setw(  2 ) << right << query_from_rep_index
		     << ","         << setw(  2 ) << right << index_from_rep_index
		     << ")->("      << setw(  2 ) << right << query_to_rep_index
		     << ","         << setw(  2 ) << right << index_to_rep_index
		     << ")]="       << setw( 25 ) << right << result
//		     << ",A/"                              << query_res_pair
//		     << ",B/"                              << index_res_pair
		     << "\n";
//	}

	return result;
}
			/// \brief Calculate the squared distance between the views of the two residue pairs
			///
			/// Each view is the location of the to_residue's carbon-beta atom as seen from
			/// the coordinate frame of the from_residue
			inline double squared_distance(const size_size_pair &arg_indices_a, ///< The indices of the from/to residues in the first  protein
			                               const size_size_pair &arg_indices_b, ///< The indices of the from/to residues in the second protein
			                               const protein        &arg_protein_a, ///< The first  protein
			                               const protein        &arg_protein_b  ///< The second protein
			                               ) {
				const residue    &from_a_res = arg_protein_a.get_residue_ref_of_index( arg_indices_a.first  );
				const residue    &to_a_res   = arg_protein_a.get_residue_ref_of_index( arg_indices_a.second );
				const residue    &from_b_res = arg_protein_b.get_residue_ref_of_index( arg_indices_b.first  );
				const residue    &to_b_res   = arg_protein_b.get_residue_ref_of_index( arg_indices_b.second );

				const geom::coord view_a     = view_vector_of_residue_pair( from_a_res, to_a_res );
				const geom::coord view_b     = view_vector_of_residue_pair( from_b_res, to_b_res );

				return squared_distance_between_points( view_a, view_b );
			}
/// \brief TODOCUMENT
///
/// \relates
void cath::scan::detail::print_highlight_rep_pymol_commands(ostream                             &arg_os,               ///< TODOCUMENT
                                                            const check_scan_on_final_alignment &arg_csofa,            ///< TODOCUMENT
			                                                const protein                       &arg_protein,          ///< TODOCUMENT
			                                                const roled_scan_stride             &arg_roled_scan_stride ///< TODOCUMENT
			                                                ) {
	print_highlight_rep_pymol_commands( arg_os, arg_protein.get_title(), arg_csofa.get_rep_name_lists( arg_protein, arg_roled_scan_stride ) );
}
				/// \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;
				}
				/// \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;
				}
				/// \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;
				}
				/// \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;
				}
				/// \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;
				}
			/// \brief Calculate the view_frame of the pair
			///        (ie the coordinate frame of the to_residue's atoms in terms of the coordinate from of the from_residue's atoms)
			inline cath::geom::rotation view_frame(const protein &arg_protein,    ///< The protein containing the two residues
			                                       const size_t  &arg_from_index, ///< The index of the from_residue
			                                       const size_t  &arg_to_index    ///< The index of the to_residue
			                                       ) {
				return view_frame(
					arg_protein.get_residue_ref_of_index( arg_from_index ),
					arg_protein.get_residue_ref_of_index( arg_to_index   )
				);
			}
Ejemplo n.º 15
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 )
	);
}
		/// \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
					);
				}
			);
		}
Ejemplo n.º 17
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;
}
Ejemplo n.º 18
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;
	}
}
			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();
			}
/// \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();
}
Ejemplo n.º 21
0
/// \brief TODOCUMENT
size_t residue_querier::do_get_length(const protein &arg_protein ///< TODOCUMENT
                                      ) const {
	return arg_protein.get_length();
}
/// \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 )
	);
}