sapiopycommons 2024.10.31a349__tar.gz → 2024.11.5a352__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sapiopycommons might be problematic. Click here for more details.

Files changed (76) hide show
  1. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/PKG-INFO +1 -1
  2. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/pyproject.toml +1 -1
  3. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/chem/IndigoMolecules.py +1 -0
  4. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/chem/Molecules.py +77 -19
  5. sapiopycommons-2024.11.5a352/src/sapiopycommons/flowcyto/flow_cyto.py +77 -0
  6. sapiopycommons-2024.11.5a352/src/sapiopycommons/flowcyto/flowcyto_data.py +75 -0
  7. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/multimodal/multimodal_data.py +6 -3
  8. sapiopycommons-2024.11.5a352/tests/chem_test_curation_queue.py +31 -0
  9. sapiopycommons-2024.11.5a352/tests/curation_queue_test.sdf +168 -0
  10. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/tests/data_type_models.py +38154 -17480
  11. sapiopycommons-2024.11.5a352/tests/flowcyto/101_DEN084Y5_15_E01_008_clean.fcs +0 -0
  12. sapiopycommons-2024.11.5a352/tests/flowcyto/101_DEN084Y5_15_E03_009_clean.fcs +0 -0
  13. sapiopycommons-2024.11.5a352/tests/flowcyto/101_DEN084Y5_15_E05_010_clean.fcs +0 -0
  14. sapiopycommons-2024.11.5a352/tests/flowcyto/8_color_ICS.wsp +4833 -0
  15. sapiopycommons-2024.11.5a352/tests/flowcyto/COVID19_W_001_O.fcs +0 -0
  16. sapiopycommons-2024.11.5a352/tests/flowcyto_test.py +71 -0
  17. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/.gitignore +0 -0
  18. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/LICENSE +0 -0
  19. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/README.md +0 -0
  20. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/__init__.py +0 -0
  21. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/callbacks/__init__.py +0 -0
  22. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/callbacks/callback_util.py +0 -0
  23. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/callbacks/field_builder.py +0 -0
  24. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/chem/__init__.py +0 -0
  25. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/customreport/__init__.py +0 -0
  26. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/customreport/column_builder.py +0 -0
  27. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/customreport/custom_report_builder.py +0 -0
  28. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/customreport/term_builder.py +0 -0
  29. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/datatype/__init__.py +0 -0
  30. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/datatype/attachment_util.py +0 -0
  31. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/datatype/data_fields.py +0 -0
  32. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/datatype/pseudo_data_types.py +0 -0
  33. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/eln/__init__.py +0 -0
  34. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/eln/experiment_handler.py +0 -0
  35. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/eln/experiment_report_util.py +0 -0
  36. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/eln/plate_designer.py +0 -0
  37. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/files/__init__.py +0 -0
  38. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/files/complex_data_loader.py +0 -0
  39. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/files/file_bridge.py +0 -0
  40. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/files/file_bridge_handler.py +0 -0
  41. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/files/file_data_handler.py +0 -0
  42. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/files/file_util.py +0 -0
  43. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/files/file_validator.py +0 -0
  44. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/files/file_writer.py +0 -0
  45. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/general/__init__.py +0 -0
  46. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/general/accession_service.py +0 -0
  47. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/general/aliases.py +0 -0
  48. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/general/audit_log.py +0 -0
  49. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/general/custom_report_util.py +0 -0
  50. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/general/exceptions.py +0 -0
  51. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/general/popup_util.py +0 -0
  52. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/general/sapio_links.py +0 -0
  53. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/general/storage_util.py +0 -0
  54. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/general/time_util.py +0 -0
  55. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/multimodal/multimodal.py +0 -0
  56. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/processtracking/__init__.py +0 -0
  57. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/processtracking/custom_workflow_handler.py +0 -0
  58. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/processtracking/endpoints.py +0 -0
  59. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/recordmodel/__init__.py +0 -0
  60. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/recordmodel/record_handler.py +0 -0
  61. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/rules/__init__.py +0 -0
  62. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/rules/eln_rule_handler.py +0 -0
  63. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/rules/on_save_rule_handler.py +0 -0
  64. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/sftpconnect/__init__.py +0 -0
  65. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/sftpconnect/sftp_builder.py +0 -0
  66. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/webhook/__init__.py +0 -0
  67. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/webhook/webhook_context.py +0 -0
  68. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/webhook/webhook_handlers.py +0 -0
  69. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/src/sapiopycommons/webhook/webservice_handlers.py +0 -0
  70. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/tests/_do_not_add_init_py_here +0 -0
  71. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/tests/accession_test.py +0 -0
  72. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/tests/bio_reg_test.py +0 -0
  73. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/tests/chem_test.py +0 -0
  74. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/tests/kappa.chains.fasta +0 -0
  75. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/tests/mafft_test.py +0 -0
  76. {sapiopycommons-2024.10.31a349 → sapiopycommons-2024.11.5a352}/tests/test.gb +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sapiopycommons
