Skip to content

Commit

Permalink
Merge branch 'main' of github.com:BSC-CNS-EAPM/EAPM-plugins into main
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertCS committed Jun 5, 2024
2 parents 67518b0 + c2f33cc commit d353a49
Show file tree
Hide file tree
Showing 36 changed files with 1,499 additions and 270 deletions.
20 changes: 20 additions & 0 deletions EAPM/EAPM.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ def createPlugin():

eapmPlugin.addBlock(ahatoolBlock)

from Blocks.EpPred import epPredBlock # type: ignore

eapmPlugin.addBlock(epPredBlock)

# from Blocks.testBlock import testBlock # type: ignore

# eapmPlugin.addBlock(testBlock)

from Blocks.AnalyseGlide import AnalyseGBlock # type: ignore

eapmPlugin.addBlock(AnalyseGBlock)

# from Blocks.Rbcavity import rbCavityBlock # type: ignore

# eapmPlugin.addBlock(rbCavityBlock)

# from Blocks.Rbdock import rbDockBlock # type: ignore

# eapmPlugin.addBlock(rbDockBlock)

# Add the configs
from Configs.mafftConfig import mafftExecutableConfig # type: ignore

Expand Down
19 changes: 14 additions & 5 deletions EAPM/Include/Blocks/Ahatool.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import datetime
import os
import subprocess

from HorusAPI import PluginBlock, PluginVariable, VariableList, VariableTypes

# TODO Add to the documentation

# ==========================#
# Variable inputs
# ==========================#
Expand Down Expand Up @@ -44,6 +42,13 @@
##############################
# Other variables #
##############################
removeExistingResults = PluginVariable(
name="Remove existing results",
id="remove_existing_results",
description="Remove existing results",
type=VariableTypes.BOOLEAN,
defaultValue=False,
)
prefixVar = PluginVariable(
name="Prefix",
id="prefix",
Expand Down Expand Up @@ -76,6 +81,10 @@

def initialAction(block: PluginBlock):

import datetime
import os
import subprocess

container_name = block.inputs.get("container_name", "bsceapm/ahatool:2.2")
input_fasta = block.inputs.get("input_fasta", None)
fasta = os.path.basename(input_fasta)
Expand Down Expand Up @@ -145,6 +154,6 @@ def initialAction(block: PluginBlock):
action=initialAction,
description="Iteratively search a protein sequence against a protein database",
inputs=[inputFasta, dbPath, containerName],
variables=[prefixVar, startVar, evalVar, threadsVar],
variables=[removeExistingResults, prefixVar, startVar, evalVar, threadsVar],
outputs=[outputAhatool],
)
23 changes: 11 additions & 12 deletions EAPM/Include/Blocks/AlignPdbEAPM.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
type=VariableTypes.INTEGER,
defaultValue=0,
)

chainIndexesAlign = VariableList(
name="Chain indexes",
id="chain_indexes",
Expand All @@ -63,15 +62,12 @@
type=VariableTypes.INTEGER,
defaultValue=0,
)

trajectoryChainIndexesAlign = VariableList(
name="Trajectory chain indexes",
id="trajectory_chain_indexes",
description="Chain indexes of the target trajectories to use in the alignment.",
prototypes=[trajectoryChainIndexVariable],
)


alignmentModeAlign = PluginVariable(
name="Alignment mode",
id="alignment_mode",
Expand All @@ -80,7 +76,6 @@
defaultValue="aligned",
allowedValues=["aligned", "exact"],
)

