15 #include <basic/Tracer.hh>
17 #include <utility/string_util.hh>
22 #include <utility/exit.hh>
23 #include <numeric/xyzVector.hh>
33 #include <boost/foreach.hpp>
34 #define foreach BOOST_FOREACH
75 connection_table_lines_(connection_table_lines), molecule_container_(molecule_container), mol_data_(mol_data)
83 core::Size atom_count = atoi(counts_line.substr(0,3).c_str());
84 core::Size bond_count = atoi(counts_line.substr(3,3).c_str());
86 ctabParserTracer.Debug << atom_count <<
" atoms and " << bond_count <<
" bonds" <<std::endl;
89 if(version_tag !=
"V2000")
91 utility_exit_with_message(
"This doesnt look like a V2000 CTAB, bailing out");
99 if(line_number <= last_atom)
102 }
else if(line_number <= last_bond)
109 std::map<core::Size, std::string>::iterator atom_iterator;
168 core::Size parameter_index = atom_type_set->extra_parameter_index(
"CHARGE");
169 core::Real charge = atom_type_set->operator[](atom_type_index).extra_parameter(parameter_index);
175 core::Real x_coord = atof(atom_line.substr(0,10).c_str());
176 core::Real y_coord = atof(atom_line.substr(10,10).c_str());
177 core::Real z_coord = atof(atom_line.substr(20,10).c_str());
178 ctabParserTracer.Debug <<
"atom " <<atom_number <<
" has coordinates " << x_coord <<
',' << y_coord <<
',' << z_coord << std::endl;
179 std::string element_name = atom_line.substr(31,3).c_str();
180 if(element_name.at(1)==
' ') {
181 element_name=element_name.substr(0,1);
182 }
else if (element_name.at(2)==
' ') {
183 element_name=element_name.substr(0,2);
187 std::stringstream convert_stream;
188 convert_stream << atom_number;
189 atom_number_string = convert_stream.str();
196 std::string element_id = element_name+ atom_number_string;
197 utility::add_spaces_left_align(element_id,4);
199 core::Size charge = atoi(atom_line.substr(36,3).c_str());
210 core::Size atom1_index = atoi(bond_line.substr(0,3).c_str());
211 core::Size atom2_index = atoi(bond_line.substr(3,3).c_str());
216 ctabParserTracer.Debug <<
"bond " << atom1_id <<
" to " << atom2_id <<
" of type " << bond_type << std::endl;
223 std::map<core::Size, std::string> data_map;
227 if(line.find(
"> <Rosetta AtomTypes>")!= std::string::npos)
233 if(atom_type_data ==
"")
240 for(
core::Size index = 1; index <= tokens.size();++index)
244 utility::trim(token_split[2],
"(");
245 utility::trim(token_split[3],
")");
247 core::Size atomno = atoi(token_split[2].c_str());
248 std::pair<core::Size, std::string> atom_type_point(atomno,token_split[3]);
249 data_map.insert(atom_type_point);
264 connection_table_lines_(connection_table_lines), molecule_container_(molecule_container), mol_data_(mol_data)
311 foreach(
std::string extra_parameter, extra_parameters){
312 if(extra_parameter.find(query) == std::string::npos)
318 core::Size value_length = extra_parameter.size() - (query.size()+1);
321 std::string value_string = extra_parameter.substr(value_start,value_length);
322 core::Real value = atof(value_string.c_str());
331 bool atom_block(
false);
332 bool bond_block(
false);
336 foreach(
std::string current_line, connector_table_lines_){
346 if(line_vector[2] ==
"END")
350 if(line_vector[2] !=
"V30" || line_vector.size() <2)
354 if(line_vector[3] ==
"COUNTS")
356 atom_count = atoi(line_vector[4].c_str());
357 bond_count = atoi(line_vector[5].c_str());
358 }
else if(line_vector[3] ==
"BEGIN")
360 if (line_vector[4] ==
"ATOM")
362 else if (line_vector[4] ==
"BOND")
364 }
else if(line_vector[3] ==
"END")
366 if (line_vector[4] ==
"ATOM")
368 else if (line_vector[4] ==
"BOND")
379 std::map<core::Size, std::string>::iterator atom_iterator;
386 std::map<core::Size,std::string>::iterator atom_type_it = atom_type_data.find(atomno);
387 if(atom_type_it != atom_type_data.end())
408 core::Size index = atoi(atom_vector[3].c_str());
410 std::string element_id(element_name+atom_vector[3]);
411 utility::add_spaces_left_align(element_id,4);
412 core::Real x_coord = atof(atom_vector[5].c_str());
413 core::Real y_coord = atof(atom_vector[6].c_str());
414 core::Real z_coord = atof(atom_vector[7].c_str());
436 core::Size index = atoi(bond_vector[3].c_str());
439 core::Size atom1_index = atoi(bond_vector[5].c_str());
440 core::Size atom2_index = atoi(bond_vector[6].c_str());
445 std::vector<std::string> extra_parameters;
446 std::copy(bond_vector.begin()+8, bond_vector.end(),extra_parameters.begin());
454 std::map<core::Size, std::string> data_map;
467 if(tokens.size() == 0)
474 for(
core::Size index = 0; index < tokens.size();++index)
478 utility::trim(token_split[1],
"(");
479 utility::trim(token_split[2],
")");
481 core::Size atomno = atoi(token_split[1].c_str());
482 std::pair<core::Size, std::string> atom_type_point(atomno,token_split[2]);
483 data_map.insert(atom_type_point);