diff --git a/main.nf b/main.nf index e8eae7d..f27e635 100644 --- a/main.nf +++ b/main.nf @@ -79,7 +79,7 @@ workflow WF_WISPS { params.pool, params.pool_size ) - ch_versions = ch_versions.mix(WISPS.out.versions) + ch_versions = ch_versions.mix(WISPS.out.versions) emit: multiqc_report = WISPS.out.multiqc_report @@ -90,9 +90,10 @@ workflow WF_WISPS { msa_json = WISPS.out.msa_json.map{['json': it[1]]} msa_yaml = WISPS.out.msa_yaml.map{['yaml': it[1]]} msa_csv = WISPS.out.msa_csv.map{['csv': it[1]]} + colabfold_predictions = WISPS.out.colabfold_scores .join(WISPS.out.colabfold_pdb) - .map { ['score': params.iptm_threshold > 0 ? new groovy.json.JsonSlurper().parseText(it[1].text).iptm : null, + .map { ['score': params.iptm_threshold > 0 ? new groovy.json.JsonSlurper().parseText(it[1].text).with { (iptm && iptm != 0) ? iptm : ptm } : null, 'pdb': it[2], 'confidence': it[1]] } .filter{params.iptm_threshold == 0 || it.score >= params.iptm_threshold} @@ -103,14 +104,14 @@ workflow WF_WISPS { .map { ['confidence': it[3], 'cif': it[2], 'pae': it[1], - 'score': params.iptm_threshold > 0 ? new groovy.json.JsonSlurper().parseText(it[3].text).iptm : null] } + 'score': params.iptm_threshold > 0 ? new groovy.json.JsonSlurper().parseText(it[3].text).with { (iptm && iptm != 0) ? iptm : ptm } : null] } .filter{params.iptm_threshold == 0 || it.score >= params.iptm_threshold} af3_predictions = WISPS.out.alphafold3_confidence .join(WISPS.out.alphafold3_cif) .map { ['confidence': it[1], 'cif': it[2], - 'score': params.iptm_threshold > 0 ? new groovy.json.JsonSlurper().parseText(it[1].text).iptm : null] } + 'score': params.iptm_threshold > 0 ? new groovy.json.JsonSlurper().parseText(it[1].text).with { (iptm && iptm != 0) ? iptm : ptm } : null] } .filter{params.iptm_threshold == 0 || it.score >= params.iptm_threshold} } /* @@ -149,7 +150,6 @@ workflow { params.hook_url, WF_WISPS.out.multiqc_report ) - publish: colabfold_predictions = WF_WISPS.out.colabfold_predictions boltz_predictions = WF_WISPS.out.boltz_predictions @@ -161,7 +161,7 @@ workflow { msa_json = WF_WISPS.out.msa_json.ifEmpty([]) msa_yaml = WF_WISPS.out.msa_yaml.ifEmpty([]) msa_csv = WF_WISPS.out.msa_csv.ifEmpty([]) - + } output { @@ -212,6 +212,7 @@ output { } + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ THE END diff --git a/workflows/wisps.nf b/workflows/wisps.nf index 5ae2771..b79ce9a 100644 --- a/workflows/wisps.nf +++ b/workflows/wisps.nf @@ -83,7 +83,7 @@ workflow WISPS { main: ch_multiqc_files = Channel.empty() ch_confidence_scores = Channel.empty() - + use_interaction_pools = (pool instanceof Boolean) ? pool : pool.toString().toBoolean() interaction_mode = mode.split(",").collect { pair -> pair.split('-').sort().join('-') @@ -223,12 +223,12 @@ workflow WISPS { ch_interaction_raw = ch_samplesheet .map { it[1] } .filter { it.extension == "fasta" || it.extension == "fa" } - .ifEmpty { error("Manual mode requires at least one FASTA file in the samplesheet sequence column.") } + .ifEmpty { error("Manual mode requires at least one FASTA file in the samplesheet sequence column-Z.") } .collectFile(name: "manual_interactions.fasta", newLine: false) { fasta_file -> ["manual_interactions.fasta", fasta_file.text.trim() + "\n"] } } - + ch_interaction_has_protein = ch_interaction_raw.flatMap { interactions_fasta -> def out = [] def lines = interactions_fasta.readLines().findAll { it?.trim() } @@ -581,6 +581,7 @@ workflow WISPS { .map { [it[0].id, it[0]] } .groupTuple() .map { inputId, metas -> [inputId, metas] } + ch_long = Channel.empty() if ('boltz' in active_modes) @@ -589,8 +590,9 @@ workflow WISPS { ch_long = ch_long.mix(ch_ipsae_out.colabfold.flatMap { id, entries -> entries.collect { e -> [id, e[0], 'colabfold', e[1]] } }) if ('alphafold3' in active_modes) ch_long = ch_long.mix(ch_ipsae_out.alphafold3.flatMap { id, entries -> entries.collect { e -> [id, e[0], 'alphafold3', e[1]] } }) + ch_long = ch_long - .join(ch_report_meta_grouped_by_input_id, remainder: true) + .join(ch_report_meta_grouped_by_input_id, remainder: false) .flatMap { inputId, pairId, model, score, metaList -> def metas = (metaList instanceof List && !metaList.isEmpty()) ? metaList @@ -600,7 +602,8 @@ workflow WISPS { [reportId, pairId, model, score] } } - + + // 2) Pivot per pair: [pair_id, sampleModelScoreMap] ch_pair_wide = ch_long .map { sampleId, pairId, model, score -> [pairId, [sampleId, model, score]] } @@ -612,7 +615,9 @@ workflow WISPS { } [pairId, bySample] } - + + + //ch_pair_wide.view() // 3) Create one CSV per pair with model-only headers ch_interaction_in.map { it[0].report_id }.unique().toSortedList().map { [sample_ids: it] } .combine(ch_pair_wide.collect(flat: false).map { [pairs: it] })