/** * \file SettingsData.cpp * \brief stored a multifit settings data * * Copyright 2007-2010 IMP Inventors. All rights reserved. * */ #include IMPMULTIFIT_BEGIN_NAMESPACE namespace { std::string join_path(const std::string &path, const std::string &name) { return path + "/" + boost::lexical_cast(name); } } ComponentHeader parse_component_line( const std::string &path,const std::string &line) { try { typedef boost::split_iterator string_split_iterator; IMP_USAGE_CHECK(line.size() > 0,"no data to parse"< line_split; boost::split(line_split, line, boost::is_any_of("|")); IMP_USAGE_CHECK(line_split.size() == 7, "Wrong format of input line : not enough fields in line:"<(line_split[0])); comp.set_filename(join_path(path, line_split[1])); comp.set_pdb_ap_fn(join_path(path, line_split[2])); comp.set_num_ap(boost::lexical_cast(line_split[3])); comp.set_transformations_fn(join_path(path, line_split[4])); comp.set_reference_fn(join_path(path, line_split[5])); return comp; } catch (IMP::Exception &e) { IMP_THROW("can not parse line:"< string_split_iterator; IMP_USAGE_CHECK(line.size() > 0,"no data to parse"< line_split; boost::split(line_split, line, boost::is_any_of("|")); IMP_USAGE_CHECK(line_split.size() == 10, "Expecting 10 fileds in input line, got "<< line_split.size() << " : " <(line_split[1])); dens.set_spacing(boost::lexical_cast(line_split[2])); dens.set_origin(algebra::Vector3D( boost::lexical_cast(line_split[3]), boost::lexical_cast(line_split[4]), boost::lexical_cast(line_split[5]))); dens.set_pdb_fine_ap_fn(join_path(path, line_split[6])); dens.set_pdb_coarse_ap_fn(join_path(path, line_split[7])); dens.set_junction_tree_fn(join_path(path, line_split[8])); return dens; } SettingsData read_settings(const char *filename,const char *data_path) { std::fstream in; in.open(filename, std::fstream::in); IMP_USAGE_CHECK(in.good(), "Problem openning file " << filename << " for reading " << std::endl); std::string line; SettingsData header; getline(in, line); //skip header line int status=0; while (!in.eof()) { getline(in, line); //skip header line std::vector line_split; boost::split(line_split, line, boost::is_any_of("|")); if ((line_split.size() == 7) && (status == 0)) {//protein line header.add_component_header(parse_component_line(data_path,line)); } else if (status==0) {//map header line status=1; } else if (status==1){ //map line header.set_assembly_header(parse_assembly_line(data_path,line)); status=2; } else {//(status == 2) IMP_WARN("the line was not parsed:"<