Skip to content

Commit

Permalink
augment ParamCTD file with new tag (bumping version to version 1.8)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbielow committed Jun 6, 2024
1 parent c4157b8 commit d045489
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 60 deletions.
136 changes: 136 additions & 0 deletions share/OpenMS/SCHEMAS/Param_1_8_0.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="PARAMETERS" type="PARAMETERSType">
<xs:annotation>
<xs:documentation>Main parameters node.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="PARAMETERSType">
<xs:sequence>
<xs:group ref="ITEMS" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="NODE" type="NODEType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="version" type="versionString" />
</xs:complexType>
<xs:complexType name="AbstractITEMType" abstract="true">
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="type" type="PossibleITEMType" use="required">
<xs:annotation>
<xs:documentation>The type of the specified ITEM. Either input or output.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="description" type="xs:string" default="" />
<xs:attribute name="short_description" type="xs:string">
<xs:annotation>
<xs:documentation>A short description of the parameter.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="tags" type="xs:string" default="false">
<xs:annotation>
<xs:documentation>Additional annotations of the parameter incl. required, advanced, thread, debug, internal, file-type-override, log</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="restrictions" type="xs:string" default="" />
<xs:attribute name="supported_formats" type="xs:string" default="false">
<xs:annotation>
<xs:documentation>Defines the expected file types. Only valid for input-file, output-file, input-prefix, and output-prefix parameters.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="required" type="xs:boolean" default="false">
<xs:annotation>
<xs:documentation>Deprecated, embed as tag into tags attribute. Will be removed in v2.0.0 of the schema.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="advanced" type="xs:boolean" default="false">
<xs:annotation>
<xs:documentation>Deprecated, embed as tag into tags attribute. Will be removed in v2.0.0 of the schema.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="position" type="xs:nonNegativeInteger" use="optional">
<xs:annotation>
<xs:documentation>Position of the parameter (0-based). Certain parameters are not associated to an option identifier, rather, to the position on which they appear on the command-line.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:complexType name="ITEMLISTType">
<xs:complexContent>
<xs:extension base="AbstractITEMType">
<xs:sequence>
<xs:element name="LISTITEM" type="LISTITEMType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="LISTITEMType">
<xs:attribute name="value" use="required" />
</xs:complexType>
<xs:complexType name="ITEMType">
<xs:complexContent>
<xs:extension base="AbstractITEMType">
<xs:attribute name="value" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>The actual value of the parameter.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="default" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>If available, the default value of the given parameter.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:simpleType name="PossibleITEMType">
<xs:annotation>
<xs:documentation>Defines the possible types available in the type attribute of ITEM and ITEMLIST.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="int" />
<xs:enumeration value="double" />
<xs:enumeration value="float" />
<xs:enumeration value="string" />
<xs:enumeration value="int-pair" />
<xs:enumeration value="double-pair" />
<xs:enumeration value="input-prefix" />
<xs:enumeration value="output-prefix" />
<xs:enumeration value="input-file" />
<xs:enumeration value="output-file" />
<xs:enumeration value="output-dir" />
<xs:enumeration value="bool" />
</xs:restriction>
</xs:simpleType>
<xs:group name="ITEMS">
<xs:choice>
<xs:element name="ITEM" type="ITEMType" />
<xs:element name="ITEMLIST" type="ITEMLISTType" />
</xs:choice>
</xs:group>
<xs:complexType name="NODEType">
<xs:annotation>
<xs:documentation />
</xs:annotation>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="ITEMS" />
<xs:element name="NODE" type="NODEType" />
</xs:choice>
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="description" type="xs:string" default="" />
</xs:complexType>
<xs:simpleType name="versionString">
<xs:restriction base="xs:string">
<xs:pattern value="\d+\.\d+(\.\d+)?" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
4 changes: 2 additions & 2 deletions src/openms/include/OpenMS/FORMAT/ParamCTDFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace OpenMS
*/
static void replace(std::string& replace_in, char to_replace, const std::string& replace_with);

const std::string schema_location_ = "/SCHEMAS/Param_1_7_0.xsd";
const std::string schema_version_ = "1.7.0";
const std::string schema_location_ = "/SCHEMAS/Param_1_8_0.xsd";
const std::string schema_version_ = "1.8.0";
};
}
31 changes: 20 additions & 11 deletions src/openms/source/FORMAT/ParamCTDFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
// --------------------------------------------------------------------------

#include <OpenMS/FORMAT/ParamCTDFile.h>

#include <OpenMS/APPLICATIONS/TOPPBase.h>

#include <cstdint>
#include <fstream>
#include <iostream>
#include <limits>


