From b8d41c7c89432cce6ceec7f0a098e93b4a77ef42 Mon Sep 17 00:00:00 2001 From: junikimm717 <68165832+junikimm717@users.noreply.github.com> Date: Sun, 15 Jan 2023 10:07:36 -0500 Subject: [PATCH] instructions --- app.py | 2 +- templates/admin.html | 31 ++++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index dc33a86..485b116 100755 --- a/app.py +++ b/app.py @@ -253,7 +253,7 @@ def search_api(): rt_filter = and_(rt_max > Chemical.final_rt, Chemical.final_rt > rt_min) result = Chemical.query.filter( and_(mz_filter, rt_filter) - ).limit(20).all() + ).limit(10).all() data = [] for x in result: data.append({"url": url_for("chemical_view", id=x.id), "name": x.name, "mz": x.final_mz, "rt": x.final_rt}) diff --git a/templates/admin.html b/templates/admin.html index 79f1486..df0287e 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -64,5 +64,34 @@ fields = { } session.post(baseurl + "/chemical/create", fields) +

Programmatically Searching For Matching Compounds

+

+import requests
+baseurl = "chemicaldb.teidkim.me"
+# initialize parameters
+
+def generate_parameters(mz, mz_range_ppm, rt, rt_range):
+    return dict(
+      mz_min=(mz - mz_range_ppm/10**6),
+      mz_max=(mz + mz_range_ppm/10**6),
+      rt_min=(rt - rt_range),
+      rt_max=(rt + rt_range)
+    )
+
+mz = < theoretical mz ratio >
+mz_range_ppm = <threshold the mz value should be in ppm units>
+rt = < theoretical retention time >
+rt_range = < seconds in which the rt needs to be in >
+
+# make a request to the endpoint.
+response = requests.get(baseurl + "/chemical/search", params=generate_parameters(mz, mz_range_ppm, rt, rt_range))
+# make sure to include some error handling code.
+results = response.json()
+
+# results is a json containing a list of chemicals with the same schema as above.
+# There are up to 10 search results per query, so you should write some code to
+# determine which result is best.
+    
+ -{% endblock %} \ No newline at end of file +{% endblock %}