本文整理汇总了C++中TextFile::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ TextFile::begin方法的具体用法?C++ TextFile::begin怎么用?C++ TextFile::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextFile
的用法示例。
在下文中一共展示了TextFile::begin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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;
}
}
示例2: HeaderInfo
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;
}
}
}
示例3: ParseError
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;
}
}