namespace OpenMS
{
void ParamCTDFile::store(const std::string& filename, const Param& param, const ToolInfo& tool_info) const
Expand Down Expand Up @@ -44,7 +48,7 @@ namespace OpenMS

// write ctd specific stuff
os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
os << R"(<tool ctdVersion="1.7" version=")" << tool_info.version_ << R"(" name=")" << tool_info.name_ << R"(" docurl=")" << tool_info.docurl_ << R"(" category=")" << tool_info.category_
os << R"(<tool ctdVersion="1.8" version=")" << tool_info.version_ << R"(" name=")" << tool_info.name_ << R"(" docurl=")" << tool_info.docurl_ << R"(" category=")" << tool_info.category_
<< "\" >\n";
os << "<description><![CDATA[" << tool_info.description_ << "]]></description>\n";
os << "<manual><![CDATA[" << tool_info.description_ << "]]></manual>\n";
Expand Down Expand Up @@ -107,20 +111,25 @@ namespace OpenMS
os << param_it->value.toString() << R"(" type="double")";
break;
case ParamValue::STRING_VALUE:
if (tag_list.find("input file") != tag_list.end())
if (tag_list.find(TOPPBase::TAG_INPUT_FILE) != tag_list.end())
{
os << escapeXML(param_it->value.toString()) << R"(" type="input-file")";
tag_list.erase("input file");
tag_list.erase(TOPPBase::TAG_INPUT_FILE);
}
else if (tag_list.find("output file") != tag_list.end())
else if (tag_list.find(TOPPBase::TAG_OUTPUT_FILE) != tag_list.end())
{
os << escapeXML(param_it->value.toString()) << R"(" type="output-file")";
tag_list.erase("output file");
tag_list.erase(TOPPBase::TAG_OUTPUT_FILE);
}
else if (tag_list.find(TOPPBase::TAG_OUTPUT_DIR) != tag_list.end())
{
os << escapeXML(param_it->value.toString()) << R"(" type="output-dir")";
tag_list.erase(TOPPBase::TAG_OUTPUT_DIR);
}
else if (tag_list.find("output prefix") != tag_list.end())
else if (tag_list.find(TOPPBase::TAG_OUTPUT_PREFIX) != tag_list.end())
{
os << escapeXML(param_it->value.toString()) << R"(" type="output-prefix")";
tag_list.erase("output prefix");
tag_list.erase(TOPPBase::TAG_OUTPUT_PREFIX);
}
else if (param_it->valid_strings.size() == 2 && param_it->valid_strings[0] == "true" && param_it->valid_strings[1] == "false" && param_it->value == "false")
{
Expand All @@ -138,15 +147,15 @@ namespace OpenMS
}
break;
case ParamValue::STRING_LIST:
if (tag_list.find("input file") != tag_list.end())
if (tag_list.find(TOPPBase::TAG_INPUT_FILE) != tag_list.end())
{
os << R"(" type="input-file")";
tag_list.erase("input file");
tag_list.erase(TOPPBase::TAG_INPUT_FILE);
}
else if (tag_list.find("output file") != tag_list.end())
else if (tag_list.find(TOPPBase::TAG_OUTPUT_FILE) != tag_list.end())
{
os << R"(" type="output-file")";
tag_list.erase("output file");
tag_list.erase(TOPPBase::TAG_OUTPUT_FILE);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/openms/source/FORMAT/ParamXMLFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace OpenMS
}

