seer-pas-sdk 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl
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.
- seer_pas_sdk/core/__init__.py +100 -22
- {seer_pas_sdk-0.1.0.dist-info → seer_pas_sdk-0.1.2.dist-info}/METADATA +24 -8
- {seer_pas_sdk-0.1.0.dist-info → seer_pas_sdk-0.1.2.dist-info}/RECORD +6 -6
- {seer_pas_sdk-0.1.0.dist-info → seer_pas_sdk-0.1.2.dist-info}/WHEEL +1 -1
- {seer_pas_sdk-0.1.0.dist-info → seer_pas_sdk-0.1.2.dist-info}/LICENSE.txt +0 -0
- {seer_pas_sdk-0.1.0.dist-info → seer_pas_sdk-0.1.2.dist-info}/top_level.txt +0 -0
seer_pas_sdk/core/__init__.py
CHANGED
|
@@ -20,7 +20,7 @@ class SeerSDK:
|
|
|
20
20
|
|
|
21
21
|
Examples
|
|
22
22
|
-------
|
|
23
|
-
>>> from
|
|
23
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
24
24
|
>>> USERNAME = "test"
|
|
25
25
|
>>> PASSWORD = "test-password"
|
|
26
26
|
>>> INSTANCE = "EU"
|
|
@@ -51,7 +51,7 @@ class SeerSDK:
|
|
|
51
51
|
|
|
52
52
|
Examples
|
|
53
53
|
-------
|
|
54
|
-
>>> from
|
|
54
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
55
55
|
>>> seer_sdk = SeerSDK()
|
|
56
56
|
>>> seer_sdk.get_spaces()
|
|
57
57
|
>>> [
|
|
@@ -97,7 +97,7 @@ class SeerSDK:
|
|
|
97
97
|
|
|
98
98
|
Examples
|
|
99
99
|
-------
|
|
100
|
-
>>> from
|
|
100
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
101
101
|
>>> seer_sdk = SeerSDK()
|
|
102
102
|
>>> seer_sdk.get_plate_metadata()
|
|
103
103
|
>>> [
|
|
@@ -170,7 +170,7 @@ class SeerSDK:
|
|
|
170
170
|
|
|
171
171
|
Examples
|
|
172
172
|
-------
|
|
173
|
-
>>> from
|
|
173
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
174
174
|
>>> seer_sdk = SeerSDK()
|
|
175
175
|
>>> seer_sdk.get_project_metadata()
|
|
176
176
|
>>> [
|
|
@@ -263,17 +263,17 @@ class SeerSDK:
|
|
|
263
263
|
|
|
264
264
|
Examples
|
|
265
265
|
-------
|
|
266
|
-
>>> from
|
|
266
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
267
267
|
>>> seer_sdk = SeerSDK()
|
|
268
268
|
|
|
269
|
-
>>> seer_sdk.
|
|
269
|
+
>>> seer_sdk._get_samples_metadata(plate_id="7ec8cad0-15e0-11ee-bdf1-bbaa73585acf")
|
|
270
270
|
>>> [
|
|
271
271
|
{ "id": ... },
|
|
272
272
|
{ "id": ... },
|
|
273
273
|
...
|
|
274
274
|
]
|
|
275
275
|
|
|
276
|
-
>>> seer_sdk.
|
|
276
|
+
>>> seer_sdk._get_samples_metadata(df=True)
|
|
277
277
|
>>> id ... control
|
|
278
278
|
0 812139c0-15e0-11ee-bdf1-bbaa73585acf ...
|
|
279
279
|
1 803e05b0-15e0-11ee-bdf1-bbaa73585acf ... MPE Control
|
|
@@ -332,7 +332,46 @@ class SeerSDK:
|
|
|
332
332
|
for entry in res:
|
|
333
333
|
del entry["tenant_id"]
|
|
334
334
|
|
|
335
|
-
|
|
335
|
+
# Exclude custom fields that don't belong to the tenant
|
|
336
|
+
res_df = dict_to_df(res)
|
|
337
|
+
custom_columns = [
|
|
338
|
+
x["field_name"] for x in self.get_sample_custom_fields()
|
|
339
|
+
]
|
|
340
|
+
res_df = res_df[
|
|
341
|
+
[
|
|
342
|
+
x
|
|
343
|
+
for x in res_df.columns
|
|
344
|
+
if not x.startswith("custom_") or x in custom_columns
|
|
345
|
+
]
|
|
346
|
+
]
|
|
347
|
+
|
|
348
|
+
return res_df.to_dict(orient="records") if not df else res_df
|
|
349
|
+
|
|
350
|
+
def get_sample_custom_fields(self):
|
|
351
|
+
"""
|
|
352
|
+
Fetches a list of custom fields defined for the authenticated user.
|
|
353
|
+
"""
|
|
354
|
+
ID_TOKEN, ACCESS_TOKEN = self._auth.get_token()
|
|
355
|
+
HEADERS = {
|
|
356
|
+
"Authorization": f"{ID_TOKEN}",
|
|
357
|
+
"access-token": f"{ACCESS_TOKEN}",
|
|
358
|
+
}
|
|
359
|
+
URL = f"{self._auth.url}api/v1/samplefields"
|
|
360
|
+
|
|
361
|
+
with requests.Session() as s:
|
|
362
|
+
s.headers.update(HEADERS)
|
|
363
|
+
|
|
364
|
+
fields = s.get(URL)
|
|
365
|
+
|
|
366
|
+
if fields.status_code != 200:
|
|
367
|
+
raise ValueError(
|
|
368
|
+
"Failed to fetch custom columns. Please check your connection."
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
res = fields.json()
|
|
372
|
+
for entry in res:
|
|
373
|
+
del entry["tenant_id"]
|
|
374
|
+
return res
|
|
336
375
|
|
|
337
376
|
def get_msdata(self, sample_ids: list, df: bool = False):
|
|
338
377
|
"""
|
|
@@ -354,7 +393,7 @@ class SeerSDK:
|
|
|
354
393
|
|
|
355
394
|
Examples
|
|
356
395
|
-------
|
|
357
|
-
>>> from
|
|
396
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
358
397
|
>>> seer_sdk = SeerSDK()
|
|
359
398
|
>>> sample_ids = ["812139c0-15e0-11ee-bdf1-bbaa73585acf", "803e05b0-15e0-11ee-bdf1-bbaa73585acf"]
|
|
360
399
|
|
|
@@ -425,7 +464,7 @@ class SeerSDK:
|
|
|
425
464
|
|
|
426
465
|
Examples
|
|
427
466
|
-------
|
|
428
|
-
>>> from
|
|
467
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
429
468
|
>>> seer_sdk = SeerSDK()
|
|
430
469
|
>>> plate_id = "7ec8cad0-15e0-11ee-bdf1-bbaa73585acf"
|
|
431
470
|
|
|
@@ -442,7 +481,7 @@ class SeerSDK:
|
|
|
442
481
|
|
|
443
482
|
[2 rows x 26 columns]
|
|
444
483
|
"""
|
|
445
|
-
plate_samples = self.
|
|
484
|
+
plate_samples = self._get_samples_metadata(plate_id=plate_id)
|
|
446
485
|
sample_ids = [sample["id"] for sample in plate_samples]
|
|
447
486
|
return self.get_msdata(sample_ids, df)
|
|
448
487
|
|
|
@@ -470,7 +509,7 @@ class SeerSDK:
|
|
|
470
509
|
|
|
471
510
|
Examples
|
|
472
511
|
-------
|
|
473
|
-
>>> from
|
|
512
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
474
513
|
>>> seer_sdk = SeerSDK()
|
|
475
514
|
>>> project_id = "7e48e150-8a47-11ed-b382-bf440acece26"
|
|
476
515
|
|
|
@@ -549,7 +588,7 @@ class SeerSDK:
|
|
|
549
588
|
return ValueError("No project ID specified.")
|
|
550
589
|
|
|
551
590
|
sample_ids = []
|
|
552
|
-
project_samples = self.
|
|
591
|
+
project_samples = self._get_samples_metadata(
|
|
553
592
|
project_id=project_id, df=False
|
|
554
593
|
)
|
|
555
594
|
|
|
@@ -610,7 +649,7 @@ class SeerSDK:
|
|
|
610
649
|
|
|
611
650
|
Examples
|
|
612
651
|
-------
|
|
613
|
-
>>> from
|
|
652
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
614
653
|
>>> seer_sdk = SeerSDK()
|
|
615
654
|
>>> seer_sdk.get_analysis_protocols()
|
|
616
655
|
>>> [
|
|
@@ -678,7 +717,13 @@ class SeerSDK:
|
|
|
678
717
|
|
|
679
718
|
return res
|
|
680
719
|
|
|
681
|
-
def get_analysis(
|
|
720
|
+
def get_analysis(
|
|
721
|
+
self,
|
|
722
|
+
analysis_id: str = None,
|
|
723
|
+
folder_id: str = None,
|
|
724
|
+
show_folders=True,
|
|
725
|
+
analysis_only=True,
|
|
726
|
+
):
|
|
682
727
|
"""
|
|
683
728
|
Returns a list of analyses objects for the authenticated user. If no id is provided, returns all analyses for the authenticated user.
|
|
684
729
|
|
|
@@ -687,6 +732,17 @@ class SeerSDK:
|
|
|
687
732
|
analysis_id : str, optional
|
|
688
733
|
ID of the analysis to be fetched, defaulted to None.
|
|
689
734
|
|
|
735
|
+
folder_id : str, optional
|
|
736
|
+
ID of the folder to be fetched, defaulted to None.
|
|
737
|
+
|
|
738
|
+
show_folders : bool, optional
|
|
739
|
+
Mark True if folder contents are to be returned in the response, defaulted to True.
|
|
740
|
+
Will be disabled if an analysis id is provided.
|
|
741
|
+
|
|
742
|
+
analysis_only : bool, optional
|
|
743
|
+
Mark True if only analyses objects are to be returned in the response, defaulted to True.
|
|
744
|
+
If marked false, folder objects will also be included in the response.
|
|
745
|
+
|
|
690
746
|
Returns
|
|
691
747
|
-------
|
|
692
748
|
analyses: dict
|
|
@@ -694,7 +750,7 @@ class SeerSDK:
|
|
|
694
750
|
|
|
695
751
|
Examples
|
|
696
752
|
-------
|
|
697
|
-
>>> from
|
|
753
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
698
754
|
>>> seer_sdk = SeerSDK()
|
|
699
755
|
>>> seer_sdk.get_analysis()
|
|
700
756
|
>>> [
|
|
@@ -718,10 +774,14 @@ class SeerSDK:
|
|
|
718
774
|
with requests.Session() as s:
|
|
719
775
|
s.headers.update(HEADERS)
|
|
720
776
|
|
|
777
|
+
params = {"all": "true"}
|
|
778
|
+
if folder_id:
|
|
779
|
+
params["folder"] = folder_id
|
|
780
|
+
|
|
721
781
|
analyses = s.get(
|
|
722
|
-
f"{URL}/{analysis_id}" if analysis_id else URL,
|
|
723
|
-
params={"all": "true"},
|
|
782
|
+
f"{URL}/{analysis_id}" if analysis_id else URL, params=params
|
|
724
783
|
)
|
|
784
|
+
|
|
725
785
|
if analyses.status_code != 200:
|
|
726
786
|
raise ValueError(
|
|
727
787
|
"Invalid request. Please check your parameters."
|
|
@@ -732,6 +792,7 @@ class SeerSDK:
|
|
|
732
792
|
else:
|
|
733
793
|
res = [analyses.json()["analysis"]]
|
|
734
794
|
|
|
795
|
+
folders = []
|
|
735
796
|
for entry in range(len(res)):
|
|
736
797
|
if "tenant_id" in res[entry]:
|
|
737
798
|
del res[entry]["tenant_id"]
|
|
@@ -739,10 +800,27 @@ class SeerSDK:
|
|
|
739
800
|
if "parameter_file_path" in res[entry]:
|
|
740
801
|
# Simple lambda function to find the third occurrence of '/' in the raw file path
|
|
741
802
|
location = lambda s: len(s) - len(s.split("/", 3)[-1])
|
|
803
|
+
|
|
742
804
|
# Slicing the string from the location
|
|
743
805
|
res[entry]["parameter_file_path"] = res[entry][
|
|
744
806
|
"parameter_file_path"
|
|
745
807
|
][location(res[entry]["parameter_file_path"]) :]
|
|
808
|
+
|
|
809
|
+
if (
|
|
810
|
+
show_folders
|
|
811
|
+
and not analysis_id
|
|
812
|
+
and res[entry]["is_folder"]
|
|
813
|
+
):
|
|
814
|
+
folders.append(res[entry]["id"])
|
|
815
|
+
|
|
816
|
+
# recursive solution to get analyses in folders
|
|
817
|
+
for folder in folders:
|
|
818
|
+
res += self.get_analysis(folder_id=folder)
|
|
819
|
+
|
|
820
|
+
if analysis_only:
|
|
821
|
+
res = [
|
|
822
|
+
analysis for analysis in res if not analysis["is_folder"]
|
|
823
|
+
]
|
|
746
824
|
return res
|
|
747
825
|
|
|
748
826
|
def get_analysis_result(self, analysis_id: str, download_path: str = ""):
|
|
@@ -764,7 +842,7 @@ class SeerSDK:
|
|
|
764
842
|
|
|
765
843
|
Examples
|
|
766
844
|
-------
|
|
767
|
-
>>> from
|
|
845
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
768
846
|
>>> seer_sdk = SeerSDK()
|
|
769
847
|
|
|
770
848
|
>>> seer_sdk.get_analysis_result("YOUR_ANALYSIS_ID_HERE")
|
|
@@ -862,7 +940,7 @@ class SeerSDK:
|
|
|
862
940
|
|
|
863
941
|
Examples
|
|
864
942
|
-------
|
|
865
|
-
>>> from
|
|
943
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
866
944
|
>>> seer_sdk = SeerSDK()
|
|
867
945
|
>>> seer_sdk.analysis_complete("YOUR_ANALYSIS_ID_HERE")
|
|
868
946
|
>>> {
|
|
@@ -898,7 +976,7 @@ class SeerSDK:
|
|
|
898
976
|
|
|
899
977
|
Examples
|
|
900
978
|
-------
|
|
901
|
-
>>> from
|
|
979
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
902
980
|
>>> sdk = SeerSDK()
|
|
903
981
|
>>> folder_path = "test-may-2/"
|
|
904
982
|
>>> sdk.list_ms_data_files(folder_path)
|
|
@@ -1069,7 +1147,7 @@ class SeerSDK:
|
|
|
1069
1147
|
|
|
1070
1148
|
Examples
|
|
1071
1149
|
-------
|
|
1072
|
-
>>> from
|
|
1150
|
+
>>> from seer_pas_sdk import SeerSDK
|
|
1073
1151
|
>>> seer_sdk = SeerSDK()
|
|
1074
1152
|
>>> seer_sdk.group_analysis_results("YOUR_ANALYSIS_ID_HERE")
|
|
1075
1153
|
>>> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: seer-pas-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: SDK for Seer Proteograph Analysis Suite (PAS)
|
|
5
5
|
Home-page: https://github.com/seerbio/seer-pas-sdk
|
|
6
6
|
Author: Agam Jolly
|
|
@@ -12,13 +12,14 @@ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
|
12
12
|
Requires-Python: >=3.6
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE.txt
|
|
15
|
-
Requires-Dist: boto3
|
|
16
|
-
Requires-Dist: botocore
|
|
17
|
-
Requires-Dist: pandas
|
|
18
|
-
Requires-Dist:
|
|
19
|
-
Requires-Dist:
|
|
20
|
-
Requires-Dist:
|
|
21
|
-
Requires-Dist:
|
|
15
|
+
Requires-Dist: boto3==1.26.152
|
|
16
|
+
Requires-Dist: botocore==1.29.152
|
|
17
|
+
Requires-Dist: pandas==2.0.1
|
|
18
|
+
Requires-Dist: numpy<2.0.0,>=1.5.3
|
|
19
|
+
Requires-Dist: PyJWT==2.8.0
|
|
20
|
+
Requires-Dist: python-dotenv==1.0.0
|
|
21
|
+
Requires-Dist: Requests==2.31.0
|
|
22
|
+
Requires-Dist: tqdm==4.65.0
|
|
22
23
|
|
|
23
24
|
# Seer PAS Python SDK
|
|
24
25
|
|
|
@@ -32,3 +33,18 @@ This SDK permits interaction with the Seer Proteograph Analysis Suite using Pyth
|
|
|
32
33
|
```shell
|
|
33
34
|
pip install seer-pas-sdk
|
|
34
35
|
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
To import and set up the SDK:
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from seer_pas_sdk import SeerSDK
|
|
43
|
+
|
|
44
|
+
# Instantiate an SDK object with your credentials:
|
|
45
|
+
sdk = SeerSDK(USERNAME, PASSWORD)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
You can then use the SDK's functions to create, query, or retrieve projects, plates, samples, and analyses.
|
|
49
|
+
|
|
50
|
+
For complete documentation of this SDK, visit [https://seerbio.github.io/seer-pas-sdk/](https://seerbio.github.io/seer-pas-sdk/ "Documentation").
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
seer_pas_sdk/__init__.py,sha256=Ie6atdmdBV-OmdHHXjhrGhdFGXiyP3JKhKrr3hyvSsA,563
|
|
2
2
|
seer_pas_sdk/auth/__init__.py,sha256=DZcbkYel11GvIn-iiutt9UOVfj9URZ_f89QMHhyGfRg,2277
|
|
3
3
|
seer_pas_sdk/common/__init__.py,sha256=QnBup2dT6okt62Yjdhik4DmLf36Ozgv6KybdvFAULaA,12260
|
|
4
|
-
seer_pas_sdk/core/__init__.py,sha256=
|
|
4
|
+
seer_pas_sdk/core/__init__.py,sha256=J8dAiYsvNbc11zN1mgp7KqjHSVPw9CVwI-uc85UHw5s,47488
|
|
5
5
|
seer_pas_sdk/objects/__init__.py,sha256=DosquJu2-XvDjVj4JFKoXa0DBVS8OroYCDeS5Np4U8Q,3693
|
|
6
6
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
tests/conftest.py,sha256=nu5Qu8CHwgJEwFpLQ0iX8e5csz4HGIC2oe50AdkA2Ms,317
|
|
@@ -9,8 +9,8 @@ tests/test_auth.py,sha256=np4XXbEzoSFf-zXKaZQFL4Ry1ehMtjbXtHG3J6D-zzc,933
|
|
|
9
9
|
tests/test_common.py,sha256=3VgHPbeLVJCh8V0kBGMvkhTKMd6sN_eLJF3AgvbyH0I,3433
|
|
10
10
|
tests/test_objects.py,sha256=BcQtE8CbGUAnFlbkwsaJalUV6D8WbdwN2aWiQddh3k4,2521
|
|
11
11
|
tests/test_sdk.py,sha256=ZNfsRAe_YHIXfteVugfkcds_lmYb0emIfDbJz7jpqR4,239
|
|
12
|
-
seer_pas_sdk-0.1.
|
|
13
|
-
seer_pas_sdk-0.1.
|
|
14
|
-
seer_pas_sdk-0.1.
|
|
15
|
-
seer_pas_sdk-0.1.
|
|
16
|
-
seer_pas_sdk-0.1.
|
|
12
|
+
seer_pas_sdk-0.1.2.dist-info/LICENSE.txt,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
|
|
13
|
+
seer_pas_sdk-0.1.2.dist-info/METADATA,sha256=VuuOZGQuA6LaN6MgYSZEHKBJXKRuVZxXNDFLLM63shk,1716
|
|
14
|
+
seer_pas_sdk-0.1.2.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
|
|
15
|
+
seer_pas_sdk-0.1.2.dist-info/top_level.txt,sha256=gMffZ5LfTF87Sr-oiyl-rtY6omfBslYCA2S4DM7YNC8,19
|
|
16
|
+
seer_pas_sdk-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|