26 #include <numeric/conversions.hh>
36 #include <basic/Tracer.hh>
39 #include <utility/vector1.hh>
40 #include <utility/options/StringVectorOption.hh>
42 static basic::Tracer
TR(
"core.chemical.adduct_util");
48 std::map< std::string, int >
50 utility::options::StringVectorOption &
add_vec
53 std::map< std::string, int > add_map;
57 Size over_index( add_vec.size() + 1 );
58 while( index != over_index ) {
61 ObjexxFCL::lowercase( this_adduct );
63 int max_uses_for_this_adduct( 9999 );
64 if( index != over_index && ObjexxFCL::is_int( add_vec[ index ] ) ) {
65 max_uses_for_this_adduct = ObjexxFCL::int_of( add_vec[ index ] );
69 add_map[ this_adduct ] = max_uses_for_this_adduct;
88 for( std::map< std::string, int >::const_iterator this_add = add_map.begin() ;
89 this_add != add_map.end() ; ++this_add ) {
90 bool not_found(
true );
92 for ( ResidueTypeCOPs::const_iterator this_rsd = rsd_types.begin(),
93 end_rsd = rsd_types.end(); this_rsd != end_rsd ; ++this_rsd ) {
96 if( not_found ==
false )
break;
100 rsd_add != end_rsd_add ; ++rsd_add ) {
103 if( ObjexxFCL::equali( this_add->first, check_name ) ) {
111 utility_exit_with_message(
"Requested undefined adduct: " + this_add->first +
'\n' );
121 using numeric::conversions::radians;
132 end_add_iter = rsd.
defined_adducts().end() ; add_iter != end_add_iter ;
133 ++add_iter, ++mask_iter ) {
136 if( !(*mask_iter) )
continue;
140 add_iter->mm_atom_type_name(), add_iter->atom_charge() );
145 radians( add_iter->theta() ), add_iter->d(), add_iter->stub_atom1(), add_iter->stub_atom2(),
146 add_iter->stub_atom3() );
147 TR.Debug <<
"Making a patch op for residue " << rsd.
name() <<
" adduct " << add_iter->adduct_name() <<
148 " phi raw " << add_iter->phi() <<
" theta raw " << add_iter->theta() <<
" d raw " << add_iter->d() << std::endl;
149 TR.Debug <<
"Using stub atoms " << add_iter->stub_atom1() <<
" , " << add_iter->stub_atom2() <<
" , " <<
150 add_iter->stub_atom3() << std::endl;
154 new_rsd_name = new_rsd_name +
"_adduct:" + add_iter->atom_name();
161 TR <<
"Setting new rsd name to " << new_rsd_name << std::endl;
162 new_rsd_type->name( new_rsd_name );
165 new_rsd_type->add_variant_type(
ADDUCT );
170 new_rsd_type->set_adduct_flag(
true );