ParamXMLFile::ParamXMLFile() :
XMLFile("/SCHEMAS/Param_1_7_0.xsd", "1.7.0")
XMLFile("/SCHEMAS/Param_1_8_0.xsd", "1.8.0")
{
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<tool ctdVersion="1.7" version="2.6.0-pre-STL-ParamCTD-2021-06-02" name="AccurateMassSearch" docurl="http://www.openms.de/doxygen/nightly/html/TOPP_AccurateMassSearch.html" category="Utilities" >
<description><![CDATA[Match MS signals to molecules from a database by mass.]]></description>
<manual><![CDATA[Match MS signals to molecules from a database by mass.]]></manual>
<citations>
<citation doi="10.1038/s41592-024-02197-7" url="" />
</citations>
<PARAMETERS version="1.7.0" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/OpenMS/OpenMS/develop/share/OpenMS/SCHEMAS/Param_1_7_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ITEMLIST name="stringlist" type="string" description="StringList Description" required="false" advanced="false" >
<LISTITEM value="a"/>
<LISTITEM value="bb"/>
<LISTITEM value="ccc"/>
</ITEMLIST>
<ITEMLIST name="intlist" type="int" description="" required="false" advanced="false" >
<LISTITEM value="1"/>
<LISTITEM value="22"/>
<LISTITEM value="333"/>
</ITEMLIST>
<ITEM name="item" value="bla" type="string" description="" required="false" advanced="false" />
<ITEMLIST name="stringlist2" type="string" description="" required="false" advanced="false" >
</ITEMLIST>
<ITEMLIST name="intlist2" type="int" description="" required="false" advanced="false" >
</ITEMLIST>
<ITEM name="item1" value="7" type="int" description="" required="false" advanced="false" />
<ITEMLIST name="intlist3" type="int" description="" required="false" advanced="false" >
<LISTITEM value="1"/>
</ITEMLIST>
<ITEMLIST name="stringlist3" type="string" description="" required="false" advanced="false" >
<LISTITEM value="1"/>
</ITEMLIST>
<ITEM name="item3" value="7.6" type="double" description="" required="false" advanced="false" />
<ITEMLIST name="doublelist" type="double" description="" required="false" advanced="false" >
<LISTITEM value="1.22"/>
<LISTITEM value="2.33"/>
<LISTITEM value="4.55"/>
</ITEMLIST>
<ITEMLIST name="doublelist3" type="double" description="" required="false" advanced="false" >
<LISTITEM value="1.4"/>
</ITEMLIST>
<ITEM name="file_parameter" value="" type="input-file" description="This is a file parameter." required="false" advanced="false" supported_formats="*.mzML,*.mzXML" />
<ITEM name="advanced_parameter" value="" type="string" description="This is an advanced parameter." required="false" advanced="true" />
<ITEM name="flag" value="false" type="bool" description="This is a flag i.e. in a command line input it does not need a value." required="false" advanced="false" />
<ITEM name="noflagJustTrueFalse" value="true" type="string" description="This is not a flag but has a boolean meaning." required="false" advanced="false" restrictions="true,false" />
</PARAMETERS>
</tool>
<?xml version="1.0" encoding="UTF-8"?>
<tool ctdVersion="1.8" version="2.6.0-pre-STL-ParamCTD-2021-06-02" name="AccurateMassSearch" docurl="http://www.openms.de/doxygen/nightly/html/TOPP_AccurateMassSearch.html" category="Utilities" >
<description><![CDATA[Match MS signals to molecules from a database by mass.]]></description>
<manual><![CDATA[Match MS signals to molecules from a database by mass.]]></manual>
<citations>
<citation doi="10.1038/s41592-024-02197-7" url="" />
</citations>
<PARAMETERS version="1.8.0" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/OpenMS/OpenMS/develop/share/OpenMS/SCHEMAS/Param_1_8_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ITEMLIST name="stringlist" type="string" description="StringList Description" required="false" advanced="false" >
<LISTITEM value="a"/>
<LISTITEM value="bb"/>
<LISTITEM value="ccc"/>
</ITEMLIST>
<ITEMLIST name="intlist" type="int" description="" required="false" advanced="false" >
<LISTITEM value="1"/>
<LISTITEM value="22"/>
<LISTITEM value="333"/>
</ITEMLIST>
<ITEM name="item" value="bla" type="string" description="" required="false" advanced="false" />
<ITEMLIST name="stringlist2" type="string" description="" required="false" advanced="false" >
</ITEMLIST>
<ITEMLIST name="intlist2" type="int" description="" required="false" advanced="false" >
</ITEMLIST>
<ITEM name="item1" value="7" type="int" description="" required="false" advanced="false" />
<ITEMLIST name="intlist3" type="int" description="" required="false" advanced="false" >
<LISTITEM value="1"/>
</ITEMLIST>
<ITEMLIST name="stringlist3" type="string" description="" required="false" advanced="false" >
<LISTITEM value="1"/>
</ITEMLIST>
<ITEM name="item3" value="7.6" type="double" description="" required="false" advanced="false" />
<ITEMLIST name="doublelist" type="double" description="" required="false" advanced="false" >
<LISTITEM value="1.22"/>
<LISTITEM value="2.33"/>
<LISTITEM value="4.55"/>
</ITEMLIST>
<ITEMLIST name="doublelist3" type="double" description="" required="false" advanced="false" >
<LISTITEM value="1.4"/>
</ITEMLIST>
<ITEM name="file_parameter" value="" type="input-file" description="This is a file parameter." required="false" advanced="false" supported_formats="*.mzML,*.mzXML" />
<ITEM name="outdir_parameter" value="" type="output-dir" description="This is a outdir parameter." required="false" advanced="false" />
<ITEM name="advanced_parameter" value="" type="string" description="This is an advanced parameter." required="false" advanced="true" />
<ITEM name="flag" value="false" type="bool" description="This is a flag i.e. in a command line input it does not need a value." required="false" advanced="false" />
<ITEM name="noflagJustTrueFalse" value="true" type="string" description="This is not a flag but has a boolean meaning." required="false" advanced="false" restrictions="true,false" />
</PARAMETERS>
</tool>
4 changes: 3 additions & 1 deletion src/tests/class_tests/openms/source/ParamCTDFile_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ START_SECTION((void writeCTDToStream(std::ostream *os_ptr, const Param &param) c
p.setValue("doublelist3", ListUtils::create<double>("1.4"));
p.setValue("file_parameter", "", "This is a file parameter.");
p.addTag("file_parameter", "input file");
p.setValidStrings("file_parameter", std::vector<std::string>{"*.mzML","*.mzXML"});
p.setValidStrings("file_parameter", std::vector<std::string> {"*.mzML", "*.mzXML"});
p.setValue("outdir_parameter", "", "This is a outdir parameter.");
p.addTag("outdir_parameter", "output dir");
p.setValue("advanced_parameter", "", "This is an advanced parameter.", {"advanced"});
p.setValue("flag", "false", "This is a flag i.e. in a command line input it does not need a value.");
p.setValidStrings("flag",{"true","false"});
Expand Down

0 comments on commit d045489

Please sign in to comment.