|
26 | 26 | from api.utils.hotspot_utils import HotspotUtils |
27 | 27 | import sys |
28 | 28 | from api import db, cache, limiter |
| 29 | +from api.utils.docking_utils import Docker |
29 | 30 |
|
30 | 31 |
|
31 | 32 | snps = Namespace("SNPs", description="Information about SNPs", path="/snps") |
|
47 | 48 | ) |
48 | 49 |
|
49 | 50 |
|
| 51 | +@snps.route("/docking/<receptor>/<ligand>") |
| 52 | +class Docking(Resource): |
| 53 | + decorators = [limiter.limit("2/minute")] |
| 54 | + |
| 55 | + @snps.param("receptor", _in="path", default="bri1") |
| 56 | + @snps.param("ligand", _in="path", default="brass") |
| 57 | + def get(self, receptor, ligand): |
| 58 | + receptor = escape(receptor) |
| 59 | + ligand = escape(ligand) |
| 60 | + docking_pdb_path = "/DATA/HEX_API/RESULTS/" |
| 61 | + |
| 62 | + if not BARUtils.is_arabidopsis_gene_valid(receptor): |
| 63 | + return BARUtils.error_exit("Invalid arapbidopsis pdb gene id"), 400 |
| 64 | + |
| 65 | + matched = re.search("[a-z]", ligand) |
| 66 | + if matched is None: |
| 67 | + return BARUtils.error_exit("Invalid ligand name"), 400 |
| 68 | + |
| 69 | + # start function to initiate docking_utils file |
| 70 | + |
| 71 | + final_json = Docker.start(receptor, ligand, docking_pdb_path) |
| 72 | + if final_json == "Receptor file not found": |
| 73 | + return BARUtils.error_exit("There are no data found for the given gene"), 400 |
| 74 | + elif final_json == "Ligand file not found": |
| 75 | + return BARUtils.error_exit("There are no data found for the given ligand"), 400 |
| 76 | + else: |
| 77 | + return BARUtils.success_exit(final_json) |
| 78 | + |
| 79 | + |
50 | 80 | @snps.route("/phenix/<fixed_pdb>/<moving_pdb>") |
51 | 81 | class Phenix(Resource): |
52 | 82 | @snps.param("fixed_pdb", _in="path", default="Potri.016G107900.1") |
|
0 commit comments