Skip to content

Commit

Permalink
Merge pull request #11 from scipion-em/devel
Browse files Browse the repository at this point in the history
release 3.1
  • Loading branch information
azazellochg authored Sep 20, 2023
2 parents 9b64cb2 + 095de4a commit 74ccfd8
Show file tree
Hide file tree
Showing 15 changed files with 227 additions and 143 deletions.
22 changes: 15 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Python compilation files
*.pyc

# Ignore temporary packaging folder
*.egg-info

# IDE files
#### Eclipse and so on
.project
.cproject
.pydevproject
.classpath
.idea

#### Python
build/
dist/
*.egg-info/
*.egg
*.py[cod]
__pycache__/
*.so
*~
8 changes: 5 additions & 3 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
3.0.1
-----
- Installation does not fail but is never complete. So installb modelangelo will git pull all the time.
3.1:
- update installation
- create constants
- add MODEL_ANGELO_CUDA_LIB
3.0.1: Installation does not fail but is never complete. So installb modelangelo will git pull all the time.
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include *.txt
include *.rst
include LICENSE
include LICENSE
include modelangelo/protocols.conf
include modelangelo/logo.jpeg
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ conda activate will not be prepended. For example (loading model-angelo as a mod
MODEL_ANGELO_ACTIVATION = module load model-angelo/main
If you need to use CUDA different from the one used during Scipion installation (defined by *CUDA_LIB*), you can add *MODEL_ANGELO_CUDA_LIB* variable to the config file.

Protocols
---------
Expand Down
70 changes: 29 additions & 41 deletions modelangelo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# *
# * This program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation; either version 2 of the License, or
# * the Free Software Foundation; either version 3 of the License, or
# * (at your option) any later version.
# *
# * This program is distributed in the hope that it will be useful,
Expand All @@ -23,29 +23,18 @@
# * e-mail address '[email protected]'
# *
# **************************************************************************
import datetime
from datetime import datetime as dt
import os

import pwem
import pyworkflow
from pyworkflow.utils import runJob
import pyworkflow.utils as pwutils
from scipion.install.funcs import VOID_TGZ

__version__ = "3.0.3"
_logo = "icon.jpeg"
_references = ['mabioarxive']
from .constants import *

# TODO: move to constants
MA_VERSION = 'git'
# Use this variable to activate an environment from the Scipion conda
MODEL_ANGELO_ENV_ACTIVATION_VAR = "MODEL_ANGELO_ENV_ACTIVATION"
# Use this general activation variable when installed outside Scipion
MODEL_ANGELO_ACTIVATION_VAR = "MODEL_ANGELO_ACTIVATION"

# models
MODELS_VERSION = '0.1'
MODELS_PKG_NAME = 'modelangelomodels'
TORCH_HOME_VAR = 'TORCH_HOME'
__version__ = "3.1"
_logo = "logo.jpeg"
_references = ['jamali2023']


class Plugin(pwem.Plugin):
Expand All @@ -55,9 +44,10 @@ def _defineVariables(cls):
cls._defineVar(MODEL_ANGELO_ACTIVATION_VAR, '')
cls._defineVar(MODEL_ANGELO_ENV_ACTIVATION_VAR, cls.getActivationCmd(MA_VERSION))
cls._defineEmVar(TORCH_HOME_VAR, MODELS_PKG_NAME + "-" + MODELS_VERSION)
cls._defineVar(MODEL_ANGELO_CUDA_LIB, pwem.Config.CUDA_LIB)

@classmethod
def getModelAngeloCmd(cls, *args):
def getModelAngeloCmd(cls):
cmd = cls.getVar(MODEL_ANGELO_ACTIVATION_VAR)
if not cmd:
cmd = cls.getCondaActivationCmd()
Expand All @@ -67,11 +57,15 @@ def getModelAngeloCmd(cls, *args):

@classmethod
def getEnviron(cls):
environ = pyworkflow.utils.Environ(os.environ)
environ = pwutils.Environ(os.environ)
torch_home = cls.getVar(TORCH_HOME_VAR)
# For GPU, we need to add to LD_LIBRARY_PATH the path to Cuda/lib
environ.set(TORCH_HOME_VAR, torch_home)

cudaLib = cls.getVar(MODEL_ANGELO_CUDA_LIB)
environ.addLibrary(cudaLib)

return environ

@classmethod
def getActivationCmd(cls, version):
return'conda activate modelangelo-' + version
Expand All @@ -80,14 +74,13 @@ def getActivationCmd(cls, version):
def defineBinaries(cls, env):

def defineModelAngeloInstallation(version):
installed = "last-pull-%s.txt" % dt.now().strftime("%y%h%d-%H%M%S")

installed = "last-pull-%s.txt" % datetime.datetime.now().strftime("%y%h%d-%H%M%S")

# For modelangelo
modelangelo_commands = []
modelangelo_commands.append(('git clone https://github.com/3dem/model-angelo.git', 'model-angelo'))
modelangelo_commands.append((getCondaInstallation(version), 'env-created.txt'))
modelangelo_commands.append(('cd model-angelo && git pull && touch ../%s' % installed, installed))
modelangelo_commands = [
('git clone https://github.com/3dem/model-angelo.git', 'model-angelo'),
(getCondaInstallation(version), 'env-created.txt'),
('cd model-angelo && git pull && touch ../%s' % installed, installed)
]

env.addPackage('modelangelo', version=version,
commands=modelangelo_commands,
Expand All @@ -96,31 +89,26 @@ def defineModelAngeloInstallation(version):

def getCondaInstallation(version):
installationCmd = cls.getCondaActivationCmd()
installationCmd += 'conda create -y -n modelangelo-' + version + ' python=3.9 && '
installationCmd += 'conda create -y -n modelangelo-' + version + ' python=3.10 && '
installationCmd += cls.getActivationCmd(version) + ' && '
installationCmd += 'cd model-angelo && python -m pip install -r requirements.txt && '
installationCmd += 'conda install -y pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch && '
installationCmd += 'python -m pip install -e . && '
installationCmd += 'conda install -y pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia && '
installationCmd += 'cd model-angelo && pip install -r requirements.txt && '
installationCmd += 'pip install -e . && '
installationCmd += 'touch ../env-created.txt'

return installationCmd

# Define model angelo installations
defineModelAngeloInstallation(MA_VERSION)

# Models download
installationCmd = ""
installationCmd += 'export TORCH_HOME=$PWD && '
installationCmd += cls.getCondaActivationCmd() + " " + cls.getActivationCmd(MA_VERSION) + ' && '
installationCmd += cls.getCondaActivationCmd() + " " + cls.getActivationCmd(MA_VERSION) + ' && '
installationCmd += 'python -m model_angelo.utils.setup_weights --bundle-name original && '
installationCmd += 'python -m model_angelo.utils.setup_weights --bundle-name original_no_seq'


env.addPackage('modelangelomodels', version="0.1",
commands=[(installationCmd,["hub/checkpoints/model_angelo/original_no_seq/success.txt",
"hub/checkpoints/model_angelo/original/success.txt"])],
env.addPackage('modelangelomodels', version=MODELS_VERSION,
commands=[(installationCmd, [f"hub/checkpoints/model_angelo_v{MODELS_VERSION}/original_no_seq/success.txt",
f"hub/checkpoints/model_angelo_v{MODELS_VERSION}/original/success.txt"])],
tar=VOID_TGZ,
default=True)



19 changes: 9 additions & 10 deletions modelangelo/bibtex.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# *
# * This program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation; either version 2 of the License, or
# * the Free Software Foundation; either version 3 of the License, or
# * (at your option) any later version.
# *
# * This program is distributed in the hope that it will be useful,
Expand All @@ -26,15 +26,14 @@
# **************************************************************************

"""
@article{mabioarxive,
doi = "https://doi.org/10.48550/arxiv.2210.00006",
url = "https://arxiv.org/abs/2210.00006",
author = "Jamali, Kiarash and Kimanius, Dari and Scheres, Sjors",
keywords = "Quantitative Methods (q-bio.QM), Artificial Intelligence (cs.AI), Machine Learning (cs.LG), Biomolecules (q-bio.BM), FOS: Biological sciences, FOS: Biological sciences, FOS: Computer and information sciences, FOS: Computer and information sciences",
title = "ModelAngelo: Automated Model Building in Cryo-EM Maps",
publisher = "arXiv",
year = "2022",
copyright = "Creative Commons Attribution 4.0 International"
@article{jamali2023,
author = {Kiarash Jamali and Lukas Kall and Rui Zhang and Alan Brown and Dari Kimanius and Sjors Scheres},
title = {Automated model building and protein identification in cryo-EM maps},
year = {2023},
doi = {https://dx.doi.org/10.1101/2023.05.16.541002},
publisher = {Cold Spring Harbor Laboratory},
URL = {https://www.biorxiv.org/content/early/2023/05/16/2023.05.16.541002},
journal = {bioRxiv}
}
"""
18 changes: 15 additions & 3 deletions modelangelo/wizards/__init__.py → modelangelo/constants.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
# **************************************************************************
# *
# * Authors: Roberto Marabini
# * Authors: Grigory Sharov ([email protected])
# *
# * MRC Laboratory of Molecular Biology (MRC-LMB)
# *
# * This program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation; either version 2 of the License, or
# * the Free Software Foundation; either version 3 of the License, or
# * (at your option) any later version.
# *
# * This program is distributed in the hope that it will be useful,
Expand All @@ -23,3 +23,15 @@
# * e-mail address '[email protected]'
# *
# **************************************************************************

MA_VERSION = 'git'
# Use this variable to activate an environment from the Scipion conda
MODEL_ANGELO_ENV_ACTIVATION_VAR = "MODEL_ANGELO_ENV_ACTIVATION"
# Use this general activation variable when installed outside Scipion
MODEL_ANGELO_ACTIVATION_VAR = "MODEL_ANGELO_ACTIVATION"
MODEL_ANGELO_CUDA_LIB = "MODEL_ANGELO_CUDA_LIB"

# models
MODELS_VERSION = '1.0'
MODELS_PKG_NAME = 'modelangelomodels'
TORCH_HOME_VAR = 'TORCH_HOME'
File renamed without changes
30 changes: 24 additions & 6 deletions modelangelo/protocols/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
# -*- coding: utf-8 -*-
# **************************************************************************
# Module to declare protocols
# Find documentation here: https://scipion-em.github.io/docs/docs/developer/creating-a-protocol
# **************************************************************************
from .protocol_model_angelo import ProtModelAngelo
# ***************************************************************************
# * Authors: Roberto Marabini ([email protected])
# *
# *
# * This program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation; either version 3 of the License, or
# * (at your option) any later version.
# *
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# * GNU General Public License for more details.
# *
# * You should have received a copy of the GNU General Public License
# * along with this program; if not, write to the Free Software
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# * 02111-1307 USA
# *
# * All comments concerning this program package may be sent to the
# * e-mail address '[email protected]'
# ***************************************************************************

from .protocol_model_angelo import ProtModelAngelo
Loading

0 comments on commit 74ccfd8

Please sign in to comment.