Mercurial > repos > tduigou > retrorules
diff query.py @ 4:815748762646 draft default tip
planemo upload for repository https://github.com/brsynth/galaxytools commit d7030c1af6fe06a1d45af115756ee775721e39b5
| author | tduigou |
|---|---|
| date | Thu, 02 Oct 2025 14:27:31 +0000 |
| parents | 95b4196b4ded |
| children |
line wrap: on
line diff
--- a/query.py Mon Sep 15 12:59:58 2025 +0000 +++ b/query.py Thu Oct 02 14:27:31 2025 +0000 @@ -17,11 +17,11 @@ chemical_domain_str: str, ec_number_str: str, min_radius_int: int, - valid_str: str, + valid_str: str, dedup_str: str, limit_int: int, offset_int: int, - ) -> Tuple: +) -> Tuple: url = f"{BASE_URL}/templates" params = [] if smarts_str: @@ -48,16 +48,19 @@ params.append(("offset", str(offset_int))) return url, params + def from_templates_summary(template_id_str: str) -> Tuple: url = f"{BASE_URL}/templates/{template_id_str}/summary" params = {} return url, params + def from_templates_sources(template_id_str: str) -> Tuple: url = f"{BASE_URL}/templates/{template_id_str}/sources" params = {} return url, params + def from_templates_count( smarts_str: str, template_ids_str: str, @@ -66,9 +69,9 @@ chemical_domain_str: str, ec_number_str: str, min_radius_int: int, - valid_str: str, + valid_str: str, dedup_str: str, - ) -> Tuple: +) -> Tuple: url = f"{BASE_URL}/templates_count" params = [] if smarts_str: @@ -91,6 +94,7 @@ params.append(("dedup", dedup_str)) return url, params + def from_templates_export( generation_token_str: str, smarts_str: str, @@ -100,9 +104,9 @@ chemical_domain_str: str, ec_number_str: str, min_radius_int: int, - valid_str: str, + valid_str: str, dedup_str: str, - ) -> Tuple: +) -> Tuple: url = f"{BASE_URL}/templates_export" params = [] if generation_token_str: @@ -127,19 +131,23 @@ params.append(("dedup", dedup_str)) return url, params + def query(url: str, params: Dict): response = requests.get(url, params=params) response.raise_for_status() return response + def write_json(path: str, data: Dict): with open(path, "w") as fd: json.dump(data, fd, indent=4) + def write_tab(path: str, data: str): with open(path, "w") as fd: fd.write(data) + def main(): parser = argparse.ArgumentParser( description="Query RetroRules API via command-line endpoints." @@ -215,7 +223,7 @@ required=True, help="Path to output JSON file", ) - + # Subcommand: templates-sources parser_tem_sou = subparsers.add_parser("templates-sources", help="From templates-sources") parser_tem_sou.add_argument("--input-template-id-str", required=True, help="Template ID")
