Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
*.mzml binary
*.mzxml binary

# Vendor API archives are binary; never normalize line endings (would corrupt them)
*.7z binary

*.sh text eol=lf
1,102 changes: 946 additions & 156 deletions pwiz/data/common/cv.cpp

Large diffs are not rendered by default.

580 changes: 520 additions & 60 deletions pwiz/data/common/cv.hpp

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions pwiz/data/common/cvgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ void writeHpp(const vector<OBO>& obos, const string& basename, const bfs::path&
os << "/// enumeration of controlled vocabulary (CV) terms, generated from OBO file(s)\n"
"enum PWIZ_API_DECL CVID\n{\n"
" CVID_Unknown = -1";
set<string> emittedEnumNames; // track emitted enum names to avoid redefinitions (e.g. synonyms that escape to the same name)
for (vector<OBO>::const_iterator obo=obos.begin(); obo!=obos.end(); ++obo)
for(const Term& term : obo->terms)
{
Expand All @@ -176,14 +177,20 @@ void writeHpp(const vector<OBO>& obos, const string& basename, const bfs::path&
os << ",\n\n"
<< " /// " << term.name << ": " << term.def << "\n"
<< " " << eName << " = " << enumValue(term, enumMultiplierByPrefix[term.prefix]);
emittedEnumNames.insert(eName);

if (term.prefix == "MS") // add synonyms for PSI-MS only
{
for(const string& synonym : term.exactSynonyms)
{
auto synonym_enum_name = enumName(term.prefix, synonym, term.isObsolete);
if (eName == synonym_enum_name) // Should not happen, but just in case
cerr << "Warning: synonym enum name collision for term id " << term.id << ": " << synonym << ": " << eName << endl;
// skip synonyms whose escaped enum name collides with an already-emitted name
// (e.g. a term with both "TOF/TOF" and "TOF-TOF" synonyms both escape to MS_TOF_TOF)
if (!emittedEnumNames.insert(synonym_enum_name).second)
{
cerr << "Warning: skipping duplicate synonym enum name for term id " << term.id << ": " << synonym << ": " << synonym_enum_name << endl;
continue;
}
os << ",\n\n"
<< " /// " << synonym << " (" << term.name << "): " << term.def << "\n"
<< " " << synonym_enum_name << " = " << eName;
Expand Down
2 changes: 1 addition & 1 deletion pwiz/data/common/cvtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void test()

unit_assert(cvTermInfo(MS_None____OBSOLETE).isObsolete);

unit_assert(cvTermInfo(MS_regular_expressions_for_a_GUID).def == "([A-Fa-f0-9]\\{8\\}-([A-Fa-f0-9]\\{4\\}-)\\{3\\}[A-Fa-f0-9]\\{12\\}).");
unit_assert(cvTermInfo(MS_regular_expressions_for_a_GUID).def == "([A-Fa-f0-9]\\\\{8\\\\}-([A-Fa-f0-9]\\\\{4\\\\}-)\\\\{3\\\\}[A-Fa-f0-9]\\\\{12\\\\}).");
}


Expand Down
Loading