From a23ffff03f7415b3171b1ec6b40f06e334ad19fb Mon Sep 17 00:00:00 2001 From: Ryan Greer Date: Mon, 30 Sep 2024 18:56:09 -0600 Subject: [PATCH 1/5] added functionality for sbh user library imports + fixed tooltip bug --- apps/server/app.py | 28 +++ apps/web/src/components/CurationForm.jsx | 7 +- apps/web/src/components/SequenceSection.jsx | 194 ++++++++++++++++++-- apps/web/src/modules/api.js | 32 +++- apps/web/src/modules/store.js | 19 +- 5 files changed, 256 insertions(+), 24 deletions(-) diff --git a/apps/server/app.py b/apps/server/app.py index 0434d39..e2c1953 100644 --- a/apps/server/app.py +++ b/apps/server/app.py @@ -200,6 +200,7 @@ def run_synbict(sbol_content: str, part_library_file_names: list[str]) -> tuple[ target_library = FeatureLibrary([target_doc]) # feature_library = FEATURE_LIBRARIES[0] feature_library = create_feature_library(part_lib_f_name) + print(f"feature library for {part_lib_f_name}: {feature_library}") min_feature_length = 10 annotater = FeatureAnnotater(feature_library, min_feature_length) min_target_length = 10 @@ -423,6 +424,33 @@ def annotate_text(): biobert_result = run_biobert(free_text) return {"text": free_text, "annotations": biobert_result} +@app.post("/api/importUserLibrary") +def import_library(): + request_data = request.get_json() + SBHSessionToken = request_data['sessionToken'] + collectionURL = request_data['url'] + + headers = { + "Accept": "text/plain", + "X-authorization": SBHSessionToken + } + + response = requests.get(collectionURL, headers=headers) + + # Check if the request was successful + if response.status_code == 200: + print("Request successful") + feature_doc = sbol2.Document() + feature_doc.readString(response.text) + FEATURE_LIBRARIES[collectionURL] = FeatureLibrary([feature_doc]) + print(f"Feature Doc Summary for{collectionURL}: \n{feature_doc}") + + return {"response": response.text} + else: + print(f"Request failed with status code: {response.status_code}") + return {"response": response.text} + + # if __name__ == '__main__': # app.run(debug=True,host='0.0.0.0',port=5000) if __name__ == "__main__": diff --git a/apps/web/src/components/CurationForm.jsx b/apps/web/src/components/CurationForm.jsx index 96f84ca..a158093 100644 --- a/apps/web/src/components/CurationForm.jsx +++ b/apps/web/src/components/CurationForm.jsx @@ -43,7 +43,7 @@ function SynBioHubClient({opened, onClose, setIsInteractingWithSynBioHub, synBio ); } -function SynBioHubClientLogin({ synBioHubs }) { +export function SynBioHubClientLogin({ synBioHubs }) { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [inputError, setInputError] = useState(false); @@ -62,7 +62,8 @@ function SynBioHubClientLogin({ synBioHubs }) { data={synBioHubs} onChange={(v) => { setWorkingSynBioHubUrlPrefix(v); - }} + }} + searchable /> - {workingSequence !== false ? //TextArea is the editor // TODO: add highlight in TextArea - //