@@ -44,8 +44,8 @@ workflow PROTEIN_DESIGN {
4444 // Use flatMap to create individual tasks per PDB file (one per budget iteration)
4545 ch_pdb_per_design = CONVERT_CIF_TO_PDB . out. pdb_files_all
4646 .flatMap { meta, pdb_files ->
47- // Convert to list if single file
48- def pdb_list = pdb_files instanceof List ? pdb_files : [pdb_files]
47+ // Convert to list if single file and create defensive copy
48+ def pdb_list = pdb_files instanceof List ? new ArrayList ( pdb_files) : [pdb_files]
4949
5050 // Create a separate channel entry for each PDB file
5151 pdb_list. collect { pdb_file ->
@@ -93,8 +93,8 @@ workflow PROTEIN_DESIGN {
9393 // Each ProteinMPNN run generates multiple FASTA files (mpnn_num_seq_per_target)
9494 ch_boltz2_per_sequence = PROTEINMPNN_OPTIMIZE . out. sequences
9595 .flatMap { meta, fasta_files ->
96- // Convert to list if single file
97- def fasta_list = fasta_files instanceof List ? fasta_files : [fasta_files]
96+ // Convert to list if single file and create defensive copy
97+ def fasta_list = fasta_files instanceof List ? new ArrayList ( fasta_files) : [fasta_files]
9898
9999 // Create a separate entry for each FASTA file
100100 fasta_list. collect { fasta_file ->
@@ -147,9 +147,9 @@ workflow PROTEIN_DESIGN {
147147 ch_ipsae_boltzgen = BOLTZGEN_RUN . out. budget_design_cifs
148148 .join(BOLTZGEN_RUN . out. budget_design_npz, by : 0 )
149149 .flatMap { meta, cif_files, npz_files ->
150- // Convert to list if single file
151- def cif_list = cif_files instanceof List ? cif_files : [cif_files]
152- def npz_list = npz_files instanceof List ? npz_files : [npz_files]
150+ // Convert to list if single file and create defensive copies
151+ def cif_list = cif_files instanceof List ? new ArrayList ( cif_files) : [cif_files]
152+ def npz_list = npz_files instanceof List ? new ArrayList ( npz_files) : [npz_files]
153153
154154 // Create a map of basenames to files for quick lookup
155155 def npz_map = [:]
@@ -244,8 +244,8 @@ workflow PROTEIN_DESIGN {
244244 // Strategy: Use flatMap to create individual tasks for each CIF file
245245 ch_prodigy_input = BOLTZGEN_RUN . out. budget_design_cifs
246246 .flatMap { meta, cif_files ->
247- // Convert to list if single file
248- def cif_list = cif_files instanceof List ? cif_files : [cif_files]
247+ // Convert to list if single file and create defensive copy
248+ def cif_list = cif_files instanceof List ? new ArrayList ( cif_files) : [cif_files]
249249
250250 // Create a separate entry for each CIF file
251251 cif_list. collect { cif_file ->
@@ -265,8 +265,8 @@ workflow PROTEIN_DESIGN {
265265 if (params. run_proteinmpnn && params. run_boltz2_refold) {
266266 ch_prodigy_boltz2 = BOLTZ2_REFOLD . out. structures
267267 .flatMap { meta, cif_files ->
268- // Convert to list if single file
269- def cif_list = cif_files instanceof List ? cif_files : [cif_files]
268+ // Convert to list if single file and create defensive copy
269+ def cif_list = cif_files instanceof List ? new ArrayList ( cif_files) : [cif_files]
270270
271271 // Create a separate entry for each CIF file
272272 cif_list. collect { cif_file ->
@@ -312,12 +312,13 @@ workflow PROTEIN_DESIGN {
312312 // This searches for homologs of the original Boltzgen-designed structures
313313 ch_foldseek_boltzgen = BOLTZGEN_RUN . out. budget_design_cifs
314314 .flatMap { meta, cif_files ->
315- // Convert to list if single file
316- def cif_list = cif_files instanceof List ? cif_files : [cif_files]
315+ // Convert to list if single file and create defensive copy
316+ def cif_list = cif_files instanceof List ? new ArrayList ( cif_files) : [cif_files]
317317
318318 // Create a separate entry for each CIF file
319319 cif_list. collect { cif_file ->
320320 def base_name = cif_file. baseName
321+ // Create new meta map explicitly to avoid concurrent modification
321322 def design_meta = [
322323 id : " ${ meta.id} _${ base_name} " ,
323324 parent_id : meta. id,
@@ -335,8 +336,8 @@ workflow PROTEIN_DESIGN {
335336 if (params. run_proteinmpnn && params. run_boltz2_refold) {
336337 ch_foldseek_boltz2 = BOLTZ2_REFOLD . out. structures
337338 .flatMap { meta, cif_files ->
338- // Convert to list if single file
339- def cif_list = cif_files instanceof List ? cif_files : [cif_files]
339+ // Convert to list if single file and create defensive copy
340+ def cif_list = cif_files instanceof List ? new ArrayList ( cif_files) : [cif_files]
340341
341342 // Create a separate entry for each CIF file
342343 cif_list. collect { cif_file ->
0 commit comments