seer-pas-sdk 0.3.1__tar.gz → 0.3.3__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.
Files changed (39) hide show
  1. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/PKG-INFO +1 -1
  2. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk/core/sdk.py +143 -8
  3. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk.egg-info/PKG-INFO +1 -1
  4. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/.github/workflows/lint.yml +0 -0
  5. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/.github/workflows/publish.yml +0 -0
  6. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/.github/workflows/test.yml +0 -0
  7. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/.gitignore +0 -0
  8. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/.pre-commit-config.yaml +0 -0
  9. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/LICENSE.txt +0 -0
  10. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/README.md +0 -0
  11. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/docs/_quarto.yml +0 -0
  12. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/docs/index.qmd +0 -0
  13. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/pyproject.toml +0 -0
  14. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk/__init__.py +0 -0
  15. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk/auth/__init__.py +0 -0
  16. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk/auth/auth.py +0 -0
  17. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk/common/__init__.py +0 -0
  18. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk/common/errors.py +0 -0
  19. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk/common/groupanalysis.py +0 -0
  20. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk/core/__init__.py +0 -0
  21. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk/core/unsupported.py +0 -0
  22. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk/objects/__init__.py +0 -0
  23. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk/objects/groupanalysis.py +0 -0
  24. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk/objects/platemap.py +0 -0
  25. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk/objects/volcanoplot.py +0 -0
  26. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk.egg-info/SOURCES.txt +0 -0
  27. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk.egg-info/dependency_links.txt +0 -0
  28. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk.egg-info/requires.txt +0 -0
  29. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/seer_pas_sdk.egg-info/top_level.txt +0 -0
  30. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/setup.cfg +0 -0
  31. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/tests/__init__.py +0 -0
  32. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/tests/conftest.py +0 -0
  33. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/tests/objects/__init__.py +0 -0
  34. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/tests/objects/test_platemap.py +0 -0
  35. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/tests/test_auth.py +0 -0
  36. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/tests/test_common.py +0 -0
  37. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/tests/test_objects.py +0 -0
  38. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/tests/test_sdk.py +0 -0
  39. {seer_pas_sdk-0.3.1 → seer_pas_sdk-0.3.3}/tests/unsupported_platemap.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seer-pas-sdk
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: SDK for Seer Proteograph Analysis Suite (PAS)
5
5
  Author-email: Ryan Sun <rsun@seer.bio>
6
6
  License:
@@ -379,8 +379,8 @@ class SeerSDK:
379
379
 
380
380
  URL = (
381
381
  f"{self._auth.url}api/v1/projects"
382
- if not project_id
383
- 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}"
384
384
  )
385
385
  res = []
386
386
  if not project_id and not project_name:
@@ -391,7 +391,7 @@ class SeerSDK:
391
391
  "searchItem": project_name,
392
392
  }
393
393
  else:
394
- params = dict()
394
+ params = {"searchFields": "id", "searchItem": project_id}
395
395
 
396
396
  with self._get_auth_session() as s:
397
397
 
@@ -400,10 +400,10 @@ class SeerSDK:
400
400
  raise ValueError(
401
401
  "Invalid request. Please check your parameters."
402
402
  )
403
- if not project_id:
404
- res = projects.json()["data"]
405
- else:
406
- res = [projects.json()]
403
+ res = projects.json()["data"]
404
+
405
+ if project_id and not res:
406
+ raise ValueError("Project ID is invalid.")
407
407
 
408
408
  for entry in res:
409
409
  if "tenant_id" in entry:
@@ -803,6 +803,7 @@ class SeerSDK:
803
803
  analysis_only: bool = True,
804
804
  project_id: str = None,
805
805
  plate_name: str = None,
806
+ as_df=False,
806
807
  **kwargs,
807
808
  ):
