/// \brief Escape residue name strings for use in PyMOL
str_vec pymol_tools::parse_residue_names_for_pymol(const residue_name_vec &arg_residue_names ///< The residue name strings to escape
                                                   ) {
	str_vec new_residue_names;
	new_residue_names.reserve( arg_residue_names.size() );
	for (const residue_name &the_residue_name : arg_residue_names) {
		new_residue_names.push_back( parse_residue_name_for_pymol( the_residue_name ) );
	}
	return new_residue_names;
}
/// \brief TODOCUMENT
///
/// \relates residue_name_align_map
residue_name_align_map cath::align::detail::make_residue_name_align_map(const residue_name_vec &arg_residue_names ///< TODOCUMENT
                                                                        ) {
	str_vec residue_name_strings;
	residue_name_strings.reserve( arg_residue_names.size() );
	for (const residue_name &the_residue_name : arg_residue_names) {
		residue_name_strings.push_back( lexical_cast<string>( the_residue_name ) );
	}
	return residue_name_align_map( residue_name_strings );
}
Example #3
0
/// \brief Convenience function for read_alignment_from_cath_ssap_legacy_format() to use
opt_aln_posn cath::align::search_for_residue_in_residue_names(const size_t           &arg_pos,           ///< TODOCUMENT
                                                              const residue_name_vec &arg_residue_names, ///< TODOCUMENT
                                                              const char             &arg_amino_acid,    ///< TODOCUMENT
                                                              const residue_name     &arg_residue_name,  ///< TODOCUMENT
                                                              ostream                &/*arg_stderr*/     ///< TODOCUMENT
                                                              ) {
	const bool residue_is_present = ( arg_amino_acid != '0' );
	if ( residue_is_present ) {
		if (arg_pos >= arg_residue_names.size()) {
			BOOST_THROW_EXCEPTION(runtime_error_exception("Counter has gone past end of list of residues whilst loading alignment"));
		}
		const auto res_itr = find(
			common::cbegin( arg_residue_names ) + numeric_cast<ptrdiff_t>( arg_pos ),
			common::cend  ( arg_residue_names ),
			arg_residue_name
		);
		if ( res_itr == common::cend( arg_residue_names ) ) {
			cerr << "Residue names being searched:\n\n";
			for (const residue_name &the_res_name : arg_residue_names) {
				cerr << " " << the_res_name;
			}
			cerr << "\n" << endl;
			BOOST_THROW_EXCEPTION(runtime_error_exception(
				"Unable to find residue "
				+ lexical_cast<string>( arg_residue_name )
				+ " from alignment in list of residues, starting from position "
				+ lexical_cast<string>( arg_pos )
			));
		}

		const size_t new_pos = numeric_cast<size_t>( distance( common::cbegin( arg_residue_names ), res_itr ) );
		if ( new_pos != arg_pos + 1 && ( new_pos != 0 || arg_pos != 0 ) ) {
			const size_t jump = new_pos - (arg_pos + 1);
			BOOST_LOG_TRIVIAL( warning ) << "Missing some residues whilst loading alignment: jumped "
			                             << jump
			                             << " position(s) from residue "
			                             << arg_residue_names[arg_pos]
			                             << " (in position "
			                             << arg_pos
			                             << ") to residue "
			                             << arg_residue_names[new_pos]
			                             << " (in position "
			                             << new_pos
			                             << ")";
		}
		return opt_aln_posn( new_pos );
	}
	return opt_aln_posn( none );
}