//reimplemented in order to remove the "indexmzML" tag from the front (if present) String MzMLValidator::getPath_(UInt remove_from_end) const { String path; if (open_tags_.size() != 0 && open_tags_.front() == "indexedmzML") { path.concatenate(open_tags_.begin() + 1, open_tags_.end() - remove_from_end, "/"); } else { path.concatenate(open_tags_.begin(), open_tags_.end() - remove_from_end, "/"); } path = String("/") + path; return path; }
void ConsensusIDAlgorithmIdentity::preprocess_( vector<PeptideIdentification>& ids) { // check score types and orientations: bool higher_better = ids[0].isHigherScoreBetter(); set<String> score_types; for (vector<PeptideIdentification>::iterator pep_it = ids.begin(); pep_it != ids.end(); ++pep_it) { if (pep_it->isHigherScoreBetter() != higher_better) { // scores with different orientations definitely aren't comparable: String hi_lo = higher_better ? "higher/lower" : "lower/higher"; String msg = "Score types '" + ids[0].getScoreType() + "' and '" + pep_it->getScoreType() + "' have different orientations (" + hi_lo + " is better) and cannot be compared meaningfully."; throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, msg, higher_better ? "false" : "true"); } score_types.insert(pep_it->getScoreType()); } if (score_types.size() > 1) { String types; types.concatenate(score_types.begin(), score_types.end(), "'/'"); LOG_WARN << "Warning: Different score types for peptide hits found ('" << types << "'). If the scores are not comparable, " << "results will be meaningless." << endl; } }
void CsvFile::addRow(const StringList& list) { StringList elements = list; if (itemenclosed_) { for (Size i = 0; i < elements.size(); ++i) { elements[i].quote('"', String::NONE); } } String line; line.concatenate(elements.begin(), elements.end(), itemseperator_); addLine(line); }
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; } } }
//reimplemented in order to handle index MzML bool MzMLFile::isValid(const String& filename, std::ostream& os) { //determine if this is indexed mzML or not bool indexed = false; TextFile file(filename, true, 4); String s; s.concatenate(file.begin(), file.end()); if (s.hasSubstring("<indexedmzML")) { indexed = true; } // find the corresponding schema String current_location; if (indexed) { current_location = File::find(indexed_schema_location_); } else { current_location = File::find(schema_location_); } return XMLValidator().isValid(filename, current_location, os); }
String XQuestResultXMLFile::getxQuestBase64EncodedSpectrum_(const PeakSpectrum& spec, String header) { std::vector<String> in_strings; StringList sl; double precursor_mz = 0; double precursor_z = 0; if (spec.getPrecursors().size() > 0) { precursor_mz = Math::roundDecimal(spec.getPrecursors()[0].getMZ(), -9); precursor_z = spec.getPrecursors()[0].getCharge(); } // header lines if (!header.empty()) // common or xlinker spectrum will be reported { sl.push_back(header + "\n"); // e.g. GUA1372-S14-A-LRRK2_DSS_1A3.03873.03873.3.dta,GUA1372-S14-A-LRRK2_DSS_1A3.03863.03863.3.dta sl.push_back(String(precursor_mz) + "\n"); sl.push_back(String(precursor_z) + "\n"); } else // light or heavy spectrum will be reported { sl.push_back(String(precursor_mz) + "\t" + String(precursor_z) + "\n"); } PeakSpectrum::IntegerDataArray charges; if (spec.getIntegerDataArrays().size() > 0) { charges = spec.getIntegerDataArrays()[0]; } // write peaks for (Size i = 0; i != spec.size(); ++i) { String s; s += String(Math::roundDecimal(spec[i].getMZ(), -9)) + "\t"; s += String(spec[i].getIntensity()) + "\t"; if (charges.size() > 0) { s += String(charges[i]); } else { s += "0"; } s += "\n"; sl.push_back(s); } String out; out.concatenate(sl.begin(), sl.end(), ""); in_strings.push_back(out); String out_encoded; Base64().encodeStrings(in_strings, out_encoded, false, false); String out_wrapped; wrap_(out_encoded, 76, out_wrapped); return out_wrapped; }
void convertINI2HTML(const Param & p, ostream & os) { // the .css file is included via the Header.html (see doc/doxygen/common/Header.html) os << "<div class=\"ini_global\">\n"; os << "<div class=\"legend\">\n"; os << "<b>Legend:</b><br>\n"; os << " <div class=\"item item_required\">required parameter</div>\n"; os << " <div class=\"item item_advanced\">advanced parameter</div>\n"; os << "</div>\n"; Param::ParamIterator it = p.begin(); String indentation = " "; while (it != p.end()) { string key = it.getName(); //write opened/closed nodes const std::vector<Param::ParamIterator::TraceInfo> & trace = it.getTrace(); for (std::vector<Param::ParamIterator::TraceInfo>::const_iterator it2 = trace.begin(); it2 != trace.end(); ++it2) { if (it2->opened) //opened node { String d = it2->description; d.substitute("\n", "<br>"); os << indentation << "<div class=\"node\"><span class=\"node_name\">" << (String().fillLeft('+', (UInt) indentation.size() / 2) + it2->name) << "</span><span class=\"node_description\">" << (d) << "</span></div>" << "\n"; indentation += " "; } else //closed node { indentation.resize(indentation.size() - 2); //os << indentation << "</div>" << "\n"; } } //write item String s_attr; String s_req; if (it->tags.find("advanced") != it->tags.end()) s_attr += " item_advanced"; // optionally add advanced class if (it->tags.find("required") != it->tags.end()) s_req += " item_required"; // optionally add required class DataValue::DataType value_type = it->value.valueType(); //write opening tag os << indentation << "<div class=\"item" + s_attr + "\"><span class=\"item_name" + s_req + "\" style=\"padding-left:" << indentation.size() * 4 << "px;\">" << (it->name) << "</span><span class=\"item_value\">" << it->value.toString() << "</span>" << "\n"; //replace all critical characters in description String d = it->description; d.substitute("\n", "<br>"); os << "<span class=\"item_description\">" << (d) << "</span>"; //tags String list; for (set<String>::const_iterator tag_it = it->tags.begin(); tag_it != it->tags.end(); ++tag_it) { if (*tag_it == "advanced") continue; // do not list "advanced" or "required" (this is done by color coding) if (*tag_it == "required") continue; if (!list.empty()) list += ","; list += *tag_it; } os << "<span class=\"item_tags\">" << (list) << "</span>"; //restrictions String restrictions = ""; bool escape_restrictions(true); switch (value_type) { case DataValue::INT_VALUE: case DataValue::INT_LIST: { bool min_set = (it->min_int != -numeric_limits<Int>::max()); bool max_set = (it->max_int != numeric_limits<Int>::max()); if (max_set || min_set) { if (min_set) restrictions += String(it->min_int); else restrictions += "-∞"; // infinity symbol restrictions += ':'; if (max_set) restrictions += String(it->max_int); else restrictions += "∞"; } escape_restrictions = false; // prevent html escape of infinity symbol } break; case DataValue::DOUBLE_VALUE: case DataValue::DOUBLE_LIST: { bool min_set = (it->min_float != -numeric_limits<DoubleReal>::max()); bool max_set = (it->max_float != numeric_limits<DoubleReal>::max()); if (max_set || min_set) { if (min_set) restrictions += String(it->min_float); else restrictions += "-∞"; // infinity symbol restrictions += ':'; if (max_set) restrictions += String(it->max_float); else restrictions += "∞"; } escape_restrictions = false; // prevent html escape of infinity symbol } break; case DataValue::STRING_VALUE: case DataValue::STRING_LIST: if (it->valid_strings.size() != 0) { restrictions.concatenate(it->valid_strings.begin(), it->valid_strings.end(), ","); } break; default: break; } if (restrictions.empty()) restrictions = " "; // create content, such that the cell gets an underline os << "<span class=\"item_restrictions\">" << restrictions << "</span>"; os << "</div>"; // end div item ++it; } os << "</div>\n"; // end global div }