diff --git "a/output_helpers.py" "b/output_helpers.py" new file mode 100644--- /dev/null +++ "b/output_helpers.py" @@ -0,0 +1,1566 @@ + +import json +import os + +local_url = "http://localhost:8888/frontend/" +remote_url = "https://cdn.jsdelivr.net/gh/duerrsimon/vue_3dmol_gradio@latest/" + + +if os.environ.get("GRADIO_LOCAL") is not None: + url = local_url +else: + url = remote_url + +def viewer_html(path_to_file, name="input", selectionStyle={"color": "greenCarbon", + "representation": "cartoon", + "multiple": True}, representations={}): + + ext = path_to_file.split(".")[-1] + with open(path_to_file, "r") as f: + data = f.read() + moldata = {"moldata": [{"data": data, "name": name, "selectionStyle": selectionStyle,"format": ext, + "selectable": True, + "asFrames":False, + "clickable": False}] + } + # dict to json + moldata = json.dumps(moldata) + representations = json.dumps(representations) + + return """ + + + +
+ + + + + +