-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15cbf01
commit 0c3f7cd
Showing
2 changed files
with
65 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,77 @@ | ||
|
||
/* | ||
======================================================================================== | ||
CLASSES | ||
======================================================================================== | ||
*/ | ||
|
||
|
||
/* | ||
======================================================================================== | ||
FUNCTIONS | ||
======================================================================================== | ||
*/ | ||
|
||
// Function to get a valid profile from a ToolProfiles map | ||
/* | ||
String profileStr, | ||
Map<String, ToolProfile> toolProfilesMap | ||
<logger> log | ||
*/ | ||
|
||
// Method to perform AND operation: Perform AND common entries and set the rest to false (interpret absence as false) | ||
public ToolProfile andOperation(ToolProfile other) { | ||
ToolProfile result = new ToolProfile() | ||
Set<String> allTools = this.tool_selection.keySet() + other.tool_selection.keySet() | ||
def getProfileFromToolProfiles(profileStr, toolProfilesMap, log) { | ||
|
||
allTools.each { tool -> | ||
if (this.tool_selection.containsKey(tool) && other.tool_selection.containsKey(tool)) { | ||
result[tool] = this[tool] && other[tool] | ||
} else if (this.tool_selection.containsKey(tool) && !other.tool_selection.containsKey(tool)) { | ||
result[tool] = false | ||
} else if (!this.tool_selection.containsKey(tool) && other.tool_selection.containsKey(tool)) { | ||
result[tool] = false | ||
} | ||
if (!toolProfilesMap) { | ||
toolProfilesMap = SeqinspectorDataClasses.ToolProfiles | ||
} | ||
return result | ||
} | ||
|
||
// Method to perform UnionOR operation: Retain entries that exists in either of the ToolProfile instances, OR for common entries | ||
public ToolProfile orOperation(ToolProfile other) { | ||
ToolProfile result = new ToolProfile() | ||
Set<String> allTools = this.tool_selection.keySet() + other.tool_selection.keySet() | ||
|
||
allTools.each { tool -> | ||
if (this.tool_selection.containsKey(tool) && other.tool_selection.containsKey(tool)) { | ||
result[tool] = this[tool] || other[tool] | ||
} else if (this.tool_selection.containsKey(tool) && !other.tool_selection.containsKey(tool)) { | ||
result[tool] = this[tool] | ||
} else if (!this.tool_selection.containsKey(tool) && other.tool_selection.containsKey(tool)) { | ||
result[tool] = other[tool] | ||
} | ||
if (!toolProfilesMap.containsKey(profileStr.toUpperCase())) { | ||
def keys = toolProfilesMap.keySet().toLowerCase().join('\n - ') | ||
log.error "Invalid profile specified: '${profileStr}'. Valid options are:\n - ${keys}" | ||
nextflow.Nextflow.exit(1) | ||
} | ||
return result | ||
return toolProfilesMap[profileStr] | ||
} | ||
|
||
// Method to perform exclusiveOR (XOR) operation: Retain entries that exists in either of the ToolProfile instances, but not both | ||
public ToolProfile xorOperation(ToolProfile other) { | ||
ToolProfile result = new ToolProfile() | ||
Set<String> allTools = this.tool_selection.keySet() + other.tool_selection.keySet() | ||
|
||
allTools.each { tool -> | ||
if (this.tool_selection.containsKey(tool) && !other.tool_selection.containsKey(tool)) { | ||
result[tool] = this[tool] | ||
} else if (!this.tool_selection.containsKey(tool) && other.tool_selection.containsKey(tool)) { | ||
result[tool] = other[tool] | ||
} else { | ||
result[tool] = false | ||
} | ||
} | ||
return result | ||
} | ||
|
||
// Method to perform inclusiveAND operation: Retain entries that exists in either of the ToolProfile instances, AND conjunction for common entries | ||
public ToolProfile iAndOperation(ToolProfile other) { | ||
ToolProfile result = new ToolProfile() | ||
Set<String> allTools = this.tool_selection.keySet() + other.tool_selection.keySet() | ||
|
||
allTools.each { tool -> | ||
if (this.tool_selection.containsKey(tool) && other.tool_selection.containsKey(tool)) { | ||
result[tool] = this[tool] && other[tool] | ||
} else if (this.tool_selection.containsKey(tool) && !other.tool_selection.containsKey(tool)) { | ||
result[tool] = this[tool] | ||
} else if (!this.tool_selection.containsKey(tool) && other.tool_selection.containsKey(tool)) { | ||
result[tool] = other[tool] | ||
// Function to combine two profiles | ||
/* | ||
String profileStr, | ||
Map<String, ToolProfile> toolProfilesMap | ||
<logger> log | ||
*/ | ||
|
||
def combine_profiles(firstProfile, otherProfile, log) { | ||
|
||
// Create a new ToolProfile instance to store the combined results | ||
def combinedProfile = new SeqinspectorDataClasses.ToolProfile( | ||
enable: (firstProfile.enable + otherProfile.enable), | ||
disable: (firstProfile.disable + otherProfile.disable), | ||
tool_arguments: [:] | ||
) | ||
|
||
// remove possibly disabled tools | ||
combinedProfile.enable.removeAll(combinedProfile.disable) | ||
|
||
|
||
// Combine tool_arguments maps | ||
def allArgs = firstProfile.tool_arguments.keySet() + otherProfile.tool_arguments.keySet() | ||
allArgs.each { tool -> | ||
def firstArgs = firstProfile.tool_arguments[tool] ?: [:] | ||
def otherArgs = otherProfile.tool_arguments[tool] ?: [:] | ||
|
||
// Check for common arguments specified in both profiles for a tool | ||
def commonArgs = firstArgs.keySet().intersect(otherArgs.keySet()) | ||
// if a common setting for a tool is detected, compare the values | ||
if (commonArgs) { | ||
def incompatibleArgs = false | ||
commonArgs.each { arg -> | ||
if(firstArgs[arg] != otherArgs[arg]) { | ||
log.error "Conflicting settings of argument '${arg}' for tool '${tool}'" | ||
incompatibleArgs = true | ||
} | ||
} | ||
if(incompatibleArgs) { | ||
nextflow.Nextflow.exit(1) | ||
} | ||
} | ||
return result | ||
combinedProfile.tool_arguments[tool] = firstArgs + otherArgs | ||
} | ||
|
||
return combinedProfile | ||
|
||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,12 @@ | ||
/* | ||
======================================================================================== | ||
CLASSES | ||
======================================================================================== | ||
*/ | ||
|
||
|
||
enum SeqinspectorTools { | ||
FASTQC, | ||
FASTQSCREEN, | ||
MULTIQC, | ||
// ... | ||
} | ||
|
||
include { getEnumNames } from '../utils_seqinspector_validation/main.nf' | ||
|
||
/* | ||
======================================================================================== | ||
FUNCTIONS | ||
======================================================================================== | ||
*/ | ||
|
||
def getAllToolNames() { | ||
getEnumNames(SeqinspectorDataClasses.Tool) | ||
} |