annotate query.py @ 3:95b4196b4ded draft

planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
author tduigou
date Mon, 15 Sep 2025 12:59:58 +0000
parents 58bbbff358d6
children 815748762646
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
1 import argparse
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
2 import json
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
3 import logging
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
4 import sys
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
5 from typing import Dict, Tuple
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
6
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
7 import requests
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
8
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
9 BASE_URL = "https://retrorules.org/api"
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
10
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
11
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
12 def from_templates(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
13 smarts_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
14 template_ids_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
15 reaction_ids_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
16 datasets_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
17 chemical_domain_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
18 ec_number_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
19 min_radius_int: int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
20 valid_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
21 dedup_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
22 limit_int: int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
23 offset_int: int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
24 ) -> Tuple:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
25 url = f"{BASE_URL}/templates"
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
26 params = []
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
27 if smarts_str:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
28 params.append(("q", smarts_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
29 if template_ids_str:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
30 params.append(("template_ids", ",".join(template_ids_str)))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
31 if reaction_ids_str:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
32 params.append(("reaction_ids", ",".join(reaction_ids_str)))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
33 if datasets_str and datasets_str != "any":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
34 params.append(("datasets", datasets_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
35 if chemical_domain_str and chemical_domain_str != "any":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
36 params.append(("chemical_domain", chemical_domain_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
37 if ec_number_str:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
38 params.append(("ec", ec_number_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
39 if min_radius_int is not None:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
40 params.append(("min_radius", str(min_radius_int)))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
41 if valid_str and valid_str != "any":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
42 params.append(("valid", valid_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
43 if dedup_str and dedup_str != "any":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
44 params.append(("dedup", dedup_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
45 if limit_int:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
46 params.append(("limit", str(limit_int)))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
47 if offset_int:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
48 params.append(("offset", str(offset_int)))
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
49 return url, params
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
50
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
51 def from_templates_summary(template_id_str: str) -> Tuple:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
52 url = f"{BASE_URL}/templates/{template_id_str}/summary"
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
53 params = {}
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
54 return url, params
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
55
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
56 def from_templates_sources(template_id_str: str) -> Tuple:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
57 url = f"{BASE_URL}/templates/{template_id_str}/sources"
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
58 params = {}
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
59 return url, params
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
60
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
61 def from_templates_count(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
62 smarts_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
63 template_ids_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
64 reaction_ids_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
65 datasets_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
66 chemical_domain_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
67 ec_number_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
68 min_radius_int: int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
69 valid_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
70 dedup_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
71 ) -> Tuple:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
72 url = f"{BASE_URL}/templates_count"
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
73 params = []
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
74 if smarts_str:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
75 params.append(("q", smarts_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
76 if template_ids_str:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
77 params.append(("template_ids", ",".join(template_ids_str)))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
78 if reaction_ids_str:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
79 params.append(("reaction_ids", ",".join(reaction_ids_str)))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
80 if datasets_str and datasets_str != "any":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
81 params.append(("datasets", datasets_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
82 if chemical_domain_str and chemical_domain_str != "any":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
83 params.append(("chemical_domain", chemical_domain_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
84 if ec_number_str:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
85 params.append(("ec", ec_number_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
86 if min_radius_int is not None:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
87 params.append(("min_radius", str(min_radius_int)))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
88 if valid_str and valid_str != "any":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
89 params.append(("valid", valid_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
90 if dedup_str and dedup_str != "any":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
91 params.append(("dedup", dedup_str))
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
92 return url, params
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
93
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
94 def from_templates_export(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
95 generation_token_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
96 smarts_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
97 template_ids_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
98 reaction_ids_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
99 datasets_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
100 chemical_domain_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
101 ec_number_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
102 min_radius_int: int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
103 valid_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
104 dedup_str: str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
105 ) -> Tuple:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
106 url = f"{BASE_URL}/templates_export"
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
107 params = []
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
108 if generation_token_str:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
109 params.append(("gen_token", generation_token_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
110 if smarts_str:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
111 params.append(("q", smarts_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
112 if template_ids_str:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
113 params.append(("template_ids", ",".join(template_ids_str)))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
114 if reaction_ids_str:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
115 params.append(("reaction_ids", ",".join(reaction_ids_str)))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
116 if datasets_str and datasets_str != "any":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
117 params.append(("datasets", datasets_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
118 if chemical_domain_str and chemical_domain_str != "any":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
119 params.append(("chemical_domain", chemical_domain_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
120 if ec_number_str:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
121 params.append(("ec", ec_number_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
122 if min_radius_int is not None:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
123 params.append(("min_radius", str(min_radius_int)))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
124 if valid_str and valid_str != "any":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
125 params.append(("valid", valid_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
126 if dedup_str and dedup_str != "any":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
127 params.append(("dedup", dedup_str))
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
128 return url, params
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
129
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
130 def query(url: str, params: Dict):
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
131 response = requests.get(url, params=params)
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
132 response.raise_for_status()
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
133 return response
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
134
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
135 def write_json(path: str, data: Dict):
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
136 with open(path, "w") as fd:
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
137 json.dump(data, fd, indent=4)
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
138
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
139 def write_tab(path: str, data: str):
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
140 with open(path, "w") as fd:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
141 fd.write(data)
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
142
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
143 def main():
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
144 parser = argparse.ArgumentParser(
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
145 description="Query RetroRules API via command-line endpoints."
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
146 )
2
58bbbff358d6 planemo upload for repository https://github.com/brsynth/galaxytools commit 469ebd8616b81810ead4633c278dc4c65ab8603b
tduigou
parents: 0
diff changeset
147 subparsers = parser.add_subparsers(dest="command")
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
148
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
149 # Subcommand: templates
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
150 parser_tem = subparsers.add_parser("templates", help="From templates")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
151 parser_tem.add_argument("--input-smarts-str", help="Exact SMARTS")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
152 parser_tem.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
153 "--input-template-ids-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
154 nargs="*",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
155 help="Space separated list of template IDs",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
156 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
157 parser_tem.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
158 "--input-reaction-ids-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
159 nargs="*",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
160 help="Space separated list of reaction IDs",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
161 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
162 parser_tem.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
163 "--input-datasets-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
164 default="any",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
165 choices=["any", "metanetx", "rhea", "uspto"],
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
166 help="Select a specific database",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
167 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
168 parser_tem.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
169 "--input-chemical-domain-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
170 default="any",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
171 choices=["any", "biochem", "orgchem"],
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
172 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
173 parser_tem.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
174 "--input-ec-number-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
175 help="EC number to filter templates",
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
176 )
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
177 parser_tem.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
178 "--input-min-radius-int",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
179 type=int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
180 help="Single radius of the template",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
181 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
182 parser_tem.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
183 "--input-valid-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
184 default="true",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
185 choices=["any", "true", "false"],
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
186 help="By default only valid templates are returned",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
187 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
188 parser_tem.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
189 "--input-dedup-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
190 default="true",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
191 choices=["true", "false"],
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
192 help="By default deduplicated templates are returned",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
193 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
194 parser_tem.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
195 "--input-limit-int",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
196 type=int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
197 help="Limit number of returned templates",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
198 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
199 parser_tem.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
200 "--input-offset-int",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
201 type=int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
202 help="Offset the list of returned templates",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
203 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
204 parser_tem.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
205 "--output-data-json",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
206 required=True,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
207 help="Path to output JSON file",
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
208 )
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
209
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
210 # Subcommand: templates-summary
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
211 parser_tem_sum = subparsers.add_parser("templates-summary", help="From templates-summary")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
212 parser_tem_sum.add_argument("--input-template-id-str", required=True, help="Template ID")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
213 parser_tem_sum.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
214 "--output-data-json",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
215 required=True,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
216 help="Path to output JSON file",
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
217 )
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
218
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
219 # Subcommand: templates-sources
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
220 parser_tem_sou = subparsers.add_parser("templates-sources", help="From templates-sources")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
221 parser_tem_sou.add_argument("--input-template-id-str", required=True, help="Template ID")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
222 parser_tem_sou.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
223 "--output-data-json",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
224 required=True,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
225 help="Path to output JSON file",
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
226 )
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
227
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
228 # Subcommand: templates-count
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
229 parser_cou = subparsers.add_parser("templates-count", help="From templates-count")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
230 parser_cou.add_argument("--input-smarts-str", help="Exact SMARTS")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
231 parser_cou.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
232 "--input-template-ids-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
233 nargs="*",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
234 help="Space separated list of template IDs",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
235 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
236 parser_cou.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
237 "--input-reaction-ids-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
238 nargs="*",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
239 help="Space separated list of reaction IDs",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
240 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
241 parser_cou.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
242 "--input-datasets-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
243 default="any",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
244 choices=["any", "metanetx", "rhea", "uspto"],
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
245 help="Select a specific database",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
246 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
247 parser_cou.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
248 "--input-chemical-domain-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
249 default="any",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
250 choices=["any", "biochem", "orgchem"],
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
251 )
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
252 parser_cou.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
253 "--input-ec-number-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
254 help="EC number to filter templates",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
255 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
256 parser_cou.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
257 "--input-min-radius-int",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
258 type=int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
259 help="Single radius of the template",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
260 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
261 parser_cou.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
262 "--input-valid-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
263 default="true",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
264 choices=["any", "true", "false"],
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
265 help="By default only valid templates are returned",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
266 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
267 parser_cou.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
268 "--input-dedup-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
269 default="true",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
270 choices=["true", "false"],
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
271 help="By default deduplicated templates are returned",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
272 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
273 parser_cou.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
274 "--output-data-json",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
275 required=True,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
276 help="Path to output JSON file",
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
277 )
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
278
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
279 # Subcommand: templates-export
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
280 parser_exp = subparsers.add_parser("templates-export", help="From templates-export")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
281 parser_exp.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
282 "--input-generation-token-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
283 help="Generation token from RetroRules web interface",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
284 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
285 parser_exp.add_argument("--input-smarts-str", help="Exact SMARTS")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
286 parser_exp.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
287 "--input-template-ids-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
288 nargs="*",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
289 help="Space separated list of template IDs",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
290 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
291 parser_exp.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
292 "--input-reaction-ids-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
293 nargs="*",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
294 help="Space separated list of reaction IDs",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
295 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
296 parser_exp.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
297 "--input-datasets-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
298 default="any",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
299 choices=["any", "metanetx", "rhea", "uspto"],
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
300 help="Select a specific database",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
301 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
302 parser_exp.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
303 "--input-chemical-domain-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
304 default="any",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
305 choices=["any", "biochem", "orgchem"],
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
306 )
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
307 parser_exp.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
308 "--input-ec-number-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
309 help="EC number to filter templates",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
310 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
311 parser_exp.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
312 "--input-min-radius-int",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
313 type=int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
314 help="Single radius of the template",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
315 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
316 parser_exp.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
317 "--input-valid-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
318 default="true",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
319 choices=["any", "true", "false"],
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
320 help="By default only valid templates are returned",
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
321 )
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
322 parser_exp.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
323 "--input-dedup-str",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
324 default="true",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
325 choices=["true", "false"],
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
326 help="By default deduplicated templates are returned",
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
327 )
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
328 parser_exp.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
329 "--output-data-json",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
330 help="Path to output JSON file",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
331 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
332 parser_exp.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
333 "--output-data-csv",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
334 help="Path to output CSV file",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
335 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
336 parser_exp.add_argument(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
337 "--output-data-tsv",
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
338 help="Path to output TSV file",
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
339 )
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
340
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
341 logging.info("Query RetroRules - start")
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
342 args = parser.parse_args()
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
343
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
344 try:
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
345 logging.info("Build arguments")
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
346 url, params = "", {}
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
347 if args.command == "templates":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
348 url, params = from_templates(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
349 smarts_str=args.input_smarts_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
350 template_ids_str=args.input_template_ids_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
351 reaction_ids_str=args.input_reaction_ids_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
352 datasets_str=args.input_datasets_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
353 chemical_domain_str=args.input_chemical_domain_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
354 ec_number_str=args.input_ec_number_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
355 min_radius_int=args.input_min_radius_int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
356 valid_str=args.input_valid_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
357 dedup_str=args.input_dedup_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
358 limit_int=args.input_limit_int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
359 offset_int=args.input_offset_int,
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
360 )
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
361 elif args.command == "templates-summary":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
362 url, _ = from_templates_summary(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
363 template_id_str=args.input_template_id_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
364 )
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
365 elif args.command == "templates-sources":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
366 url, _ = from_templates_sources(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
367 template_id_str=args.input_template_id_str,
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
368 )
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
369 elif args.command == "templates-count":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
370 url, params = from_templates_count(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
371 smarts_str=args.input_smarts_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
372 template_ids_str=args.input_template_ids_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
373 reaction_ids_str=args.input_reaction_ids_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
374 datasets_str=args.input_datasets_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
375 chemical_domain_str=args.input_chemical_domain_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
376 ec_number_str=args.input_ec_number_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
377 min_radius_int=args.input_min_radius_int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
378 valid_str=args.input_valid_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
379 dedup_str=args.input_dedup_str,
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
380 )
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
381 elif args.command == "templates-export":
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
382 url, params = from_templates_export(
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
383 generation_token_str=args.input_generation_token_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
384 smarts_str=args.input_smarts_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
385 template_ids_str=args.input_template_ids_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
386 reaction_ids_str=args.input_reaction_ids_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
387 datasets_str=args.input_datasets_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
388 chemical_domain_str=args.input_chemical_domain_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
389 ec_number_str=args.input_ec_number_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
390 min_radius_int=args.input_min_radius_int,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
391 valid_str=args.input_valid_str,
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
392 dedup_str=args.input_dedup_str,
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
393 )
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
394 else:
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
395 parser.print_help()
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
396 sys.exit(1)
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
397
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
398 logging.info("Query API")
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
399 response = query(url=url, params=params)
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
400
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
401 logging.info("Write data")
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
402 if "output_data_json" in vars(args) and args.output_data_json:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
403 write_json(path=args.output_data_json, data=response.json())
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
404 if "output_data_csv" in vars(args) and args.output_data_csv:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
405 write_tab(path=args.output_data_csv, data=response.text)
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
406 if "output_data_tsv" in vars(args) and args.output_data_tsv:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 2
diff changeset
407 write_tab(path=args.output_data_tsv, data=response.text)
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
408 except requests.HTTPError as e:
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
409 logging.error(f"HTTP error: {e.response.status_code} - {e.response.text}")
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
410 sys.exit(1)
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
411 except Exception as e:
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
412 logging.error(f"Error: {e}")
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
413 sys.exit(1)
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
414
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
415 logging.info("Query RetroRules - end")
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
416
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
417
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
418 if __name__ == "__main__":
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
419 logging.basicConfig(
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
420 level=logging.INFO,
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
421 format="%(asctime)s - %(levelname)s - %(message)s",
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
422 datefmt="%d-%m-%Y %H:%M",
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
423 )
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
424 main()