Skip to content

Commit

Permalink
Fixed issue with some files not appearing
Browse files Browse the repository at this point in the history
  • Loading branch information
apetkau committed Dec 13, 2023
1 parent f43c17e commit ba7b8f5
Showing 1 changed file with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,29 @@ class IridaNextObserver implements TraceObserver {
return rowsMap
}

private void processOutputPath(Path outputPath, Map<String,String> indexInfo) {
if (publishedFiles.containsKey(outputPath)) {
Path publishedPath = publishedFiles[outputPath]
def currScope = indexInfo["scope"]

if (pathMatchers[currScope].any {it.matches(publishedPath)}) {
iridaNextJSONOutput.addFile(currScope, indexInfo["subscope"], publishedPath)
}
} else {
log.trace "Not match outputPath: ${outputPath}"
}
}

@Override
void onFlowComplete() {
log.info "All publishedPaths: " + publishedFiles.values().collect{it.toString()}.join("\n")
// Generate files section
// Some of this code derived from https://github.com/nextflow-io/nf-prov/blob/master/plugins/nf-prov
tasks.each { task ->
Map<Short,Map<String,String>> outParamInfo = [:]
def currSubscope = null
task.outputs.each { outParam, object ->
log.debug "task ${task}, outParam ${outParam}, object ${object}"
Short paramIndex = outParam.getIndex()
if (!outParamInfo.containsKey(paramIndex)) {
Map<String,String> currIndexInfo = [:]
Expand All @@ -166,25 +181,24 @@ class IridaNextObserver implements TraceObserver {
currIndexInfo["scope"] = "samples"
currIndexInfo["subscope"] = objectMap["id"].toString()
} else {
throw new Exception("Found value channel output that doesn't have meta.id: ${objectMap}")
throw new Exception("Found value channel output in task [${task.getName()}] that doesn't have meta.id: ${objectMap}")
}
} else {
currIndexInfo["scope"] = "global"
currIndexInfo["subscope"] = ""
}
}

Map<String,String> currIndexInfo = outParamInfo[paramIndex]
log.debug "Setup info task [${task.getName()}], outParamInfo[${paramIndex}]: ${outParamInfo[paramIndex]}"
}

if (object instanceof Path) {
Path processPath = (Path)object

if (publishedFiles.containsKey(processPath)) {
Path publishedPath = publishedFiles[processPath]
def currScope = currIndexInfo["scope"]

if (pathMatchers[currScope].any {it.matches(publishedPath)}) {
iridaNextJSONOutput.addFile(currScope, currIndexInfo["subscope"], publishedPath)
log.debug "outParamInfo[${paramIndex}]: ${outParamInfo[paramIndex]}, object as Path: ${object as Path}"
processOutputPath(object as Path, outParamInfo[paramIndex])
} else if (object instanceof List) {
log.debug "outParamInfo[${paramIndex}]: ${outParamInfo[paramIndex]}, object as List: ${object as List}"
(object as List).each {
if (it instanceof Path) {
processOutputPath(it as Path, outParamInfo[paramIndex])
}
}
}
Expand Down

0 comments on commit ba7b8f5

Please sign in to comment.