void QuantitativeExperimentalDesign::mapFiles2Design_(map<String, StringList> & experiments, TextFile & file) { // get the defined separator from the parameter setting String separator; getSeparator_(separator); // read the header and split according separator StringList header; TextFile::Iterator iter = file.begin(); iter->split(separator, header); ++iter; // define the column of file name and experimental setting UInt expCol = -1; UInt fileCol = -1; analyzeHeader_(expCol, fileCol, header); // read rest of the file, each row is already split according to separator vector<StringList> rows; for (; iter != file.end(); ++iter) { StringList column; iter->split(separator, column); rows.push_back(column); } // map all file names to the respective experimental setting map<String, StringList>::iterator it; for (vector<StringList>::iterator iter = rows.begin(); iter != rows.end(); ++iter) { // get experimental setting and file name String experiment = iter->at(expCol); String fileName = iter->at(fileCol); // search for experimental setting it = experiments.find(experiment); // if experimental setting is already present, add file name if (it != experiments.end()) { StringList & list = it->second; list.push_back(fileName); } // otherwise create new list else { StringList newList; newList.push_back(fileName); experiments.insert(make_pair(experiment, newList)); } } LOG_INFO << "\n Statistics: \n"; for (it = experiments.begin(); it != experiments.end(); ++it) { LOG_INFO << "Experiment: " << it->first << ", number datasets: " << it->second.size() << endl; } }
explicit HeaderInfo(const String& filename) { header_description = "-- empty --"; TextFile tf; tf.load(filename); String content; content.concatenate(tf.begin(), tf.end(), ";"); String search = "$$ Sample Description:"; Size pos = content.find(search); if (pos != std::string::npos) { pos += search.size(); Size pos_end = content.find("$$", pos); if (pos_end != std::string::npos) { String tmp = content.substr(pos, pos_end - pos - 1); if (!tmp.trim().empty()) header_description = tmp; //std::cerr << "Header info is: " << header_description << std::endl; } } }
EnzymaticDigestionLogModel::EnzymaticDigestionLogModel() : enzyme_(*EnzymesDB::getInstance()->getEnzyme("Trypsin")), log_model_threshold_(0.25), model_data_() { // load the cleavage model from disk (might throw exceptions) TextFile tf; tf.load(File::find("./CHEMISTRY/MissedCleavage.model"), true); for (TextFile::ConstIterator it = tf.begin(); it != tf.end(); ++it) { String tmp = *it; if (tmp.trim().hasPrefix("#")) continue; // skip comments StringList components; tmp.split(' ', components); if (components.size() != 4) { throw Exception::ParseError(__FILE__, __LINE__, __PRETTY_FUNCTION__, String("split(' ',") + tmp + ")", String("Got ") + components.size() + " columns, expected 4!"); } BindingSite_ bs(components[0].toInt(), components[1].trim()); CleavageModel_ cl(components[2].toDouble(), components[3].toDouble()); model_data_[bs] = cl; } }