\n
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol
\n
\n",
"text/html": [
@@ -156,18 +156,52 @@
""
]
},
- "metadata": {}
+ "metadata": {},
+ "output_type": "display_data"
}
+ ],
+ "source": [
+ "view = py3Dmol.view()\n",
+ "view.addModel(open('/root/PymolFold_workdir/1pga.pdb', 'r').read(),'pdb')\n",
+ "view.setBackgroundColor('white')\n",
+ "view.setStyle({'chain':'A'}, {'cartoon': {'color':'purple'}})\n",
+ "view.zoomTo()\n",
+ "view.show()"
]
},
{
"cell_type": "code",
- "source": [],
+ "execution_count": null,
"metadata": {
"id": "WeyDnykt8Aj1"
},
- "execution_count": null,
- "outputs": []
+ "outputs": [],
+ "source": []
}
- ]
-}
\ No newline at end of file
+ ],
+ "metadata": {
+ "colab": {
+ "authorship_tag": "ABX9TyP3hM2vE4uupz+QGJQ6Q5KK",
+ "include_colab_link": true,
+ "provenance": []
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.8.10"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/pf_plugin.py b/pf_plugin.py
index 36827c1..2259751 100644
--- a/pf_plugin.py
+++ b/pf_plugin.py
@@ -5,8 +5,16 @@
import json
BASE_URL = "http://region-8.seetacloud.com:42711/"
+ESMFOLD_API = "https://api.esmatlas.com/foldSequence/v1/pdb/"
ABS_PATH = os.path.abspath("./")
+def set_workdir(path):
+ global ABS_PATH
+ ABS_PATH = path
+ if ABS_PATH[0] == "~":
+ ABS_PATH = os.path.join(os.path.expanduser("~"), ABS_PATH[2:])
+ print(f"Results will be saved to {ABS_PATH}")
+
def set_base_url(url):
global BASE_URL
BASE_URL = url
@@ -47,7 +55,7 @@ def cal_plddt(pdb_string: str):
return sum(plddts) / len(plddts)
-def query_pymolfold(sequence: str, num_recycle: int = 3, name: str = None):
+def query_pymolfold(sequence: str, name: str = None, num_recycle: int = 3):
num_recycle = int(num_recycle)
data = {
'sequence': sequence,
@@ -93,9 +101,7 @@ def query_esmfold(sequence: str, name: str = None):
"Content-Type": "application/x-www-form-urlencoded",
}
- response = requests.post(
- "https://api.esmatlas.com/foldSequence/v1/pdb/", headers=headers, data=sequence
- )
+ response = requests.post(ESMFOLD_API, headers=headers, data=sequence)
if not name:
name = sequence[:3] + sequence[-3:]
pdb_filename = os.path.join(ABS_PATH, name) + ".pdb"
@@ -142,7 +148,6 @@ def query_mpnn(path_to_pdb: str, fix_pos=None, chain=None, rm_aa=None, inverse=F
response = requests.post(
f"{BASE_URL}mpnn/", headers=headers, files=files, params=params)
- # print(response.content.decode("utf-8"))
res = response.content.decode("utf-8")
d = json.loads(res)
@@ -214,7 +219,7 @@ def query_dms(path_to_pdb: str):
ofile.write('mutation,002,010,020,030,ensemble\n')
for name, s1, s2, s3, s4, s5 in zip(d['mutation'], d['002'], d['010'], d['020'], d['030'], d['ensemble']):
ofile.write(f'{name},{s1},{s2},{s3},{s4},{s5}\n')
- p = os.path.join(os.getcwd(), 'dms_results.csv')
+ p = os.path.join(ABS_PATH, 'dms_results.csv')
print(f"Results save to '{p}'")
@@ -317,3 +322,4 @@ def dms(selection, name='./target_bb.pdb'):
cmd.extend("singlemut", singlemut)
cmd.extend("dms", dms)
cmd.extend("ls_fix", ls_fix)
+cmd.extend("set_workdir", set_workdir)