Mercurial > repos > iuc > swissmodel_modelling_api
annotate sm_api_wrapper.py @ 0:0c3f56c85e98 draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
| author | iuc |
|---|---|
| date | Thu, 11 Dec 2025 19:32:14 +0000 |
| parents | |
| children |
| rev | line source |
|---|---|
|
0
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
1 """Wrapper for the SWISS-MODEL API.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
2 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
3 import argparse |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
4 import json |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
5 import os |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
6 import sys |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
7 import time |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
8 from urllib.parse import urlsplit |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
9 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
10 import requests |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
11 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
12 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
13 class _SmApiWhisperer: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
14 """Parent class for talking to the SWISS-MODEL API.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
15 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
16 PROJECT_TYPE = "" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
17 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
18 def __init__(self, targets, token, project_title="Untitled Project"): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
19 self.project_id = None |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
20 self.project_title = project_title |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
21 self.targets = targets |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
22 self.token = token |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
23 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
24 def get_json_payload(self): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
25 """Needs to be implemented per project type.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
26 raise NotImplementedError |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
27 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
28 def submit_request(self): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
29 """Send off a request to the SM API.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
30 json_payload = self.get_json_payload() |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
31 json_payload["project_title"] = self.project_title |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
32 try: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
33 response = requests.post( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
34 f"https://swissmodel.expasy.org/{self.PROJECT_TYPE}", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
35 headers={"Authorization": f"Token {self.token}"}, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
36 json=json_payload, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
37 timeout=60, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
38 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
39 except requests.exceptions.ConnectTimeout: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
40 print( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
41 "SWISS-MODEL seems to temporarily unavailable", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
42 file=sys.stderr, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
43 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
44 sys.exit(3) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
45 if response.ok is not True: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
46 raise RuntimeError( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
47 f"Submitting modelling job failed ({response.status_code})" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
48 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
49 self.project_id = response.json()["project_id"] |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
50 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
51 return response.status_code |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
52 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
53 def wait(self): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
54 """Poll the API for job to be finished.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
55 response = None |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
56 # Wait at the end, there is a chance that this project is already |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
57 # available from cache. |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
58 while True: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
59 # Update the status from the server |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
60 # response = requests.get( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
61 # f"https://swissmodel.expasy.org/project/{self.project_id}/" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
62 # + "models/summary/", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
63 # headers={"Authorization": f"Token {self.token}"}, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
64 # timeout=360, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
65 # ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
66 response = requests.get( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
67 f"https://swissmodel.expasy.org/project/{self.project_id}/" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
68 + "models/full-details/", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
69 headers={"Authorization": f"Token {self.token}"}, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
70 timeout=360, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
71 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
72 # Update the status |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
73 status = response.json()["status"] |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
74 if status.upper() in ["COMPLETED", "FAILED"]: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
75 break |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
76 # Wait for some time before the next request |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
77 time.sleep(17) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
78 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
79 return response.json() |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
80 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
81 def fetch_results( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
82 self, response_object, output_dir, fetch_modelcif=True, fetch_pdb=True |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
83 ): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
84 """Get results of the modelling job.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
85 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
86 def _store_model_json(model_json, outdir): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
87 fname = f"model_{model_json['model_id']}.json" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
88 with open( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
89 os.path.join(outdir, "JSON", fname), "w", encoding="utf8" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
90 ) as jfh: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
91 json.dump(model_json, jfh) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
92 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
93 def _fetch_file(url, file_type, outdir): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
94 response = requests.get(url, timeout=360) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
95 if response.ok is not True: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
96 raise RuntimeError( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
97 f"Fetching {file_type} output failed (" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
98 + f"{response.status_code})." |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
99 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
100 try: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
101 os.mkdir(os.path.join(outdir, file_type)) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
102 except FileExistsError: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
103 pass |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
104 fname = f"model_{os.path.basename(urlsplit(url).path)}" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
105 with open(os.path.join(outdir, file_type, fname), "wb") as mfh: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
106 for chunk in response.iter_content(chunk_size=8192): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
107 mfh.write(chunk) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
108 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
109 # make sure a JSON directory exists |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
110 os.mkdir(os.path.join(output_dir, "JSON")) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
111 if response_object["status"] == "COMPLETED": |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
112 for model in response_object["models"]: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
113 _store_model_json(model, output_dir) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
114 if fetch_modelcif: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
115 _fetch_file(model["modelcif_url"], "ModelCIF", output_dir) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
116 if fetch_pdb: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
117 _fetch_file(model["coordinates_url"], "PDB", output_dir) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
118 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
119 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
120 class _AutoModelWhisperer(_SmApiWhisperer): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
121 """SM automodel project.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
122 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
123 PROJECT_TYPE = "automodel" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
124 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
125 def get_json_payload(self): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
126 """Payload for automodel mode.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
127 return {"target_sequences": self.targets} |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
128 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
129 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
130 class _AlignmentWhisperer(_SmApiWhisperer): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
131 """SM alignemt project.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
132 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
133 PROJECT_TYPE = "alignment" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
134 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
135 def __init__( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
136 self, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
137 targets, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
138 token, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
139 template_sequence, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
140 template_seqres_offset, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
141 pdb_id, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
142 auth_asym_id, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
143 assembly_id, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
144 project_title="Untitled Project", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
145 ): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
146 # Not sure how to reduce the number of arguments as they are required |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
147 # by the API, so make an exception in Pylint. |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
148 # pylint: disable=too-many-arguments,too-many-positional-arguments |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
149 """Initialise alignment mode, add mode-specific info to the method.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
150 super().__init__(targets, token, project_title=project_title) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
151 self.assembly_id = assembly_id |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
152 self.auth_asym_id = auth_asym_id |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
153 self.pdb_id = pdb_id.lower() |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
154 self.template_seqres_offset = template_seqres_offset |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
155 self.template_sequence = template_sequence |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
156 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
157 def get_json_payload(self): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
158 """Payload for alignment mode.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
159 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
160 return { |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
161 "assembly_id": self.assembly_id, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
162 "auth_asym_id": self.auth_asym_id, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
163 "pdb_id": self.pdb_id, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
164 "target_sequences": self.targets, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
165 "template_seqres_offset": self.template_seqres_offset, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
166 "template_sequence": self.template_sequence, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
167 } |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
168 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
169 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
170 class _UserTemplateWhisperer(_SmApiWhisperer): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
171 """SM user-template project.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
172 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
173 PROJECT_TYPE = "user_template" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
174 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
175 def __init__( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
176 self, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
177 targets, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
178 token, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
179 template_file, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
180 project_title="Untitled Project", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
181 ): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
182 """Initialise user template mode.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
183 super().__init__(targets, token, project_title=project_title) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
184 self.template_file = template_file |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
185 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
186 def get_json_payload(self): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
187 """Payload for user upload mode.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
188 with open(self.template_file, encoding="utf8") as tfh: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
189 template_coordinates = tfh.read() |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
190 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
191 return { |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
192 "project_title": self.project_title, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
193 "target_sequences": self.targets, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
194 "template_coordinates": template_coordinates, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
195 } |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
196 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
197 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
198 def _defastarise_targets(sequences): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
199 """In case some of the targets carry FastA headers, remove them.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
200 targets = [] |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
201 for seq in sequences: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
202 seq = seq.split(" ") |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
203 if len(seq) > 1: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
204 if seq[0].strip().startswith((">", "__gt__")): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
205 targets.append("".join(seq[1:])) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
206 else: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
207 targets.append("".join(seq)) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
208 else: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
209 targets.extend(seq) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
210 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
211 return targets |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
212 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
213 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
214 def _parse_args(): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
215 """Get command line arguments.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
216 parser = argparse.ArgumentParser(description=__doc__) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
217 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
218 parser.add_argument( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
219 "-d", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
220 "--project-title", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
221 help="Title for the modelling project", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
222 metavar="<TITLE>", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
223 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
224 parser.add_argument( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
225 "-m", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
226 "--no-modelcif", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
227 help="Do not download models in ModelCIF format.", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
228 default=False, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
229 action="store_true", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
230 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
231 parser.add_argument( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
232 "-l", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
233 "--fetch-pdb", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
234 help="Download models in PDB legacy format.", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
235 default=False, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
236 action="store_true", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
237 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
238 parser.add_argument( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
239 "-t", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
240 "--template-sequence", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
241 help="The template sequence used for alignment mode", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
242 metavar="<SEQUENCE>", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
243 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
244 # ToDo: do we need the offset from the user? Doesn't interactive alignment |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
245 # mode compute it? |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
246 parser.add_argument( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
247 "-o", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
248 "--template-seqres-offset", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
249 help="Offset of the template sequence segment compared to the full " |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
250 + "template sequence", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
251 metavar="<NUMBER>", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
252 type=int, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
253 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
254 parser.add_argument( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
255 "-p", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
256 "--pdb-id", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
257 help="PDB ID (SMTL ID) for the template used in alignment mode", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
258 metavar="<PDB ID>", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
259 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
260 parser.add_argument( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
261 "-c", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
262 "--auth-asym-id", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
263 help="The chain name to be used in alignment mode", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
264 metavar="<CHAIN NAME>", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
265 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
266 parser.add_argument( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
267 "-a", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
268 "--assembly-id", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
269 help="ID of the assembly of the SMTL template to be used in alignment " |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
270 + "mode", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
271 metavar="<NUMBER>", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
272 type=int, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
273 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
274 parser.add_argument( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
275 "-f", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
276 "--template-file", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
277 help="PDB formatted file to serve as template for modelling", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
278 metavar="<PDB FILE>", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
279 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
280 parser.add_argument( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
281 "project_type", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
282 choices=("alignment", "automodel", "usertemplate"), |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
283 help="Kind of project ('alignmet', 'automodel', 'usertemplate')", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
284 metavar="<PROJECT TYPE>", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
285 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
286 metas = { |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
287 "outdir": "<OUTPUT DIRECTORY>", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
288 "target_sequences": "<SEQUENCE[S]>", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
289 "token": "<TOKEN>", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
290 } |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
291 parser.add_argument( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
292 "token", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
293 help="Authentication token for SWISS-MODEL", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
294 metavar=metas["token"], |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
295 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
296 parser.add_argument( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
297 "outdir", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
298 help="Directory to store results in", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
299 metavar=metas["outdir"], |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
300 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
301 parser.add_argument( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
302 "target_sequences", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
303 help="Target sequence to be modelled; to add multiple sequences, " |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
304 + "delimit with a space", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
305 metavar=metas["target_sequences"], |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
306 nargs=argparse.REMAINDER, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
307 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
308 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
309 opts = parser.parse_args() |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
310 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
311 # Make sure arguments for the different modelling modes are there |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
312 req_opts = { |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
313 "alignment": [ |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
314 "assembly_id", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
315 "auth_asym_id", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
316 "pdb_id", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
317 "template_seqres_offset", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
318 "template_sequence", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
319 ], |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
320 "automodel": [], |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
321 "usertemplate": ["template_file"], |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
322 } |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
323 # check mandatory arguments |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
324 for req in req_opts[opts.project_type]: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
325 value = getattr(opts, req) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
326 if value is None: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
327 print( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
328 f"Option '--{req.replace('_', '-')}' missing for " |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
329 + f"'{opts.project_type}' mode", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
330 file=sys.stderr, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
331 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
332 sys.exit(2) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
333 if isinstance(value, str) and len(value) == 0: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
334 print( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
335 f"Option '--{req.replace('_', '-')}' can not be an empty " |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
336 + "string", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
337 file=sys.stderr, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
338 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
339 sys.exit(2) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
340 # check positional arguments |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
341 for req, mta in metas.items(): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
342 value = getattr(opts, req) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
343 if isinstance(value, str): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
344 if len(value) == 0: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
345 print( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
346 f"Argument of '{mta}' can not be an empty string", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
347 file=sys.stderr, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
348 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
349 sys.exit(2) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
350 elif isinstance(value, list): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
351 if len(value) == 0 or not all(value): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
352 print( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
353 f"Argument of '{mta}' can not be an empty", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
354 file=sys.stderr, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
355 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
356 sys.exit(2) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
357 else: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
358 raise RuntimeError( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
359 f"Value with unknown type '{type(value).__name__}' found for " |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
360 + f"'{mta}'" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
361 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
362 # check optional & positional arguments |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
363 for opt in ["project_title"]: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
364 value = getattr(opts, opt) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
365 if value is not None and len(value) == 0: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
366 print( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
367 f"Option '--{opt.replace('_', '-')}' can not have an empty " |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
368 + "string as value", |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
369 file=sys.stderr, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
370 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
371 sys.exit(2) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
372 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
373 return opts |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
374 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
375 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
376 def _main(): |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
377 """Run as script.""" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
378 opts = _parse_args() |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
379 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
380 target_sequences = _defastarise_targets(opts.target_sequences) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
381 # determine class |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
382 whsprr = None |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
383 if opts.project_type.lower() == "automodel": |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
384 whsprr = _AutoModelWhisperer( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
385 target_sequences, opts.token, project_title=opts.project_title |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
386 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
387 elif opts.project_type.lower() == "alignment": |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
388 template_sequence = _defastarise_targets([opts.template_sequence]) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
389 assert len(template_sequence) == 1 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
390 template_sequence = template_sequence[0] |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
391 whsprr = _AlignmentWhisperer( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
392 target_sequences, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
393 opts.token, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
394 template_sequence, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
395 opts.template_seqres_offset, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
396 opts.pdb_id, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
397 opts.auth_asym_id, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
398 opts.assembly_id, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
399 project_title=opts.project_title, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
400 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
401 elif opts.project_type.lower() == "usertemplate": |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
402 whsprr = _UserTemplateWhisperer( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
403 target_sequences, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
404 opts.token, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
405 opts.template_file, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
406 project_title=opts.project_title, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
407 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
408 else: |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
409 raise RuntimeError( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
410 f"Not a suitable project type: '{opts.project_type}'" |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
411 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
412 # run the modelling job and wait for it to finish |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
413 whsprr.submit_request() |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
414 response = whsprr.wait() |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
415 whsprr.fetch_results( |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
416 response, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
417 opts.outdir, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
418 fetch_modelcif=not opts.no_modelcif, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
419 fetch_pdb=opts.fetch_pdb, |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
420 ) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
421 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
422 sys.exit(0) |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
423 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
424 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
425 if __name__ == "__main__": |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
426 _main() |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
427 |
|
0c3f56c85e98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/main/tools/swissmodel_modelling_api commit 43b5bef8757185b4c077effd0bad846f25d408db
iuc
parents:
diff
changeset
|
428 # LocalWords: Pylint |
