Skip to content

Commit

Permalink
Remove unnecessary if
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Heringer committed Oct 17, 2023
1 parent dc1c162 commit 49dce5b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
53 changes: 25 additions & 28 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,32 @@ def parse_int(int plain_integer) {
}

def parse_int(String integer_with_suffix) {
def pattern = /^([1-9]\d*[kKmMgGtT]?|0)$/
def parsed_integer
if (integer_with_suffix ==~ pattern) {
if (integer_with_suffix.isInteger()) {
parsed_integer = integer_with_suffix.toInteger()
} else {
def integer_part = integer_with_suffix.substring(0, integer_with_suffix.length() - 1).toInteger()
def suffix_part = integer_with_suffix.substring(integer_with_suffix.length() - 1, integer_with_suffix.length())

switch(suffix_part) {
case "k":
case "K":
parsed_integer = integer_part * 1000
break;
case "m":
case "M":
parsed_integer = integer_part * 1000000
break;
case "g":
case "G":
parsed_integer = integer_part * 1000000000
break;
case "t":
case "T":
parsed_integer = integer_part * 1000000000000
break;
default:
break;
}
if (integer_with_suffix.isInteger()) {
parsed_integer = integer_with_suffix.toInteger()
} else {
def integer_part = integer_with_suffix.substring(0, integer_with_suffix.length() - 1).toInteger()
def suffix_part = integer_with_suffix.substring(integer_with_suffix.length() - 1, integer_with_suffix.length())

switch(suffix_part) {
case "k":
case "K":
parsed_integer = integer_part * 1000
break;
case "m":
case "M":
parsed_integer = integer_part * 1000000
break;
case "g":
case "G":
parsed_integer = integer_part * 1000000000
break;
case "t":
case "T":
parsed_integer = integer_part * 1000000000000
break;
default:
break;
}
}
return parsed_integer
Expand Down
2 changes: 1 addition & 1 deletion nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
},
"seqwish_sparse_factor": {
"type": "number",
"default": 0,
"default": 0.0,
"description": "Keep this randomly selected fraction of input matches."
},
"seqwish_temp_dir": {
Expand Down

0 comments on commit 49dce5b

Please sign in to comment.