seer-pas-sdk 0.3.0__tar.gz → 0.3.2__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.
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/PKG-INFO +1 -1
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk/core/sdk.py +154 -28
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk.egg-info/PKG-INFO +1 -1
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/.github/workflows/lint.yml +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/.github/workflows/publish.yml +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/.github/workflows/test.yml +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/.gitignore +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/.pre-commit-config.yaml +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/LICENSE.txt +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/README.md +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/docs/_quarto.yml +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/docs/index.qmd +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/pyproject.toml +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk/__init__.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk/auth/__init__.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk/auth/auth.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk/common/__init__.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk/common/errors.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk/common/groupanalysis.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk/core/__init__.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk/core/unsupported.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk/objects/__init__.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk/objects/groupanalysis.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk/objects/platemap.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk/objects/volcanoplot.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk.egg-info/SOURCES.txt +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk.egg-info/dependency_links.txt +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk.egg-info/requires.txt +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/seer_pas_sdk.egg-info/top_level.txt +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/setup.cfg +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/tests/__init__.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/tests/conftest.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/tests/objects/__init__.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/tests/objects/test_platemap.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/tests/test_auth.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/tests/test_common.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/tests/test_objects.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/tests/test_sdk.py +0 -0
- {seer_pas_sdk-0.3.0 → seer_pas_sdk-0.3.2}/tests/unsupported_platemap.py +0 -0
|
@@ -114,11 +114,11 @@ class SeerSDK:
|
|
|
114
114
|
tenants : dict[str, str]
|
|
115
115
|
A dictionary containing the institution names and tenant ids for the authenticated user.
|
|
116
116
|
"""
|
|
117
|
-
tenants = self.get_user_tenant()
|
|
117
|
+
tenants = self.get_user_tenant(index=False)
|
|
118
118
|
if reverse:
|
|
119
|
-
return {x["tenantId"]: x["institution"] for x in tenants
|
|
119
|
+
return {x["tenantId"]: x["institution"] for x in tenants}
|
|
120
120
|
else:
|
|
121
|
-
return {x["institution"]: x["tenantId"] for x in tenants
|
|
121
|
+
return {x["institution"]: x["tenantId"] for x in tenants}
|
|
122
122
|
|
|
123
123
|
def switch_tenant(self, identifier: str):
|
|
124
124
|
"""
|
|
@@ -251,7 +251,9 @@ class SeerSDK:
|
|
|
251
251
|
)
|
|
252
252
|
return spaces.json()
|
|
253
253
|
|
|
254
|
-
def get_plates(
|
|
254
|
+
def get_plates(
|
|
255
|
+
self, plate_id: str = None, plate_name: str = None, as_df: bool = False
|
|
256
|
+
):
|
|
255
257
|
"""
|
|
256
258
|
Fetches a list of plates for the authenticated user. If no `plate_id` is provided, returns all plates for the authenticated user. If `plate_id` is provided, returns the plate with the given `plate_id`, provided it exists.
|
|
257
259
|
|
|
@@ -298,11 +300,18 @@ class SeerSDK:
|
|
|
298
300
|
URL = f"{self._auth.url}api/v1/plates"
|
|
299
301
|
res = []
|
|
300
302
|
|
|
303
|
+
if not plate_id and not plate_name:
|
|
304
|
+
params = {"all": "true"}
|
|
305
|
+
elif plate_name:
|
|
306
|
+
params = {"searchFields": "plate_name", "searchItem": plate_name}
|
|
307
|
+
else:
|
|
308
|
+
params = dict()
|
|
309
|
+
|
|
301
310
|
with self._get_auth_session() as s:
|
|
302
311
|
|
|
303
312
|
plates = s.get(
|
|
304
313
|
f"{URL}/{plate_id}" if plate_id else URL,
|
|
305
|
-
params=
|
|
314
|
+
params=params,
|
|
306
315
|
)
|
|
307
316
|
if plates.status_code != 200:
|
|
308
317
|
raise ValueError(
|
|
@@ -318,7 +327,12 @@ class SeerSDK:
|
|
|
318
327
|
|
|
319
328
|
return res if not as_df else dict_to_df(res)
|
|
320
329
|
|
|
321
|
-
def get_projects(
|
|
330
|
+
def get_projects(
|
|
331
|
+
self,
|
|
332
|
+
project_id: str = None,
|
|
333
|
+
project_name: str = None,
|
|
334
|
+
as_df: bool = False,
|
|
335
|
+
):
|
|
322
336
|
"""
|
|
323
337
|
Fetches a list of projects for the authenticated user. If no `project_id` is provided, returns all projects for the authenticated user. If `project_id` is provided, returns the project with the given `project_id`, provided it exists.
|
|
324
338
|
|
|
@@ -365,22 +379,31 @@ class SeerSDK:
|
|
|
365
379
|
|
|
366
380
|
URL = (
|
|
367
381
|
f"{self._auth.url}api/v1/projects"
|
|
368
|
-
if not project_id
|
|
369
|
-
else f"{self._auth.url}api/v1/projects/{project_id}"
|
|
382
|
+
# if not project_id
|
|
383
|
+
# else f"{self._auth.url}api/v1/projects/{project_id}"
|
|
370
384
|
)
|
|
371
385
|
res = []
|
|
386
|
+
if not project_id and not project_name:
|
|
387
|
+
params = {"all": "true"}
|
|
388
|
+
elif project_name:
|
|
389
|
+
params = {
|
|
390
|
+
"searchFields": "project_name",
|
|
391
|
+
"searchItem": project_name,
|
|
392
|
+
}
|
|
393
|
+
else:
|
|
394
|
+
params = {"searchFields": "id", "searchItem": project_id}
|
|
372
395
|
|
|
373
396
|
with self._get_auth_session() as s:
|
|
374
397
|
|
|
375
|
-
projects = s.get(URL, params=
|
|
398
|
+
projects = s.get(URL, params=params)
|
|
376
399
|
if projects.status_code != 200:
|
|
377
400
|
raise ValueError(
|
|
378
401
|
"Invalid request. Please check your parameters."
|
|
379
402
|
)
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
403
|
+
res = projects.json()["data"]
|
|
404
|
+
|
|
405
|
+
if project_id and not res:
|
|
406
|
+
raise ValueError("Project ID is invalid.")
|
|
384
407
|
|
|
385
408
|
for entry in res:
|
|
386
409
|
if "tenant_id" in entry:
|
|
@@ -679,6 +702,7 @@ class SeerSDK:
|
|
|
679
702
|
self,
|
|
680
703
|
analysis_protocol_name: str = None,
|
|
681
704
|
analysis_protocol_id: str = None,
|
|
705
|
+
as_df: bool = False,
|
|
682
706
|
):
|
|
683
707
|
"""
|
|
684
708
|
Fetches a list of analysis protocols for the authenticated user. If no `analysis_protocol_id` is provided, returns all analysis protocols for the authenticated user. If `analysis_protocol_name` (and no `analysis_protocol_id`) is provided, returns the analysis protocol with the given name, provided it exists.
|
|
@@ -691,6 +715,8 @@ class SeerSDK:
|
|
|
691
715
|
analysis_protocol_name : str, optional
|
|
692
716
|
Name of the analysis protocol to be fetched, defaulted to None.
|
|
693
717
|
|
|
718
|
+
as_df : bool, optional
|
|
719
|
+
whether the result should be converted to a DataFrame, defaulted to False.
|
|
694
720
|
Returns
|
|
695
721
|
-------
|
|
696
722
|
protocols: list[dict]
|
|
@@ -724,32 +750,41 @@ class SeerSDK:
|
|
|
724
750
|
else f"{self._auth.url}api/v1/analysisProtocols/{analysis_protocol_id}"
|
|
725
751
|
)
|
|
726
752
|
res = []
|
|
753
|
+
params = {"all": "true"}
|
|
754
|
+
|
|
755
|
+
if analysis_protocol_name:
|
|
756
|
+
params.update(
|
|
757
|
+
{
|
|
758
|
+
"searchFields": "analysis_protocol_name,offering_name",
|
|
759
|
+
"searchItem": analysis_protocol_name,
|
|
760
|
+
}
|
|
761
|
+
)
|
|
727
762
|
|
|
728
763
|
with self._get_auth_session() as s:
|
|
729
764
|
|
|
730
|
-
protocols = s.get(URL, params=
|
|
765
|
+
protocols = s.get(URL, params=params)
|
|
731
766
|
if protocols.status_code != 200:
|
|
732
767
|
raise ValueError(
|
|
733
768
|
"Invalid request. Please check your parameters."
|
|
734
769
|
)
|
|
735
|
-
if
|
|
736
|
-
res = protocols.json()["data"]
|
|
737
|
-
|
|
738
|
-
if analysis_protocol_id and not analysis_protocol_name:
|
|
770
|
+
if analysis_protocol_id:
|
|
739
771
|
res = [protocols.json()]
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
res = [
|
|
743
|
-
protocol
|
|
744
|
-
for protocol in protocols.json()["data"]
|
|
745
|
-
if protocol["analysis_protocol_name"]
|
|
746
|
-
== analysis_protocol_name
|
|
747
|
-
]
|
|
772
|
+
else:
|
|
773
|
+
res = protocols.json()["data"]
|
|
748
774
|
|
|
749
775
|
for entry in range(len(res)):
|
|
750
776
|
if "tenant_id" in res[entry]:
|
|
751
777
|
del res[entry]["tenant_id"]
|
|
752
778
|
|
|
779
|
+
if "can_edit" in res[entry]:
|
|
780
|
+
del res[entry]["can_edit"]
|
|
781
|
+
|
|
782
|
+
if "can_delete" in res[entry]:
|
|
783
|
+
del res[entry]["can_delete"]
|
|
784
|
+
|
|
785
|
+
if "scope" in res[entry]:
|
|
786
|
+
del res[entry]["scope"]
|
|
787
|
+
|
|
753
788
|
if "parameter_file_path" in res[entry]:
|
|
754
789
|
# Simple lambda function to find the third occurrence of '/' in the raw file path
|
|
755
790
|
location = lambda s: len(s) - len(s.split("/", 3)[-1])
|
|
@@ -758,7 +793,7 @@ class SeerSDK:
|
|
|
758
793
|
"parameter_file_path"
|
|
759
794
|
][location(res[entry]["parameter_file_path"]) :]
|
|
760
795
|
|
|
761
|
-
return res
|
|
796
|
+
return res if not as_df else dict_to_df(res)
|
|
762
797
|
|
|
763
798
|
def get_analyses(
|
|
764
799
|
self,
|
|
@@ -768,6 +803,7 @@ class SeerSDK:
|
|
|
768
803
|
analysis_only: bool = True,
|
|
769
804
|
project_id: str = None,
|
|
770
805
|
plate_name: str = None,
|
|
806
|
+
as_df=False,
|
|
771
807
|
**kwargs,
|
|
772
808
|
):
|
|
773
809
|
"""
|
|
@@ -797,6 +833,9 @@ class SeerSDK:
|
|
|
797
833
|
plate_name : str, optional
|
|
798
834
|
Name of the plate to be fetched, defaulted to None.
|
|
799
835
|
|
|
836
|
+
as_df : bool, optional
|
|
837
|
+
whether the result should be converted to a DataFrame, defaulted to False.
|
|
838
|
+
|
|
800
839
|
**kwargs : dict, optional
|
|
801
840
|
Search keyword parameters to be passed in. Acceptable values are 'analysis_name', 'folder_name', 'analysis_protocol_name', 'description', 'notes', or 'number_msdatafile'.
|
|
802
841
|
|
|
@@ -920,7 +959,7 @@ class SeerSDK:
|
|
|
920
959
|
res = [
|
|
921
960
|
analysis for analysis in res if not analysis["is_folder"]
|
|
922
961
|
]
|
|
923
|
-
return res
|
|
962
|
+
return res if not as_df else dict_to_df(res)
|
|
924
963
|
|
|
925
964
|
@deprecation.deprecated(deprecated_in="0.3.0", removed_in="1.0.0")
|
|
926
965
|
def get_analysis_result_protein_data(
|
|
@@ -1657,6 +1696,93 @@ class SeerSDK:
|
|
|
1657
1696
|
|
|
1658
1697
|
return {"status": res[0]["status"]}
|
|
1659
1698
|
|
|
1699
|
+
def get_protein_results_table(
|
|
1700
|
+
self,
|
|
1701
|
+
analysis_id: str = None,
|
|
1702
|
+
analysis_name: str = None,
|
|
1703
|
+
grouping: str = "condition",
|
|
1704
|
+
as_df=False,
|
|
1705
|
+
):
|
|
1706
|
+
"""Fetches the protein results table for a given analysis ID or analysis name.
|
|
1707
|
+
|
|
1708
|
+
Args:
|
|
1709
|
+
analysis_id (str, optional): id of the analysis. Defaults to None.
|
|
1710
|
+
analysis_name (str, optional): name of the analysis. Defaults to None.
|
|
1711
|
+
grouping (str, optional): group criteria of table result. Defaults to "condition".
|
|
1712
|
+
as_df (bool, optional): . Defaults to False.
|
|
1713
|
+
|
|
1714
|
+
Raises:
|
|
1715
|
+
ValueError: neither name or id were provided for an analysis.
|
|
1716
|
+
ServerError: the request to the server was not successful.
|
|
1717
|
+
|
|
1718
|
+
Returns:
|
|
1719
|
+
list[dict] | pd.DataFrame: data from the protein results table.
|
|
1720
|
+
"""
|
|
1721
|
+
if not analysis_name and not analysis_id:
|
|
1722
|
+
raise ValueError(
|
|
1723
|
+
"Please provide either analysis name or analysis id."
|
|
1724
|
+
)
|
|
1725
|
+
|
|
1726
|
+
if not analysis_id and analysis_name:
|
|
1727
|
+
analysis_id = self.get_analyses(analysis_name=analysis_name)[0][
|
|
1728
|
+
"id"
|
|
1729
|
+
]
|
|
1730
|
+
|
|
1731
|
+
URL = self._auth.url + "api/v2/groupanalysis/protein"
|
|
1732
|
+
with self._get_auth_session() as s:
|
|
1733
|
+
res = s.post(
|
|
1734
|
+
URL, json={"analysisId": analysis_id, "grouping": grouping}
|
|
1735
|
+
)
|
|
1736
|
+
if res.status_code != 200:
|
|
1737
|
+
raise ServerError(
|
|
1738
|
+
"Could not fetch protein results table. Please verify that your analysis completed."
|
|
1739
|
+
)
|
|
1740
|
+
return dict_to_df(res.json()) if as_df else res.json()
|
|
1741
|
+
|
|
1742
|
+
def get_peptide_results_table(
|
|
1743
|
+
self,
|
|
1744
|
+
analysis_id: str = None,
|
|
1745
|
+
analysis_name: str = None,
|
|
1746
|
+
grouping: str = "condition",
|
|
1747
|
+
as_df=False,
|
|
1748
|
+
):
|
|
1749
|
+
"""Fetches the peptide results table for a given analysis ID or analysis name.
|
|
1750
|
+
|
|
1751
|
+
Args:
|
|
1752
|
+
analysis_id (str, optional): id of the analysis. Defaults to None.
|
|
1753
|
+
analysis_name (str, optional): name of the analysis. Defaults to None.
|
|
1754
|
+
grouping (str, optional): group criteria of table results. Defaults to "condition".
|
|
1755
|
+
as_df (bool, optional): whether the result should be converted to a DataFrame, defaulted to False.
|
|
1756
|
+
|
|
1757
|
+
|
|
1758
|
+
Raises:
|
|
1759
|
+
ValueError: neither name or id were provided for an analysis.
|
|
1760
|
+
ServerError: the request to the server was not successful.
|
|
1761
|
+
|
|
1762
|
+
Returns:
|
|
1763
|
+
list[dict] | pd.DataFrame: data from the peptide results table.
|
|
1764
|
+
"""
|
|
1765
|
+
if not analysis_name and not analysis_id:
|
|
1766
|
+
raise ValueError(
|
|
1767
|
+
"Please provide either analysis name or analysis id."
|
|
1768
|
+
)
|
|
1769
|
+
|
|
1770
|
+
if not analysis_id and analysis_name:
|
|
1771
|
+
analysis_id = self.get_analyses(analysis_name=analysis_name)[0][
|
|
1772
|
+
"id"
|
|
1773
|
+
]
|
|
1774
|
+
|
|
1775
|
+
URL = self._auth.url + "api/v2/groupanalysis/peptide"
|
|
1776
|
+
with self._get_auth_session() as s:
|
|
1777
|
+
res = s.post(
|
|
1778
|
+
URL, json={"analysisId": analysis_id, "grouping": grouping}
|
|
1779
|
+
)
|
|
1780
|
+
if res.status_code != 200:
|
|
1781
|
+
raise ServerError(
|
|
1782
|
+
"Could not fetch protein results table. Please verify that your analysis completed."
|
|
1783
|
+
)
|
|
1784
|
+
return dict_to_df(res.json()) if as_df else res.json()
|
|
1785
|
+
|
|
1660
1786
|
def list_ms_data_files(self, folder="", space=None):
|
|
1661
1787
|
"""
|
|
1662
1788
|
Lists all the MS data files in the given folder as long as the folder path passed in the params is valid.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|