referenceResiduesAlign = PluginVariable(
name="Reference residue index",
id="reference_residues",
Expand Down Expand Up @@ -129,26 +124,30 @@ def initialAlign(block: PluginBlock):
alignmentMode = block.variables.get("alignment_mode", "aligned")
referenceResidues = block.variables.get("reference_residues", [])

import prepare_proteins

print("Loading PDB files...")

models = prepare_proteins.proteinModels(inputFolder)

# Parse the chain indexes
if chainIndexes is not None:
chainIndexes = [x["chain_index"] for x in chainIndexes]
else:
chainIndexes = [0]

trajectory_chain_indexes = None
# Parse the trajectory chain indexes
if trajectoryChainIndexes is not None:
trajectoryChainIndexes = [x["trajectory_chain_index"] for x in trajectoryChainIndexes]
trajectory_chain_indexes = {}
for i, model in enumerate(models.models_names):
trajectory_chain_indexes[model] = trajectoryChainIndexes[i]

# Parse the reference residues
if referenceResidues is not None:
referenceResidues = [x["reference_residues"] for x in referenceResidues]

import prepare_proteins

print("Loading PDB files...")

models = prepare_proteins.proteinModels(inputFolder)

print("Aligning models...")

import subprocess
Expand All @@ -168,7 +167,7 @@ def hookSubprocessMafft(command, **kwargs):
pdbReference,
outputFolder,
chain_indexes=chainIndexes,
trajectory_chain_indexes=trajectoryChainIndexes,
trajectory_chain_indexes=trajectory_chain_indexes,
aligment_mode=alignmentMode,
reference_residues=referenceResidues,
verbose=True,
Expand Down
23 changes: 17 additions & 6 deletions EAPM/Include/Blocks/AlphaFoldEAPM.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Module containing the AlphaFold block for the EAPM plugin
"""

import os

from HorusAPI import PluginVariable, SlurmBlock, VariableTypes

# ==========================#
Expand All @@ -28,7 +26,6 @@
type=VariableTypes.STRING,
defaultValue="alphafold",
)

removeExistingResults = PluginVariable(
name="Remove existing results",
id="remove_existing_results",
Expand Down Expand Up @@ -63,13 +60,25 @@ def initialAlphafold(block: SlurmBlock):
folderName = block.variables.get("folder_name", "alphafold")
removeExisting = block.variables.get("remove_existing_results", False)

cpus_per_task = block.variables.get("cpus_per_task")
if cpus_per_task is 1:
print("Alphafold requires at least 20 cpus per task. Changing to 20 cpus per task.")
block.variables["cpus_per_task"] = 20

partiton = block.variables.get("partition")
if partiton is None:
print("Alphafold requires an accelerated partition. Changing to acc_bscls.")
block.variables["partition"] = "acc_bscls"

import os

# If folder already exists, raise exception
if removeExisting and os.path.exists(folderName):
os.system("rm -rf " + folderName)

if not removeExisting and os.path.exists(folderName):
raise Exception(
"The folder {} already exists. Please, choose another name or remove it.".format(
"The folder {} already exists. Please, choose another name or remove it with the remove existing folder option.".format(
folderName
)
)
Expand All @@ -88,7 +97,7 @@ def initialAlphafold(block: SlurmBlock):

from utils import launchCalculationAction

launchCalculationAction(block, jobs, folderName)
launchCalculationAction(block, jobs, "alphafold", [folderName])


def finalAlhafoldAction(block: SlurmBlock):
Expand All @@ -98,6 +107,8 @@ def finalAlhafoldAction(block: SlurmBlock):

resultsFolder = block.extraData["folder_name"]

import os

output_models_folder = os.path.join(downloaded_path, resultsFolder, "output_models")

block.setOutput(outputModelsVariable.id, output_models_folder)
Expand All @@ -107,7 +118,7 @@ def finalAlhafoldAction(block: SlurmBlock):

alphafoldBlock = SlurmBlock(
name="Alphafold",
description="Run Alphafold. (For cte_power, marenostrum, nord3 and minotauro clusters or local)",
description="Run Alphafold. (For marenostrum, nord3 clusters or local)",
initialAction=initialAlphafold,
finalAction=finalAlhafoldAction,
variables=BSC_JOB_VARIABLES + [outputAF, removeExistingResults],
Expand Down
Loading

0 comments on commit d353a49

Please sign in to comment.