808
809
  """
@@ -832,6 +833,9 @@ class SeerSDK:
832
833
  plate_name : str, optional
833
834
  Name of the plate to be fetched, defaulted to None.
834
835
 
836
+ as_df : bool, optional
837
+ whether the result should be converted to a DataFrame, defaulted to False.
838
+
835
839
  **kwargs : dict, optional
836
840
  Search keyword parameters to be passed in. Acceptable values are 'analysis_name', 'folder_name', 'analysis_protocol_name', 'description', 'notes', or 'number_msdatafile'.
837
841
 
@@ -955,7 +959,7 @@ class SeerSDK:
955
959
  res = [
956
960
  analysis for analysis in res if not analysis["is_folder"]
957
961
  ]
958
- return res
962
+ return res if not as_df else dict_to_df(res)
959
963
 
960
964
  @deprecation.deprecated(deprecated_in="0.3.0", removed_in="1.0.0")
961
965
  def get_analysis_result_protein_data(
@@ -1692,6 +1696,137 @@ class SeerSDK:
1692
1696
 
1693
1697
  return {"status": res[0]["status"]}
1694
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
+ res = dict_to_df(res.json())
1741
+ res.rename(
1742
+ columns={
1743
+ "proteinId": "uniprot_id",
1744
+ "n": "n_samples",
1745
+ "bp": "biological_process",
1746
+ "mf": "molecular_function",
1747
+ "cc": "cellular_component",
1748
+ "nFrac": "fraction_samples",
1749
+ "proteinNames": "protein_name",
1750
+ "geneName": "gene_name",
1751
+ },
1752
+ inplace=True,
1753
+ )
1754
+
1755
+ res.drop(
1756
+ columns=[
1757
+ "median_undefined",
1758
+ "n_undefined",
1759
+ "n_null",
1760
+ "median_null",
1761
+ ],
1762
+ inplace=True,
1763
+ errors="ignore",
1764
+ )
1765
+ return res if as_df else res.to_dict(orient="records")
1766
+
1767
+ def get_peptide_results_table(
1768
+ self,
1769
+ analysis_id: str = None,
1770
+ analysis_name: str = None,
1771
+ grouping: str = "condition",
1772
+ as_df=False,
1773
+ ):
1774
+ """Fetches the peptide results table for a given analysis ID or analysis name.
1775
+
1776
+ Args:
1777
+ analysis_id (str, optional): id of the analysis. Defaults to None.
1778
+ analysis_name (str, optional): name of the analysis. Defaults to None.
1779
+ grouping (str, optional): group criteria of table results. Defaults to "condition".
1780
+ as_df (bool, optional): whether the result should be converted to a DataFrame, defaulted to False.
1781
+
1782
+
1783
+ Raises:
1784
+ ValueError: neither name or id were provided for an analysis.
1785
+ ServerError: the request to the server was not successful.
1786
+
1787
+ Returns:
1788
+ list[dict] | pd.DataFrame: data from the peptide results table.
1789
+ """
1790
+ if not analysis_name and not analysis_id:
1791
+ raise ValueError(
1792
+ "Please provide either analysis name or analysis id."
1793
+ )
1794
+
1795
+ if not analysis_id and analysis_name:
1796
+ analysis_id = self.get_analyses(analysis_name=analysis_name)[0][
1797
+ "id"
1798
+ ]
1799
+
1800
+ URL = self._auth.url + "api/v2/groupanalysis/peptide"
1801
+ with self._get_auth_session() as s:
1802
+ res = s.post(
1803
+ URL, json={"analysisId": analysis_id, "grouping": grouping}
1804
+ )
1805
+ if res.status_code != 200:
1806
+ raise ServerError(
1807
+ "Could not fetch peptide results table. Please verify that your analysis completed."
1808
+ )
1809
+ res = dict_to_df(res.json())
1810
+ res.rename(
1811
+ columns={
1812
+ "proteinId": "uniprot_id",
1813
+ "n": "n_samples",
1814
+ "bp": "biological_process",
1815
+ "mf": "molecular_function",
1816
+ "cc": "cellular_component",
1817
+ "nFrac": "fraction_samples",
1818
+ "proteinNames": "protein_name",
1819
+ "geneName": "gene_name",
1820
+ },
1821
+ inplace=True,
1822
+ )
1823
+
1824
+ res.drop(columns=["n_undefined"], inplace=True, errors="ignore")
1825
+ res.drop(
1826
+ columns=["median_undefined"], inplace=True, errors="ignore"
1827
+ )
1828
+ return res if as_df else res.to_dict(orient="records")
1829
+
1695
1830
  def list_ms_data_files(self, folder="", space=None):
1696
1831
  """
1697
1832
  Lists all the MS data files in the given folder as long as the folder path passed in the params is valid.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seer-pas-sdk
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: SDK for Seer Proteograph Analysis Suite (PAS)
5
5
  Author-email: Ryan Sun <rsun@seer.bio>
6
6
  License:
File without changes
File without changes
File without changes
File without changes