| 70 | } |
| 71 | |
| 72 | ExitCodes main_(int, const char**) override |
| 73 | { |
| 74 | String in_file = getStringOption_("in"); |
| 75 | String mapping_file = getStringOption_("mapping_file"); |
| 76 | StringList cv_list = getStringList_("cv"); |
| 77 | |
| 78 | CVMappings mappings; |
| 79 | CVMappingFile().load(mapping_file, mappings, false); |
| 80 | |
| 81 | // Allow definition of the controlled vocabulary files on the commandlines. |
| 82 | // If none are defined, the hardcoded obo files are used |
| 83 | ControlledVocabulary cv; |
| 84 | if (!cv_list.empty()) |
| 85 | { |
| 86 | for (Size i = 0; i < cv_list.size(); i++) |
| 87 | { |
| 88 | // TODO do we need to provide the name of the namespace here? |
| 89 | cv.loadFromOBO("", cv_list[i]); |
| 90 | } |
| 91 | } |
| 92 | else |
| 93 | { |
| 94 | cv.loadFromOBO("PSI-MOD", File::find("/CHEMISTRY/PSI-MOD.obo")); |
| 95 | cv.loadFromOBO("PATO", File::find("/CV/quality.obo")); |
| 96 | cv.loadFromOBO("UO", File::find("/CV/unit.obo")); |
| 97 | cv.loadFromOBO("brenda", File::find("/CV/brenda.obo")); |
| 98 | cv.loadFromOBO("GO", File::find("/CV/goslim_goa.obo")); |
| 99 | cv.loadFromOBO("UNIMOD", File::find("/CV/unimod.obo")); |
| 100 | cv.loadFromOBO("PSI-MS", File::find("/CV/psi-ms.obo")); |
| 101 | } |
| 102 | |
| 103 | // check cv params |
| 104 | Internal::SemanticValidator semantic_validator(mappings, cv); |
| 105 | semantic_validator.setCheckTermValueTypes(true); |
| 106 | semantic_validator.setCheckUnits(true); |
| 107 | |
| 108 | StringList errors, warnings; |
| 109 | |
| 110 | bool valid = semantic_validator.validate(in_file, errors, warnings); |
| 111 | for (Size i = 0; i < warnings.size(); ++i) |
| 112 | { |
| 113 | cout << "Warning: " << warnings[i] << endl; |
| 114 | } |
| 115 | for (Size i = 0; i < errors.size(); ++i) |
| 116 | { |
| 117 | cout << "Error: " << errors[i] << endl; |
| 118 | } |
| 119 | |
| 120 | if (valid && warnings.empty() && errors.empty()) |
| 121 | { |
| 122 | cout << "Congratulations, the file is valid!" << endl; |
| 123 | return EXECUTION_OK; |
| 124 | } |
| 125 | else |
| 126 | { |
| 127 | return PARSE_ERROR; |
| 128 | } |
| 129 |
nothing calls this directly
no test coverage detected