Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 49 additions & 3 deletions conf/modules_alphafold3.config
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,55 @@ process {
withName: 'RUN_ALPHAFOLD3' {
accelerator = params.use_gpu? 1 : 0
publishDir = [
path: { "${params.outdir}/alphafold3" },
mode: 'copy',
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
[
path: { "${params.outdir}/alphafold3/${meta.id}" },
mode: 'copy',
pattern: '*_plddt.tsv'
],
[
path: { "${params.outdir}/alphafold3/${meta.id}" },
mode: 'copy',
pattern: '*_ptm.tsv'
],
[
path: { "${params.outdir}/alphafold3/${meta.id}" },
mode: 'copy',
pattern: '*_iptm.tsv'
],
[
path: { "${params.outdir}/alphafold3/${meta.id}" },
mode: 'copy',
saveAs: { filename -> "paes/$filename" },
pattern: '*_pae.tsv'
],
[
path: { "${params.outdir}/alphafold3/${meta.id}" },
mode: 'copy',
pattern: '*_alphafold3_msa.tsv'
],
[
enabled: params.save_intermediates,
path: { "${params.outdir}/alphafold3/${meta.id}/raw" },
mode: 'copy',
pattern: 'raw/**',
saveAs: { filename -> filename.toString().replaceFirst(/^raw\//, '') }
],
[
path: { "${params.outdir}/alphafold3/top_ranked_structures" },
mode: 'copy',
saveAs: { "${meta.id}.cif" },
pattern: '*_alphafold3.cif'
]
]
}
withName: 'MMCIF2PDB_TOP_RANKED' {
publishDir = [
[
path: { "${params.outdir}/alphafold3/top_ranked_structures" },
mode: 'copy',
saveAs: { "${meta.id}.pdb" },
pattern: '*.pdb'
]
]
}
}
2 changes: 1 addition & 1 deletion modules/local/mmcif2pdb/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ process MMCIF2PDB {
"""
for mmcif in *.cif
do
pdb_out=\$(basename "\$mmcif")
pdb_out=\$(basename "\$mmcif" .cif)
mmcif_to_pdb.py \${mmcif} --pdb_out "\${pdb_out}.pdb"
done

Expand Down
93 changes: 49 additions & 44 deletions modules/local/run_alphafold3/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Run Alphafold3
*/
process RUN_ALPHAFOLD3 {

Comment thread
JoseEspinosa marked this conversation as resolved.
Outdated
tag "$meta.id"
label 'process_medium'
label 'process_gpu'
Expand All @@ -18,11 +19,14 @@ process RUN_ALPHAFOLD3 {
path "uniprot/*"

output:
tuple val(meta), path ("publish/*alphafold3.cif") , emit: top_ranked_cif
tuple val(meta), path ("publish/*ranked_*.cif") , emit: cif
path ("raw/**") , emit: raw
tuple val(meta), path ("${meta.id}_alphafold3.cif") , emit: top_ranked_cif
tuple val(meta), path ("raw/*ranked_*.cif") , emit: cif
tuple val(meta), path ("${meta.id}_plddt.tsv") , emit: multiqc
tuple val(meta), path ("${meta.id}_alphafold3_msa.tsv") , emit: msa
Comment thread
vagkaratzas marked this conversation as resolved.
tuple val(meta), path ("${meta.id}_0_pae.tsv") , emit: pae
tuple val(meta), path ("${meta.id}_ptm.tsv") , emit: ptms
tuple val(meta), path ("${meta.id}_iptm.tsv") , optional: true, emit: iptms
path "versions.yml" , emit: versions

when:
Expand All @@ -38,33 +42,30 @@ process RUN_ALPHAFOLD3 {
def prefix = task.ext.prefix ?: "${meta.id}"
def af3_id = meta.id.toLowerCase()
"""
for f in ./pdb_seqres/pdb_seqres.txt ./pdb_seqres/pdb_seqres_2022_09_28.fasta; do
if [[ -f \$f ]]; then
pdb_seqres=\$f
break
fi
done
# Check database files exist and set variables
pdb_seqres=\$(ls -v ./pdb_seqres/pdb_seqres.txt ./pdb_seqres/pdb_seqres_2022_09_28.fasta 2>/dev/null | tail -n 1 || echo "")
if [[ -z "\$pdb_seqres" ]]; then
echo "ERROR: No pdb_seqres file found"
exit 1
fi

for f in ./uniref90/uniref90*.fa ./uniref90/uniref90*.fasta; do
if [[ -f \$f ]]; then
uniref90=\$f
break
fi
done
uniref90=\$(ls -v ./uniref90/uniref90*.fa ./uniref90/uniref90*.fasta 2>/dev/null | tail -n 1 || echo "")
if [[ -z "\$uniref90" ]]; then
echo "ERROR: No uniref90 file found"
exit 1
fi

for f in ./mgnify/mgy_clusters*.fa ./mgnify/mgnify_clusters*.fasta; do
if [[ -f \$f ]]; then
mgnify=\$f
break
fi
done
mgnify=\$(ls -v ./mgnify/mgy_clusters*.fa ./mgnify/mgnify_clusters*.fasta 2>/dev/null | tail -n 1 || echo "")
if [[ -z "\$mgnify" ]]; then
echo "ERROR: No mgnify file found"
exit 1
fi

for f in ./uniprot/uniprot.fasta ./uniprot/uniprot*.fa; do
if [[ -f \$f ]]; then
uniprot=\$f
break
fi
done
uniprot=\$(ls -v ./uniprot/uniprot.fasta ./uniprot/uniprot*.fa 2>/dev/null | tail -n 1 || echo "")
if [[ -z "\$uniprot" ]]; then
echo "ERROR: No uniprot file found"
exit 1
fi

python3 /app/alphafold/run_alphafold.py \\
--json_path=${json} \\
Expand All @@ -78,32 +79,34 @@ process RUN_ALPHAFOLD3 {
--output_dir=\$PWD \\
$args

## Rename the top ranked model
if [ ! -d publish ]; then
mkdir -p publish
fi

## Move the rest of the models and rename them according to their rank
### Move the rest of the models and rename them according to their rank
name=\$(jq -r '.name' ${json})
cp -n "\${name}/\${name}_model.cif" "publish/${prefix}_alphafold3.cif"

## Copy top ranked model to root
cp -n "\${name}/\${name}_model.cif" "${prefix}_alphafold3.cif"
Comment thread
vagkaratzas marked this conversation as resolved.

## Sort the rows by ranking_score in descending order
sorted_csv=\$(head -n 1 "\${name}/ranking_scores.csv"; tail -n +2 "\${name}/ranking_scores.csv" | sort -t, -k3 -nr)
rank=0
touch publish/combined_plddt_mqc.tsv

## Generate files with rank tag
## Create raw directory for intermediate files
mkdir -p raw

## Generate files with rank tag in raw directory
echo "\$sorted_csv" | tail -n +2 | while IFS=',' read -r seed sample ranking_score; do
cp -n "\${name}/seed-\${seed}_sample-\${sample}/model.cif" "publish/seed_\${seed}_sample_\${sample}_ranked_\${rank}.cif"
cp -n "\${name}/seed-\${seed}_sample-\${sample}/model.cif" "raw/seed_\${seed}_sample_\${sample}_ranked_\${rank}.cif"
rank=\$((rank + 1))
done

extract_metrics.py --name ${prefix} \\
--jsons ${af3_id}/${af3_id}_data.json ${af3_id}/${af3_id}_summary_confidences.json ${af3_id}/${af3_id}_confidences.json \\
--structs publish/*ranked_*.cif
--structs raw/*ranked_*.cif

mv "${prefix}_msa.tsv" "${meta.id}_alphafold3_msa.tsv"

## Move alphafold3 output directory to raw for save_intermediates
mv \${name}/* raw/

cat <<-END_VERSIONS > versions.yml
"${task.process}":
python: \$(python3 --version | sed 's/Python //g')
Expand All @@ -113,16 +116,18 @@ process RUN_ALPHAFOLD3 {
stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
mkdir publish
touch publish/${prefix}_alphafold3.cif
touch publish/${prefix}_ranked_1.cif
touch publish/${prefix}_ranked_2.cif
touch publish/${prefix}_ranked_3.cif
touch publish/${prefix}_ranked_4.cif
touch publish/${prefix}_ranked_5.cif
mkdir -p raw
touch ${prefix}_alphafold3.cif
touch raw/${prefix}_ranked_1.cif
touch raw/${prefix}_ranked_2.cif
touch raw/${prefix}_ranked_3.cif
touch raw/${prefix}_ranked_4.cif
touch raw/${prefix}_ranked_5.cif
touch ${prefix}_plddt.tsv
touch ${prefix}_alphafold3_msa.tsv
touch ${prefix}_0_pae.tsv
touch ${prefix}_ptm.tsv
touch ${prefix}_iptm.tsv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
20 changes: 8 additions & 12 deletions tests/alphafold2_download.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,14 @@
"alphafold2/standard/top_ranked_structures",
"alphafold2/standard/top_ranked_structures/T1024.pdb",
"alphafold2/standard/top_ranked_structures/T1026.pdb",
"generate",
"generate/test_LDDT.html",
"generate/test_alphafold2_report.html",
"generate/test_seq_coverage.png",
"multiqc",
"multiqc/alphafold2_multiqc_data",
"multiqc/alphafold2_multiqc_plots",
"multiqc/alphafold2_multiqc_report.html",
"pipeline_info",
"pipeline_info/nf_core_proteinfold_software_mqc_versions.yml"
"pipeline_info/nf_core_proteinfold_software_mqc_versions.yml",
"reports",
"reports/test_alphafold2_report.html"
],
[
"bfd-first_non_consensus_sequences.fasta:md5,d41d8cd98f00b204e9800998ecf8427e",
Expand Down Expand Up @@ -107,16 +105,14 @@
"T1026_0_pae.tsv:md5,d41d8cd98f00b204e9800998ecf8427e",
"T1024.pdb:md5,d41d8cd98f00b204e9800998ecf8427e",
"T1026.pdb:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_LDDT.html:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_alphafold2_report.html:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_seq_coverage.png:md5,d41d8cd98f00b204e9800998ecf8427e",
"alphafold2_multiqc_report.html:md5,d41d8cd98f00b204e9800998ecf8427e"
"alphafold2_multiqc_report.html:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_alphafold2_report.html:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "25.10.3"
"nf-test": "0.9.3",
"nextflow": "25.10.4"
},
"timestamp": "2026-01-29T21:35:56.027817716"
"timestamp": "2026-02-12T10:46:14.365206"
}
}
20 changes: 8 additions & 12 deletions tests/alphafold2_split.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,14 @@
"alphafold2/split_msa_prediction/top_ranked_structures",
"alphafold2/split_msa_prediction/top_ranked_structures/T1024.pdb",
"alphafold2/split_msa_prediction/top_ranked_structures/T1026.pdb",
"generate",
"generate/test_LDDT.html",
"generate/test_alphafold2_report.html",
"generate/test_seq_coverage.png",
"multiqc",
"multiqc/alphafold2_multiqc_data",
"multiqc/alphafold2_multiqc_plots",
"multiqc/alphafold2_multiqc_report.html",
"pipeline_info",
"pipeline_info/nf_core_proteinfold_software_mqc_versions.yml"
"pipeline_info/nf_core_proteinfold_software_mqc_versions.yml",
"reports",
"reports/test_alphafold2_report.html"
],
[
"T1024_alphafold2_msa.tsv:md5,d41d8cd98f00b204e9800998ecf8427e",
Expand All @@ -67,16 +65,14 @@
"T1026_0_pae.tsv:md5,d41d8cd98f00b204e9800998ecf8427e",
"T1024.pdb:md5,d41d8cd98f00b204e9800998ecf8427e",
"T1026.pdb:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_LDDT.html:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_alphafold2_report.html:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_seq_coverage.png:md5,d41d8cd98f00b204e9800998ecf8427e",
"alphafold2_multiqc_report.html:md5,d41d8cd98f00b204e9800998ecf8427e"
"alphafold2_multiqc_report.html:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_alphafold2_report.html:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "25.10.3"
"nf-test": "0.9.3",
"nextflow": "25.10.4"
},
"timestamp": "2026-01-29T21:36:12.286799433"
"timestamp": "2026-02-12T10:47:42.40387"
}
}
Loading