3
- Version: 2024.10.31a349
3
+ Version: 2024.11.5a352
4
4
  Summary: Official Sapio Python API Utilities Package
5
5
  Project-URL: Homepage, https://github.com/sapiosciences
6
6
  Author-email: Jonathan Steck <jsteck@sapiosciences.com>, Yechen Qiao <yqiao@sapiosciences.com>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "sapiopycommons"
7
- version='2024.10.31a349'
7
+ version='2024.11.05a352'
8
8
  authors = [
9
9
  { name="Jonathan Steck", email="jsteck@sapiosciences.com" },
10
10
  { name="Yechen Qiao", email="yqiao@sapiosciences.com" },
@@ -9,6 +9,7 @@ indigo.setOption("ignore-stereochemistry-errors", True)
9
9
  indigo.setOption("render-stereo-style", "ext")
10
10
  indigo.setOption("aromaticity-model", "generic")
11
11
  indigo.setOption("render-coloring", True)
12
+ indigo.setOption("molfile-saving-mode", "3000")
12
13
  indigo_inchi = IndigoInchi(indigo);
13
14
 
14
15
 
@@ -1,5 +1,6 @@
1
1
  # Author Yechen Qiao
2
2
  # Common Molecule Utilities for Molecule Transfers with Sapio
3
+ from typing import cast
3
4
 
4
5
  from rdkit import Chem
5
6
  from rdkit.Chem import Crippen, MolToInchi
@@ -20,6 +21,25 @@ tautomer_params.tautomerReassignStereo = False
20
21
  tautomer_params.tautomerRemoveIsotopicHs = True
21
22
  enumerator = rdMolStandardize.TautomerEnumerator(tautomer_params)
22
23
 
24
+
25
+ def get_enhanced_stereo_reg_hash(mol: Mol, enhanced_stereo: bool) -> str:
26
+ """
27
+ Get the Registration Hash for the molecule by the current registration configuration.
28
+ When we are running if we are canonicalization of tautomers or cleaning up any other way, do they first before calling.
29
+ :param mol: The molecule to obtain hash for.
30
+ :param canonical_tautomer: Whether the registry system canonicalize the tautomers.
31
+ :param enhanced_stereo: Whether we are computing enhanced stereo at all.
32
+ :return: The enhanced stereo hash.
33
+ """
34
+ if enhanced_stereo:
35
+ from rdkit.Chem.RegistrationHash import GetMolLayers, GetMolHash, HashScheme
36
+ layers = GetMolLayers(mol, enable_tautomer_hash_v2=True)
37
+ hash_scheme: HashScheme = HashScheme.TAUTOMER_INSENSITIVE_LAYERS
38
+ return GetMolHash(layers, hash_scheme=hash_scheme)
39
+ else:
40
+ return ""
41
+
42
+
23
43
  def neutralize_atoms(mol) -> Mol:
24
44
  """
25
45
  Neutralize atoms per https://baoilleach.blogspot.com/2019/12/no-charge-simple-approach-to.html
@@ -86,7 +106,6 @@ def mol_to_img(mol_str: str) -> str:
86
106
  return renderer.renderToString(mol)
87
107
 
88
108
 
89
-
90
109
  def mol_to_sapio_partial_pojo(mol: Mol):
91
110
  """
92
111
  Get the minimum information about molecule to Sapio, just its SMILES, V3000, and image data.
@@ -96,7 +115,7 @@ def mol_to_sapio_partial_pojo(mol: Mol):
96
115
  Chem.SanitizeMol(mol)
97
116
  mol.UpdatePropertyCache()
98
117
  smiles = Chem.MolToSmiles(mol)
99
- molBlock = Chem.MolToMolBlock(mol)
118
+ molBlock = Chem.MolToMolBlock(mol, forceV3000=True)
100
119
  img = mol_to_img(mol)
101
120
  molecule = dict()
102
121
  molecule["smiles"] = smiles
@@ -105,23 +124,52 @@ def mol_to_sapio_partial_pojo(mol: Mol):
105
124
  return molecule
106
125
 
107
126
 
108
- def mol_to_sapio_substance(mol: Mol, include_stereoisomers: bool = False,
127
+ def get_cxs_smiles_hash(mol: Mol, enhanced_stereo: bool) -> str:
128
+ """
129
+ Return the SHA1 CXS Smiles hash for the canonical, isomeric CXS SMILES of the molecule.
130
+ """
131
+ if not enhanced_stereo:
132
+ return ""
133
+ import hashlib
134
+ return hashlib.sha1(Chem.MolToCXSmiles(mol, canonical=True, isomericSmiles=True).encode()).hexdigest()
135
+
136
+
137
+ def get_has_or_group(mol: Mol, enhanced_stereo: bool) -> bool:
138
+ """
139
+ Return true if and only if: enhanced stereochemistry is enabled and there is at least one OR group in mol.
140
+ """
141
+ if not enhanced_stereo:
142
+ return False
143
+ from rdkit.Chem import StereoGroup_vect, STEREO_OR
144
+ stereo_groups: StereoGroup_vect = mol.GetStereoGroups()
145
+ for stereo_group in stereo_groups:
146
+ if stereo_group.GetGroupType() == STEREO_OR:
147
+ return True
148
+ return False
149
+
150
+
151
+ def mol_to_sapio_substance(mol: Mol, include_stereoisomers=False,
109
152
  normalize: bool = False, remove_salt: bool = False, make_images: bool = False,
110
- salt_def: str | None = None, canonical_tautomer: bool = True):
153
+ salt_def: str | None = None, canonical_tautomer: bool = True,
154
+ enhanced_stereo: bool = False, remove_atom_map: bool = True):
111
155
  """
112
156
  Convert a molecule in RDKit to a molecule POJO in Sapio.
113
157
 
114
158
  :param mol: The molecule in RDKit.
115
- :param include_stereoisomers: If true, will compute all stereoisomer permutations of this molecule.
116
159
  :param normalize If true, will normalize the functional groups and return normalized result.
117
160
  :param remove_salt If true, we will remove salts iteratively from the molecule before returning their data.
118
161
  We will also populate desaltedList with molecules we deleted.
162
+ :param make_images Whether to make images as part of the result without having another script to resolve it.
119
163
  :param salt_def: if not none, specifies custom salt to be used during the desalt process.
120
164
  :param canonical_tautomer: if True, we will attempt to compute canonical tautomer for the molecule. Slow!
121
165
  This is needed for a registry. Note it stops after enumeration of 1000.
166
+ :param enhanced_stereo: If enabled, enhanced stereo hash will be produced.
167
+ :param remove_atom_map: When set, clear all atom AAM maps that were set had it been merged into some reactions earlier.
122
168
  :return: The molecule POJO for Sapio.
123
169
  """
124
170
  molecule = dict()
171
+ if remove_atom_map:
172
+ [a.SetAtomMapNum(0) for a in mol.GetAtoms()]
125
173
  Chem.SanitizeMol(mol)
126
174
  mol.UpdatePropertyCache()
127
175
  Chem.GetSymmSSSR(mol)
@@ -157,7 +205,7 @@ def mol_to_sapio_substance(mol: Mol, include_stereoisomers: bool = False,
157
205
  exactMass = Descriptors.ExactMolWt(mol)
158
206
  molFormula = rdMolDescriptors.CalcMolFormula(mol)
159
207
  charge = Chem.GetFormalCharge(mol)
160
- molBlock = Chem.MolToMolBlock(mol)
208
+ molBlock = Chem.MolToMolBlock(mol, forceV3000=True)
161
209
 
162
210
  molecule["cLogP"] = cLogP
163
211
  molecule["tpsa"] = tpsa
@@ -181,28 +229,38 @@ def mol_to_sapio_substance(mol: Mol, include_stereoisomers: bool = False,
181
229
  # We need to test the INCHI can be loaded back to indigo.
182
230
  indigo_mol = indigo.loadMolecule(molBlock)
183
231
  indigo_mol.aromatize()
184
- indigo_inchi.resetOptions()
185
- indigo_inchi_str = indigo_inchi.getInchi(indigo_mol)
186
- molecule["inchi"] = indigo_inchi_str
187
- indigo_inchi_key_str = indigo_inchi.getInchiKey(indigo_inchi_str)
188
- molecule["inchiKey"] = indigo_inchi_key_str
232
+ if enhanced_stereo:
233
+ # Remove enhanced stereo layer when generating InChI as the stereo hash is generated separately for reg.
234
+ mol_copy: Mol = Chem.Mol(mol)
235
+ Chem.CanonicalizeEnhancedStereo(mol_copy)
236
+ molecule["inchi"] = Chem.MolToInchi(mol_copy)
237
+ molecule["inchiKey"] = Chem.MolToInchiKey(mol_copy)
238
+ else:
239
+ indigo_inchi.resetOptions()
240
+ indigo_inchi_str = indigo_inchi.getInchi(indigo_mol)
241
+ molecule["inchi"] = indigo_inchi_str
242
+ indigo_inchi_key_str = indigo_inchi.getInchiKey(indigo_inchi_str)
243
+ molecule["inchiKey"] = indigo_inchi_key_str
189
244
  molecule["smiles"] = indigo_mol.smiles()
245
+ molecule["reg_hash"] = get_enhanced_stereo_reg_hash(mol, enhanced_stereo=enhanced_stereo)
246
+ molecule["cxsmiles_hash"] = get_cxs_smiles_hash(mol, enhanced_stereo=enhanced_stereo)
247
+ molecule["has_or_group"] = get_has_or_group(mol, enhanced_stereo=enhanced_stereo)
190
248
 
191
- if include_stereoisomers and has_chiral_centers(mol):
192
- stereoisomers = find_all_possible_stereoisomers(mol, only_unassigned=False, try_embedding=False, unique=True)
193
- molecule["stereoisomers"] = [mol_to_sapio_partial_pojo(x) for x in stereoisomers]
194
249
  return molecule
195
250
 
196
251
 
197
- def mol_to_sapio_compound(mol: Mol, include_stereoisomers: bool = False,
252
+ def mol_to_sapio_compound(mol: Mol, include_stereoisomers=False, enhanced_stereo: bool = False,
198
253
  salt_def: str | None = None, resolve_canonical: bool = True,
199
- make_images: bool = False, canonical_tautomer: bool = True):
254
+ make_images: bool = False, canonical_tautomer: bool = True,
255
+ remove_atom_map: bool = True):
200
256
  ret = dict()
201
- ret['originalMol'] = mol_to_sapio_substance(mol, include_stereoisomers,
257
+ ret['originalMol'] = mol_to_sapio_substance(mol, include_stereoisomers=False,
202
258
  normalize=False, remove_salt=False, make_images=make_images,
203
- canonical_tautomer=canonical_tautomer)
259
+ canonical_tautomer=canonical_tautomer,
260
+ enhanced_stereo=enhanced_stereo, remove_atom_map=remove_atom_map)
204
261
  if resolve_canonical:
205
262
  ret['canonicalMol'] = mol_to_sapio_substance(mol, include_stereoisomers=False,
206
263
  normalize=True, remove_salt=True, make_images=make_images,
207
- salt_def=salt_def, canonical_tautomer=canonical_tautomer)
264
+ salt_def=salt_def, canonical_tautomer=canonical_tautomer,
265
+ enhanced_stereo=enhanced_stereo, remove_atom_map=remove_atom_map)
208
266
  return ret
@@ -0,0 +1,77 @@
1
+ from __future__ import annotations
2
+
3
+ from weakref import WeakValueDictionary
4
+
5
+ from sapiopylib.rest.User import SapioUser
6
+ from databind.json import dumps
7
+
8
+ from sapiopycommons.flowcyto.flowcyto_data import FlowJoWorkspaceInputJson, UploadFCSInputJson, \
9
+ ComputeFlowStatisticsInputJson
10
+
11
+
12
+ class FlowCytoManager:
13
+ """
14
+ This manager includes flow cytometry analysis tools that would require FlowCyto license to use.
15
+ """
16
+ _user: SapioUser
17
+
18
+ __instances: WeakValueDictionary[SapioUser, FlowCytoManager] = WeakValueDictionary()
19
+ __initialized: bool
20
+
21
+ def __new__(cls, user: SapioUser):
22
+ """
23
+ Observes singleton pattern per record model manager object.
24
+
25
+ :param user: The user that will make the webservice request to the application.
26
+ """
27
+ obj = cls.__instances.get(user)
28
+ if not obj:
29
+ obj = object.__new__(cls)
30
+ obj.__initialized = False
31
+ cls.__instances[user] = obj
32
+ return obj
33
+
34
+ def __init__(self, user: SapioUser):
35
+ if self.__initialized:
36
+ return
37
+ self._user = user
38
+ self.__initialized = True
39
+
40
+ def create_flowjo_workspace(self, workspace_input: FlowJoWorkspaceInputJson) -> int:
41
+ """
42
+ Create FlowJo Workspace and return the workspace record ID of workspace root record,
43
+ after successful creation.
44
+ :param workspace_input: the request data payload.
45
+ :return: The new workspace record ID.
46
+ """
47
+ payload = dumps(workspace_input, FlowJoWorkspaceInputJson)
48
+ response = self._user.plugin_post("flowcyto/workspace", payload=payload, is_payload_plain_text=True)
49
+ self._user.raise_for_status(response)
50
+ return int(response.json())
51
+
52
+ def upload_fcs_for_sample(self, upload_input: UploadFCSInputJson) -> int:
53
+ """
54
+ Upload FCS file as root of the sample FCS.
55
+ :param upload_input: The request data payload
56
+ :return: The root FCS file uploaded under sample.
57
+ """
58
+ payload = dumps(upload_input, UploadFCSInputJson)
59
+ response = self._user.plugin_post("flowcyto/fcs", payload=payload, is_payload_plain_text=True)
60
+ self._user.raise_for_status(response)
61
+ return int(response.json())
62
+
63
+ def compute_statistics(self, stat_compute_input: ComputeFlowStatisticsInputJson) -> list[int]:
64
+ """
65
+ Requests to compute flow cytometry statistics.
66
+ The children are of type FCSStatistic.
67
+ If the FCS files have not been evaluated yet,
68
+ then the lazy evaluation will be performed immediately prior to computing statistics, which can take longer.
69
+ If any new statistics are computed as children of FCS, they will be returned in the result record id list.
70
+ Note: if input has multiple FCS files, the client should try to get parent FCS file from each record to figure out which one is for which FCS.
71
+ :param stat_compute_input:
72
+ :return:
73
+ """
74
+ payload = dumps(stat_compute_input, ComputeFlowStatisticsInputJson)
75
+ response = self._user.plugin_post("flowcyto/statistics", payload=payload, is_payload_plain_text=True)
76
+ self._user.raise_for_status(response)
77
+ return list(response.json())
@@ -0,0 +1,75 @@
1
+ import base64
2
+ from enum import Enum
3
+
4
+ from databind.core.dataclasses import dataclass
5
+
6
+
7
+ class ChannelStatisticType(Enum):
8
+ """
9
+ All supported channel statistics type.
10
+ """
11
+ MEAN = "(Mean) MFI"
12
+ MEDIAN = "(Median) MFI"
13
+ STD_EV = "Std. Dev."
14
+ COEFFICIENT_OF_VARIATION = "CV"
15
+
16
+ display_name: str
17
+
18
+ def __init__(self, display_name: str):
19
+ self.display_name = display_name
20
+
21
+
22
+ @dataclass
23
+ class ChannelStatisticsParameterJSON:
24
+ channelNameList: list[str]
25
+ statisticsType: ChannelStatisticType
26
+
27
+ def __init__(self, channel_name_list: list[str], stat_type: ChannelStatisticType):
28
+ self.channelNameList = channel_name_list
29
+ self.statisticsType = stat_type
30
+
31
+
32
+ @dataclass
33
+ class ComputeFlowStatisticsInputJson:
34
+ fcsFileRecordIdList: list[int]
35
+ statisticsParameterList: list[ChannelStatisticsParameterJSON]
36
+
37
+ def __init__(self, fcs_file_record_id_list: list[int], statistics_parameter_list: list[ChannelStatisticsParameterJSON]):
38
+ self.fcsFileRecordIdList = fcs_file_record_id_list
39
+ self.statisticsParameterList = statistics_parameter_list
40
+
41
+
42
+ @dataclass
43
+ class FlowJoWorkspaceInputJson:
44
+ filePath: str
45
+ base64Data: str
46
+
47
+ def __init__(self, filePath: str, file_data: bytes):
48
+ self.filePath = filePath
49
+ self.base64Data = base64.b64encode(file_data).decode('utf-8')
50
+
51
+
52
+ @dataclass
53
+ class UploadFCSInputJson:
54
+ """
55
+ Request to upload new FCS file
56
+ Attributes:
57
+ filePath: The file name of the FCS file to be uploaded. For FlowJo workspace, this is important to match the file in group (via file names).
58
+ attachmentDataType: the attachment data type that contains already-uploaded FCS data.
59
+ attachmentRecordId: the attachment record ID that contains already-uploaded FCS data.
60
+ associatedRecordDataType: the "parent" association for the FCS. Can either be a workspace or a sample record.
61
+ associatedRecordId: the "parent" association for the FCS. Can either be a workspace or a sample record.
62
+ """
63
+ filePath: str
64
+ attachmentDataType: str
65
+ attachmentRecordId: int
66
+ associatedRecordDataType: str
67
+ associatedRecordId: int
68
+
69
+ def __init__(self, associated_record_data_type: str, associated_record_id: int,
70
+ file_path: str, attachment_data_type: str, attachment_record_id: int):
71
+ self.filePath = file_path
72
+ self.attachmentDataType = attachment_data_type
73
+ self.attachmentRecordId = attachment_record_id
74
+ self.associatedRecordDataType = associated_record_data_type
75
+ self.associatedRecordId = associated_record_id
@@ -38,6 +38,9 @@ class PyMolecule:
38
38
  normError: str | None
39
39
  desaltError: str | None
40
40
  desaltedList: list[str] | None
41
+ registrationHash: str | None
42
+ hasOrGroup: bool
43
+ CXSMILESHash: str | None
41
44
 
42
45
 
43
46
  @dataclass
@@ -100,9 +103,9 @@ class PyMoleculeLoaderResult:
100
103
  compoundList: the compounds successfully loaded.
101
104
  errorList: an error record is added here for each one we failed to load in Sapio.
102
105
  """
103
- compoundByStr: dict[str, PyCompound]
104
- compoundList: list[PyCompound]
105
- errorList: list[ChemLoadingError]
106
+ compoundByStr: dict[str, PyCompound] | None
107
+ compoundList: list[PyCompound] | None
108
+ errorList: list[ChemLoadingError] | None
106
109
 
107
110
 
108
111
  @dataclass
@@ -0,0 +1,31 @@
1
+ import unittest
2
+
3
+ from sapiopycommons.multimodal.multimodal import MultiModalManager
4
+ from sapiopycommons.multimodal.multimodal_data import *
5
+ from data_type_models import *
6
+
7
+ from sapiopylib.rest.DataMgmtService import DataMgmtServer
8
+ from sapiopylib.rest.User import SapioUser
9
+
10
+ user = SapioUser(url="https://linux-vm:8443/webservice/api", verify_ssl_cert=False,
11
+ guid="ae4e92e1-34c6-4336-8d80-7f6804d3e51c",
12
+ username="yqiao_api", password="Password1!")
13
+
14
+ multi_modal_manager = MultiModalManager(user)
15
+
16
+
17
+ class ChemCurationTest(unittest.TestCase):
18
+ def test_curation_reg(self):
19
+ with open("curation_queue_test.sdf", "rb") as f:
20
+ file_data: bytes = f.read()
21
+ loader_result = multi_modal_manager.load_compounds(
22
+ CompoundLoadRequestPojo(ChemicalReagentPartModel.DATA_TYPE_NAME, ChemLoadType.SDF_FILE,
23
+ file_data=file_data))
24
+ compound_list = loader_result.compoundList
25
+ for compound in compound_list:
26
+ self.assertTrue(compound.originalMol.CXSMILESHash)
27
+ self.assertTrue(compound.originalMol.registrationHash)
28
+ multi_modal_manager.register_compounds(ChemRegisterRequestPojo(
29
+ ChemicalReagentPartModel.DATA_TYPE_NAME, compound_list))
30
+ # User manually log in and resolve the curation queue.
31
+ print("Loaded! Now play with curation queue inside Sapio!")
@@ -0,0 +1,168 @@
1
+
2
+ -INDIGO-07302413292D
3
+
4
+ 0 0 0 0 0 0 0 0 0 0 0 V3000
5
+ M V30 BEGIN CTAB
6
+ M V30 COUNTS 12 13 0 0 0
7
+ M V30 BEGIN ATOM
8
+ M V30 1 C 19.7652 6.17863 0.0 0
9
+ M V30 2 C 19.4069 5.24519 0.0 0
10
+ M V30 3 C 18.4082 5.29746 0.0 0
11
+ M V30 4 C 18.1494 6.26337 0.0 0
12
+ M V30 5 C 18.9881 6.80795 0.0 0
13
+ M V30 6 C 19.9516 4.40647 0.0 0
14
+ M V30 7 C 20.9461 4.30193 0.0 0
15
+ M V30 8 C 21.154 3.32371 0.0 0 CFG=1
16
+ M V30 9 C 20.2879 2.82375 0.0 0
17
+ M V30 10 C 19.5449 3.49292 0.0 0 CFG=1
18
+ M V30 11 I 18.5667 3.28501 0.0 0
19
+ M V30 12 C 22.0676 2.91705 0.0 0
20
+ M V30 END ATOM
21
+ M V30 BEGIN BOND
22
+ M V30 1 1 1 2
23
+ M V30 2 1 2 3
24
+ M V30 3 1 3 4
25
+ M V30 4 1 4 5
26
+ M V30 5 1 5 1
27
+ M V30 6 1 2 6
28
+ M V30 7 1 6 7
29
+ M V30 8 1 7 8
30
+ M V30 9 1 8 9
31
+ M V30 10 1 9 10
32
+ M V30 11 1 10 6
33
+ M V30 12 1 10 11 CFG=1
34
+ M V30 13 1 8 12 CFG=3
35
+ M V30 END BOND
36
+ M V30 BEGIN COLLECTION
37
+ M V30 MDLV30/STEREL1 ATOMS=(1 8)
38
+ M V30 MDLV30/STEABS ATOMS=(1 10)
39
+ M V30 END COLLECTION
40
+ M V30 END CTAB
41
+ M END
42
+ $$$$
43
+
44
+ -INDIGO-07302413312D
45
+
46
+ 0 0 0 0 0 0 0 0 0 0 0 V3000
47
+ M V30 BEGIN CTAB
48
+ M V30 COUNTS 12 13 0 0 0
49
+ M V30 BEGIN ATOM
50
+ M V30 1 C 16.3152 -4.32137 0.0 0
51
+ M V30 2 C 15.9569 -5.25482 0.0 0
52
+ M V30 3 C 14.9582 -5.20255 0.0 0
53
+ M V30 4 C 14.6994 -4.23663 0.0 0
54
+ M V30 5 C 15.5381 -3.69205 0.0 0
55
+ M V30 6 C 16.5016 -6.09353 0.0 0
56
+ M V30 7 C 17.4961 -6.19807 0.0 0
57
+ M V30 8 C 17.704 -7.17629 0.0 0 CFG=2
58
+ M V30 9 C 16.8379 -7.67626 0.0 0
59
+ M V30 10 C 16.0949 -7.00708 0.0 0 CFG=1
60
+ M V30 11 I 15.1167 -7.21499 0.0 0
61
+ M V30 12 C 18.6176 -7.58295 0.0 0
62
+ M V30 END ATOM
63
+ M V30 BEGIN BOND
64
+ M V30 1 1 1 2
65
+ M V30 2 1 2 3
66
+ M V30 3 1 3 4
67
+ M V30 4 1 4 5
68
+ M V30 5 1 5 1
69
+ M V30 6 1 2 6
70
+ M V30 7 1 6 7
71
+ M V30 8 1 7 8
72
+ M V30 9 1 8 9
73
+ M V30 10 1 9 10
74
+ M V30 11 1 10 6
75
+ M V30 12 1 10 11 CFG=1
76
+ M V30 13 1 8 12 CFG=1
77
+ M V30 END BOND
78
+ M V30 BEGIN COLLECTION
79
+ M V30 MDLV30/STEREL1 ATOMS=(1 8)
80
+ M V30 MDLV30/STEABS ATOMS=(1 10)
81
+ M V30 END COLLECTION
82
+ M V30 END CTAB
83
+ M END
84
+ $$$$
85
+
86
+ -INDIGO-07302413322D
87
+
88
+ 0 0 0 0 0 0 0 0 0 0 0 V3000
89
+ M V30 BEGIN CTAB
90
+ M V30 COUNTS 12 13 0 0 0
91
+ M V30 BEGIN ATOM
92
+ M V30 1 C 19.7652 -4.32136 0.0 0
93
+ M V30 2 C 19.4068 -5.25486 0.0 0
94
+ M V30 3 C 18.4082 -5.20257 0.0 0
95
+ M V30 4 C 18.1494 -4.23667 0.0 0
96
+ M V30 5 C 18.9881 -3.69209 0.0 0
97
+ M V30 6 C 19.9515 -6.09354 0.0 0
98
+ M V30 7 C 20.9461 -6.19803 0.0 0
99
+ M V30 8 C 21.154 -7.17622 0.0 0 CFG=1
100
+ M V30 9 C 20.288 -7.67621 0.0 0
101
+ M V30 10 C 19.5448 -7.00704 0.0 0 CFG=1
102
+ M V30 11 I 18.5666 -7.21491 0.0 0
103
+ M V30 12 C 22.0676 -7.58291 0.0 0
104
+ M V30 END ATOM
105
+ M V30 BEGIN BOND
106
+ M V30 1 1 1 2
107
+ M V30 2 1 2 3
108
+ M V30 3 1 3 4
109
+ M V30 4 1 4 5
110
+ M V30 5 1 5 1
111
+ M V30 6 1 2 6
112
+ M V30 7 1 6 7
113
+ M V30 8 1 7 8
114
+ M V30 9 1 8 9
115
+ M V30 10 1 9 10
116
+ M V30 11 1 10 6
117
+ M V30 12 1 10 11 CFG=1
118
+ M V30 13 1 8 12 CFG=3
119
+ M V30 END BOND
120
+ M V30 BEGIN COLLECTION
121
+ M V30 MDLV30/STERAC1 ATOMS=(1 8)
122
+ M V30 MDLV30/STEABS ATOMS=(1 10)
123
+ M V30 END COLLECTION
124
+ M V30 END CTAB
125
+ M END
126
+ $$$$
127
+
128
+ -INDIGO-07302413322D
129
+
130
+ 0 0 0 0 0 0 0 0 0 0 0 V3000
131
+ M V30 BEGIN CTAB
132
+ M V30 COUNTS 12 13 0 0 0
133
+ M V30 BEGIN ATOM
134
+ M V30 1 C 16.3152 -4.32137 0.0 0
135
+ M V30 2 C 15.9569 -5.25481 0.0 0
136
+ M V30 3 C 14.9582 -5.20255 0.0 0
137
+ M V30 4 C 14.6994 -4.23663 0.0 0
138
+ M V30 5 C 15.5381 -3.69205 0.0 0
139
+ M V30 6 C 16.5016 -6.09353 0.0 0
140
+ M V30 7 C 17.4961 -6.19806 0.0 0
141
+ M V30 8 C 17.704 -7.17629 0.0 0 CFG=2
142
+ M V30 9 C 16.8379 -7.67626 0.0 0
143
+ M V30 10 C 16.0949 -7.00708 0.0 0 CFG=1
144
+ M V30 11 I 15.1167 -7.21499 0.0 0
145
+ M V30 12 C 18.6176 -7.58295 0.0 0
146
+ M V30 END ATOM
147
+ M V30 BEGIN BOND
148
+ M V30 1 1 1 2
149
+ M V30 2 1 2 3
150
+ M V30 3 1 3 4
151
+ M V30 4 1 4 5
152
+ M V30 5 1 5 1
153
+ M V30 6 1 2 6
154
+ M V30 7 1 6 7
155
+ M V30 8 1 7 8
156
+ M V30 9 1 8 9
157
+ M V30 10 1 9 10
158
+ M V30 11 1 10 6
159
+ M V30 12 1 10 11 CFG=1
160
+ M V30 13 1 8 12 CFG=1
161
+ M V30 END BOND
162
+ M V30 BEGIN COLLECTION
163
+ M V30 MDLV30/STERAC1 ATOMS=(1 8)
164
+ M V30 MDLV30/STEABS ATOMS=(1 10)
165
+ M V30 END COLLECTION
166
+ M V30 END CTAB
167
+ M END
168
+ $$$$