Skip to content

Commit

Permalink
Merge branch 'release/0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
schmide committed Jun 19, 2019
2 parents a95e22b + ed3ae0a commit ae51103
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
37 changes: 16 additions & 21 deletions envirest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,36 +836,31 @@ def separateRule(session, simplerule, verify=True, secure=False):
def createPathway(session, packageurl, smiles, name=None,
description=None, verify=True, secure=False):
properties = {'smilesinput': smiles, 'name': name, 'description': description, 'rootOnly': 'true'}
return createEntity(session, packageurl, 'pathway', properties=properties, secure=secure, verify=verify)
return createEntity(session, packageurl, 'pathway', properties=properties, verify=verify, secure=secure)


def predictPathway(session, package_url, root_smiles, settings_url=None, hangon=True, verify=True, secure=False):

headers={"Accept":"application/json"}
url="{0}/pathway".format(package_url)
complete = "true" if hangon else "false"

data={"smilesinput":root_smiles, "selectedSetting":settings_url}
r=session.post(url, data=data, headers=headers, allow_redirects=True, secure=secure, verify=verify)
try:
location=r.json()["id"]
except Exception as ke:
try: print(r.json())
except: pass
raise
data = {
"smilesinput": root_smiles,
"selectedSetting": settings_url
}
pw = createEntity(session, package_url, 'pathway', properties=data, verify=verify, secure=secure)
pwurl = pw["id"]

while complete == "false":
import time
time.sleep(1.0)
r=session.get(location, headers=headers, secure=secure, verify=verify)
while hangon:
try:
complete=r.json()["completed"]
#print(r.json())
if pw["completed"].lower() == "true":
break
except Exception as ke:
from sys import stderr
stderr.write("ERROR: couldnt get completeness ({0}) on {1}\n".format(ke.__class__.__name__, location))
stderr.write("ERROR: couldnt get completeness ({0}) on {1}\n".format(ke.__class__.__name__, pwurl))
break
import time
time.sleep(5.0)
pw = getjson(session, pwurl, verify=verify, secure=secure)

return r.json()
return pw


def addCompoundToPathway(session, pathwayurl, smiles, verify=True, secure=False):
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
setup(name='envipath-api',
version='0.1.1',
description="wrapper for rest calls to envipath",
author='Me and others',
author='Emanuel Schmid',
author_email='[email protected]',
license='MIT',
url='https://github.com/emanuel-schmid/envipath-api',
packages=['envirest'],
install_requires=['argparse', 'requests'],
zip_safe=False)

0 comments on commit ae51103

Please sign in to comment.