FileTypes::Type FileHandler::getTypeByFileName(const String& filename) { String basename = File::basename(filename), tmp; // special rules for "double extensions": if (basename.hasSuffix(".pep.xml")) return FileTypes::PEPXML; if (basename.hasSuffix(".prot.xml")) return FileTypes::PROTXML; try { tmp = basename.suffix('.'); } // no '.' => unknown type catch (Exception::ElementNotFound&) { // last chance, Bruker fid file if (basename == "fid") { return FileTypes::XMASS; } return FileTypes::UNKNOWN; } tmp.toUpper(); if (tmp == "BZ2" || tmp == "GZ") // todo ZIP (not supported yet): || tmp == "ZIP" { // do not use getTypeByContent() here, as this is deadly for output files! return getTypeByFileName(filename.prefix(filename.size() - tmp.size() - 1)); // check name without compression suffix (e.g. bla.mzML.gz --> bla.mzML) } return FileTypes::nameToType(tmp); }
//reimplemented to // - catch non-PSI CVs // - check if binaryDataArray name and type match void MzMLValidator::handleTerm_(const String & path, const CVTerm & parsed_term) { //some CVs cannot be validated because they use 'part_of' which spoils the inheritance if (parsed_term.accession.hasPrefix("GO:")) return; if (parsed_term.accession.hasPrefix("BTO:")) return; //check binary data array terms if (path.hasSuffix("/binaryDataArray/cvParam/@accession")) { //binary data array if (cv_.isChildOf(parsed_term.accession, "MS:1000513")) { binary_data_array_ = parsed_term.accession; } //binary data type if (cv_.isChildOf(parsed_term.accession, "MS:1000518")) { binary_data_type_ = parsed_term.accession; } //if both are parsed, check if they match if (binary_data_type_ != "" && binary_data_array_ != "") { if (!cv_.getTerm(binary_data_array_).xref_binary.contains(binary_data_type_)) { errors_.push_back(String("Binary data array of type '") + binary_data_array_ + " ! " + cv_.getTerm(binary_data_array_).name + "' cannot have the value type '" + binary_data_type_ + " ! " + cv_.getTerm(binary_data_type_).name + "'."); } } } SemanticValidator::handleTerm_(path, parsed_term); }
void ColoringSettingsDialog::forceMinValueChanged() { String text = String(((float)force_min_value_slider->value()) / 10.0); text = text.trimRight("0"); if (text.hasSuffix(".")) text += "0"; force_min_value_label->setText(text.c_str()); }
void ColoringSettingsDialog::maxTFChanged() { String text = String(((float)max_tf_slider->value()) / 10.0); text = text.trimRight("0"); if (text.hasSuffix(".")) text += "0"; max_tf_label->setText(text.c_str()); }
bool DigestionEnzymeRNA::setValueFromFile(const String& key, const String& value) { if (DigestionEnzyme::setValueFromFile(key, value)) { return true; } if (key.hasSuffix(":ThreePrimeGain")) { setThreePrimeGain(value); return true; } if (key.hasSuffix(":FivePrimeGain")) { setFivePrimeGain(value); return true; } return false; }
bool DigestionEnzyme::setValueFromFile(const String& key, const String& value) { if (key.hasSuffix(":Name")) { setName(value); return true; } if (key.hasSuffix(":RegEx")) { setRegEx(value); return true; } if (key.hasSuffix(":RegExDescription")) { setRegExDescription(value); return true; } if (key.hasSubstring(":Synonyms:")) { addSynonym(value); return true; } return false; }
void HelpViewer::onNotify(Message *message) { #ifdef BALL_VIEW_DEBUG Log.error() << "HelpViewer" << this << "onNotify " << message << std::endl; #endif if (RTTI::isKindOf<RegisterHelpSystemMessage>(message)) { RegisterHelpSystemMessage* msg = RTTI::castTo<RegisterHelpSystemMessage>(*message); if (msg->isRegister()) { registerForHelpSystem(msg->getObject(), msg->getURL()); } else { unregisterForHelpSystem(msg->getObject()); } return; } if (!RTTI::isKindOf<ShowHelpMessage>(message)) return; ShowHelpMessage* msg = RTTI::castTo<ShowHelpMessage>(*message); bool classname = false; String project = msg->getProject(); String url = msg->getURL(); if (project.hasSuffix(" class")) { classname = true; project = project.before(" "); } if (project != project_) return; if (classname) { showDocumentationFor(url, msg->getEntry()); return; } showHelp(url, msg->getEntry()); }
String File::findExecutable(const OpenMS::String& toolName) { // we first try the executablePath String exec = File::getExecutablePath() + toolName; #if OPENMS_WINDOWSPLATFORM if (!exec.hasSuffix(".exe")) exec += ".exe"; #endif if (File::exists(exec)) return exec; #if defined(__APPLE__) // check if we are in one of the bundles exec = File::getExecutablePath() + "../../../" + toolName; if (File::exists(exec)) return exec; // check if we are in one of the bundles in an installed bundle exec = File::getExecutablePath() + "../../../TOPP/" + toolName; if (File::exists(exec)) return exec; #endif // TODO(aiche): probe in PATH throw Exception::FileNotFound(__FILE__, __LINE__, __PRETTY_FUNCTION__, toolName); }
int main(int argc, char* argv[]) { CommandlineParser parpars("DockResultMerger", "merge docking output files", VERSION, String(__DATE__), "Convert, combine and store"); parpars.registerMandatoryInputFile("i", "input files"); parpars.registerMandatoryOutputFile("o", "output file"); parpars.registerOptionalStringParameter("score", "score property name", "score"); parpars.registerOptionalDoubleParameter("min", "minimal score value", -30.0); parpars.registerOptionalDoubleParameter("max", "maximal score value", 0.0); parpars.registerOptionalIntegerParameter("k", "number of output molecules", 20); parpars.registerFlag("rm", "remove input files after merging"); parpars.setSupportedFormats("i","mol2,sdf,drf"); parpars.setSupportedFormats("o","mol2,sdf,drf"); String manual = "This tool merges and sorts molecule files as generated by docking or rescoring.\n\nYou need to specify the property-tag name of the scores according to which the molecules should be sorted. Optionally you can filter those compounds that were assigned a score above and/or below specified thresholds. If desired, you can furthermore choose to have only the compounds with the k best scores written to the output file.\n\n Output of DockResultMerger is one molecule containing the molecules found in input-files (that matched all filter criteria, if any), sorted ascendingly according to their scores."; parpars.setToolManual(manual); parpars.parse(argc, argv); string e_property="score"; double energy_cutoff = 1e100; double energy_cuton = -1e100; Size best_k = 100000000; String output = parpars.get("o"); String s = parpars.get("score"); if (s != CommandlineParser::NOT_FOUND) e_property = s; s = parpars.get("min"); if (s != CommandlineParser::NOT_FOUND) energy_cuton = s.toDouble(); s = parpars.get("max"); if (s != CommandlineParser::NOT_FOUND) energy_cutoff = s.toDouble(); s = parpars.get("k"); if (s != CommandlineParser::NOT_FOUND) best_k = s.toInt(); const list<String>& n = parpars.getList("i"); vector<String> names; for (list<String>::const_iterator it = n.begin(); it != n.end(); it++) { names.push_back(*it); } bool drf_merge = 0; if (output.hasSuffix(".drf")) { for (Size i = 0; i < names.size(); i++) { if (names[i].hasSuffix(".drf")) drf_merge = 1; else if (drf_merge) { Log.error()<<"[Error:] Using drf and non-drf files together as input is not supported."<<endl; return 1; } } } if (drf_merge) { Log.error()<<"[Error:] Using DockingFiles (*.drf) is not possible since this version of DockResultMerger has been compiled without QtXML support."<<endl; return 1; } if (!drf_merge) { sortMolecules(names, output, best_k, e_property, energy_cutoff, energy_cuton); } else { mergeDRFiles(names, output, best_k, e_property, energy_cutoff, energy_cuton); } if (parpars.has("rm")) { for (Size i = 0; i < names.size(); i++) { File::remove(names[i]); } } return 0; }