Skip to content

Commit

Permalink
move the database part from analysis service and submit service.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zimiao1025 committed Mar 12, 2024
1 parent d627484 commit 03a4be9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 51 deletions.
2 changes: 1 addition & 1 deletion gui/stats.html

Large diffs are not rendered by default.

30 changes: 16 additions & 14 deletions services/analysis/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import numpy as np
import Bio.PDB
from scipy.special import softmax
from loguru import logger

from lib.base import BaseRunner
from lib.state import State
Expand Down Expand Up @@ -274,6 +275,7 @@ def run(self):
ptree = get_pathtree(request=self.requests[0])
num_res = len(self.requests[0]["sequence"])
dirname = str(ptree.alphafold.root)
logger.info(f"Analysis dirname: {dirname}")
self.rerank_relaxed_plddts(dirname=dirname)
self.parse_save_plddt_from_dir(dirname=dirname)
self.get_conformation_from_dir(dirname=dirname)
Expand All @@ -282,22 +284,22 @@ def run(self):
file_pattern="model_*_output_raw.pkl",
num_res=num_res,
)
model2plddts, model2pdbpaths = self.get_plddts_from_dir(
model2plddts, _ = self.get_plddts_from_dir(
dirname=dirname, pdb_pattern="rank_*.pdb"
)
template_infos = self.get_template_info_from_ptree(ptree)
self.info_reportor.update_reserved(
hash_id=self.requests[0][info_report.HASH_ID], update_dict=template_infos
)
self.info_reportor.update_metric(
hash_id=self.requests[0][info_report.HASH_ID],
value=model2plddts,
metric="plddt",
)

self.info_reportor.update_path_tree(
hash_id=self.requests[0][info_report.HASH_ID], path_tree=ptree.tree
)
# template_infos = self.get_template_info_from_ptree(ptree)
# self.info_reportor.update_reserved(
# hash_id=self.requests[0][info_report.HASH_ID], update_dict=template_infos
# )
# self.info_reportor.update_metric(
# hash_id=self.requests[0][info_report.HASH_ID],
# value=model2plddts,
# metric="plddt",
# )

# self.info_reportor.update_path_tree(
# hash_id=self.requests[0][info_report.HASH_ID], path_tree=ptree.tree
# )
result_path = os.path.join(dirname, "plddt_results.json")
dtool.write_json(result_path, data=model2plddts)
return str(result_path)
72 changes: 36 additions & 36 deletions services/submit/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ def calculate_plddt_from_peb(pdb_path):
plddt = np.mean(prot.b_factors[:, 0])
return plddt

def run(self, dry=False, *args, **kwargs):
def run(self, dry=False):
for _request in self.requests:
if not _request.get("submit", True):
if self.info_reportor is not None:
self.info_reportor.update_state(
hash_id=_request[info_report.HASH_ID],
state=State.SUBMIT_SKIP,
)
continue
# if not _request.get("submit", True):
# if self.info_reportor is not None:
# self.info_reportor.update_state(
# hash_id=_request[info_report.HASH_ID],
# state=State.SUBMIT_SKIP,
# )
# continue
with smtplib.SMTP(self.smtp_ssl_host, self.smtp_ssl_port) as server:
server.ehlo()
server.starttls()
Expand Down Expand Up @@ -142,18 +142,18 @@ def run(self, dry=False, *args, **kwargs):

if not dry:
server.sendmail(self.sender, target_addresses, msg.as_string())
if self.info_reportor is not None:
self.info_reportor.update_state(
hash_id=_request[info_report.HASH_ID],
state=State.SUBMIT_SUCCESS,
)
# if self.info_reportor is not None:
# self.info_reportor.update_state(
# hash_id=_request[info_report.HASH_ID],
# state=State.SUBMIT_SUCCESS,
# )
else:
if not dry:
if self.info_reportor is not None:
self.info_reportor.update_state(
hash_id=_request[info_report.HASH_ID],
state=State.SUBMIT_ERROR,
)
# if self.info_reportor is not None:
# self.info_reportor.update_state(
# hash_id=_request[info_report.HASH_ID],
# state=State.SUBMIT_ERROR,
# )
if self.loop_forever:
post_utils.set_visible(hash_id=_request[post_utils.HASH_ID])
logger.info("No pdb to submit.")
Expand Down Expand Up @@ -191,16 +191,16 @@ def calculate_plddt_from_peb(pdb_path):
plddt = np.mean(prot.b_factors[:, 0])
return plddt

def run(self, dry=False, *args, **kwargs):
def run(self, dry=False):
for reqs in misc.chunk_generate(self.requests, chunk_size=3):
for _request in reqs:
if not _request.get("submit", True):
if self.info_reportor is not None:
self.info_reportor.update_state(
hash_id=_request[info_report.HASH_ID],
state=State.SUBMIT_SKIP,
)
continue
# if not _request.get("submit", True):
# if self.info_reportor is not None:
# self.info_reportor.update_state(
# hash_id=_request[info_report.HASH_ID],
# state=State.SUBMIT_SKIP,
# )
# continue
with smtplib.SMTP(self.smtp_ssl_host, self.smtp_ssl_port) as server:
server.ehlo()
server.starttls()
Expand Down Expand Up @@ -273,18 +273,18 @@ def run(self, dry=False, *args, **kwargs):
server.sendmail(
self.sender, target_addresses, msg.as_string()
)
if self.info_reportor is not None:
self.info_reportor.update_state(
hash_id=_request[info_report.HASH_ID],
state=State.SUBMIT_SUCCESS,
)
# if self.info_reportor is not None:
# self.info_reportor.update_state(
# hash_id=_request[info_report.HASH_ID],
# state=State.SUBMIT_SUCCESS,
# )
else:
if not dry:
if self.info_reportor is not None:
self.info_reportor.update_state(
hash_id=_request[info_report.HASH_ID],
state=State.SUBMIT_ERROR,
)
# if self.info_reportor is not None:
# self.info_reportor.update_state(
# hash_id=_request[info_report.HASH_ID],
# state=State.SUBMIT_ERROR,
# )
if self.loop_forever:
post_utils.set_visible(
hash_id=_request[post_utils.HASH_ID]
Expand Down

0 comments on commit 03a4be9

Please sign in to comment.