From ca4e6a09f1d4ea797e227e818a3058afcb972b5d Mon Sep 17 00:00:00 2001 From: James Krieger Date: Tue, 22 Dec 2020 19:21:56 +0000 Subject: [PATCH 1/5] made self.run not break instantiation --- prody/database/charmmgui.py | 65 ++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/prody/database/charmmgui.py b/prody/database/charmmgui.py index 382ae1f7f..89aa2e32a 100644 --- a/prody/database/charmmgui.py +++ b/prody/database/charmmgui.py @@ -110,13 +110,12 @@ def __init__(self, fname, **kwargs): self.browser_type = kwargs.get('browser_type', None) self.link = None - self.status = False self.saveas = kwargs.get('saveas', 'charmm-gui.tgz') if not isinstance(self.saveas, str): raise TypeError('saveas should be a string') - self.run(**kwargs) + self.isSuccess = self.run(**kwargs) def download(self, browser=None, link=None, saveas=None): """Download CHARMM-GUI files from *link* to *saveas* using *browser*. @@ -238,7 +237,10 @@ def wait_for_text(self, browser=None, text=None, timeout=None, **kwargs): sleep = 180 if sleep_time >= timeout: - raise TimeoutError('wait for %s step timed out' % text) + LOGGER.warn('wait for %s step timed out' % text) + return False + + return True def next_step(self, browser=None, text=None, timeout=None, **kwargs): """Go to next step including waiting for text and checking for errors.""" @@ -252,11 +254,16 @@ def next_step(self, browser=None, text=None, timeout=None, **kwargs): status = True LOGGER.info(" Going to next step") - self.wait_for_text(browser, text, timeout) + status = self.wait_for_text(browser, text, timeout) + if status == False: + return False status, err = self.check_error(browser, **kwargs) if status == False: - raise Exception(err) + LOGGER.warn(err) + return False + + return True def run(self, cwd=None, ndir=None, fname=None, segids=None, job_type=None, saveas=None, timeout=None, browser_type=None, **kwargs): """Main running function that runs all the other steps. Arguments are as in initialization and can overwrite them.""" @@ -300,7 +307,9 @@ def run(self, cwd=None, ndir=None, fname=None, segids=None, job_type=None, savea browser.attach_file('file', "%s/%s/%s" % (cwd, ndir, fname)) browser.find_by_value("PDB").click() - self.next_step(browser, "Manipulate PDB", **kwargs) + status = self.next_step(browser, "Manipulate PDB", **kwargs) + if status == False: + return False for item in browser.find_by_value("1"): item.uncheck() @@ -308,13 +317,19 @@ def run(self, cwd=None, ndir=None, fname=None, segids=None, job_type=None, savea for segid in segids: browser.find_by_name("chains[%s][checked]" % segid.upper()).check() - self.next_step(browser, "Generate PDB", **kwargs) + status = self.next_step(browser, "Generate PDB", **kwargs) + if status == False: + return False if job_type == 'membrane.bilayer': - self.next_step(browser, "Calculate Cross-Sectional Area", **kwargs) + status = self.next_step(browser, "Calculate Cross-Sectional Area", **kwargs) + if status == False: + return False browser.find_by_name("align_option").first.click() - self.next_step(browser, "Determine the System Size", **kwargs) + status = self.next_step(browser, "Determine the System Size", **kwargs) + if status == False: + return False maxes = np.max(self.ag.getCoords(), axis=0) minis = np.min(self.ag.getCoords(), axis=0) @@ -349,40 +364,52 @@ def run(self, cwd=None, ndir=None, fname=None, segids=None, job_type=None, savea unum_popc = browser.find_by_id("lipid_number[upper][popc]").first unum_popc.fill(str(int(unum_popc.value)+1)) else: - raise Exception(browser.find_by_id("error_msg")[0].text) + LOGGER.warn(browser.find_by_id("error_msg")[0].text) + return False browser.find_by_value("Show the system info")[1].click() - self.next_step(browser, "Build Components", max_warn=1) + status = self.next_step(browser, "Build Components", max_warn=1) + if status == False: + return False else: - self.next_step(browser, "Solvate Molecule", **kwargs) + status = self.next_step(browser, "Solvate Molecule", **kwargs) + if status == False: + return False browser.find_option_by_text('NaCl').first.click() browser.find_option_by_text('Monte-Carlo').first.click() self.job_id = browser.find_by_name("jobid")[0].value if job_type == 'membrane.bilayer': - self.next_step(browser, "Assemble Components", **kwargs) + status = self.next_step(browser, "Assemble Components", **kwargs) + if status == False: + return False else: - self.next_step(browser, "Setup Periodic Boundary Condition", **kwargs) + status = self.next_step(browser, "Setup Periodic Boundary Condition", **kwargs) + if status == False: + return False - self.next_step(browser, "Generate Equilibration and Dynamics", **kwargs) + status = self.next_step(browser, "Generate Equilibration and Dynamics", **kwargs) + if status == False: + return False browser.find_by_name("namd_checked").check() - self.next_step(browser, "production.inp", **kwargs) + status = self.next_step(browser, "production.inp", **kwargs) + if status == False: + return False link = self.get_download_link(browser) LOGGER.info("Build success") - status = "Success" + status = True self.browser = browser self.link = link - self.status = status self.download(saveas=saveas) self.browser.quit() - return + return status if __name__ == "__main__": From e1d0ec167ca9e6c669c3280e71bd53086a53a1a2 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 23 Dec 2021 12:51:03 +0000 Subject: [PATCH 2/5] added about selenium --- prody/database/charmmgui.py | 2 +- prody/database/quartataweb.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/prody/database/charmmgui.py b/prody/database/charmmgui.py index 89aa2e32a..f3621c7a9 100644 --- a/prody/database/charmmgui.py +++ b/prody/database/charmmgui.py @@ -4,7 +4,7 @@ Written by CHARMM-GUI team (www.charmm-gui.org) and modified by James Krieger This suite uses the following softwares: -a) python Splinter package (https://splinter.readthedocs.org/en/latest/) +a) python splinter (https://splinter.readthedocs.org/en/latest/) and selenium (https://selenium-python.readthedocs.io/) packages b) a web browser, such as Google Chrome or Mozilla Firefox c) the corresponding driver such as chromedriver (https://sites.google.com/a/chromium.org/chromedriver/downloads) for Chrome or geckodriver (https://github.com/mozilla/geckodriver/releases) for Firefox diff --git a/prody/database/quartataweb.py b/prody/database/quartataweb.py index bb8b836ad..c3d8b04c9 100644 --- a/prody/database/quartataweb.py +++ b/prody/database/quartataweb.py @@ -4,7 +4,7 @@ Based on code written by the CHARMM-GUI team (http://charmm-gui.org) and modified by James Krieger This suite uses the following softwares: -- python Splinter package (https://splinter.readthedocs.org/en/latest/) +- python splinter (https://splinter.readthedocs.org/en/latest/) and selenium (https://selenium-python.readthedocs.io/) packages - a web browser, such as Google Chrome or Mozilla Firefox - the corresponding driver such as chromedriver (https://sites.google.com/a/chromium.org/chromedriver/downloads) for Chrome or geckodriver (https://github.com/mozilla/geckodriver/releases) for Firefox @@ -732,7 +732,7 @@ def initializeBrowser(browser_type, url): from splinter import Browser except ImportError: raise ImportError('Browser module could not be imported. ' - 'install splinter package to solve the problem.') + 'install splinter and selenium packages') else: from selenium.webdriver.common.service import WebDriverException From 41301b2be331104fa3d9b67c228bece92e9cae18 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 23 Dec 2021 12:51:31 +0000 Subject: [PATCH 3/5] charmm-gui run bug fix --- prody/database/charmmgui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prody/database/charmmgui.py b/prody/database/charmmgui.py index f3621c7a9..04772118d 100644 --- a/prody/database/charmmgui.py +++ b/prody/database/charmmgui.py @@ -60,7 +60,7 @@ class CharmmGUIBrowser(object): Default is 0. :type max_warn: int """ - def __init__(self, fname, **kwargs): + def __init__(self, fname=None, **kwargs): if fname is None: raise ValueError('Please enter a starting PDB filename.') if not isinstance(fname, str): From 8cc2bb9c0f8edfcdf3575e0f49a5274d0ca042d8 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 23 Dec 2021 12:51:48 +0000 Subject: [PATCH 4/5] added charmm-gui login --- prody/database/charmmgui.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/prody/database/charmmgui.py b/prody/database/charmmgui.py index 04772118d..54a8dc43f 100644 --- a/prody/database/charmmgui.py +++ b/prody/database/charmmgui.py @@ -303,7 +303,12 @@ def run(self, cwd=None, ndir=None, fname=None, segids=None, job_type=None, savea self.browser_type, self.browser = initializeBrowser(browser_type, url=url) browser = self.browser browser.visit(url) - + + browser.find_by_id('email').first.fill('kriegerj@pitt.edu') # we will have to change this + browser.find_by_id('password').first.fill('ProDy123') + browser.find_by_value("Submit").click() + + browser.visit(url) browser.attach_file('file', "%s/%s/%s" % (cwd, ndir, fname)) browser.find_by_value("PDB").click() From 00fe5f0b836e92e9425cb9ec6348a4abb9ac4ffa Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 23 Dec 2021 16:42:51 +0000 Subject: [PATCH 5/5] added charmmgui to database init --- prody/database/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/prody/database/__init__.py b/prody/database/__init__.py index fb523f789..d7d832731 100644 --- a/prody/database/__init__.py +++ b/prody/database/__init__.py @@ -98,3 +98,7 @@ from . import quartataweb from .quartataweb import * __all__.extend(quartataweb.__all__) + +from . import charmmgui +from .charmmgui import * +__all__.extend(charmmgui.__all__)