Skip to content

Commit

Permalink
added additional validation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hechth committed Dec 4, 2024
1 parent 0d8ffd5 commit 5a574a1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tools/recetox_aplcms/recetox_aplcms_parse_parameters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@
</edam_topics>

<expression type="ecma5.1"><![CDATA[{
// Expected column names
var expectedColumnNames = [
"min_run",
"sigma_lower",
"sigma_higher",
"min_sd",
"max_sd",
"mz_tol",
"weighting",
"min_pres",
"group_threshold"
];
// Validate column names
var columnNames = $job.row.metadata.column_names;
if (columnNames.length !== expectedColumnNames.length) {
throw new Error("Column count does not match expected count.");
}
for (var i = 0; i < columnNames.length; i++) {
if (columnNames[i] !== expectedColumnNames[i]) {
throw new Error("Column names do not match expected names.");
}
}
// Read the input CSV file
var data = $job.row.contents;
Expand All @@ -31,6 +55,15 @@
for (var i = 0; i < header.length; i++) {
result[header[i]] = row[i];
}
// Validate that the float parameters are valid float values
var floatParams = ["min_run", "sigma_lower", "sigma_higher", "min_sd", "max_sd", "mz_tol", "min_pres", "group_threshold"];
for (var i = 0; i < floatParams.length; i++) {
var param = floatParams[i];
if (isNaN(parseFloat(result[param]))) {
throw new Error("Parameter " + param + " does not contain a valid float value.");
}
}
var weighting;
if (result['weighting'] == 'true') {
Expand Down

0 comments on commit 5a574a1

Please sign in to comment.