pepdbagent


Namepepdbagent JSON
Version 0.7.3 PyPI version JSON
download
home_pagehttps://github.com/pepkit/pepdbagent/
SummaryA python-based database manager for portable encapsulated projects
upload_time2024-02-08 18:28:14
maintainer
docs_urlNone
authorOleksandr Khoroshevskyi <khorosh@virginia.edu>
requires_python
licenseBSD2
keywords project metadata bioinformatics database
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">pepdbagent</h1>

[![PEP compatible](https://pepkit.github.io/img/PEP-compatible-green.svg)](https://pep.databio.org/)
![Run pytests](https://github.com/pepkit/pepdbagent/workflows/Run%20pytests/badge.svg)
[![pypi-badge](https://img.shields.io/pypi/v/pepdbagent?color=%2334D058)](https://pypi.org/project/pepdbagent)
[![pypi-version](https://img.shields.io/pypi/pyversions/pepdbagent.svg?color=%2334D058)](https://pypi.org/project/pepdbagent)
[![Downloads](https://static.pepy.tech/badge/pepdbagent)](https://pepy.tech/project/pepdbagent)
[![Github badge](https://img.shields.io/badge/source-github-354a75?logo=github)](https://github.com/pepkit/pepdbagent)


---

**Documentation**: <a href="https://pep.databio.org" target="_blank">https://pep.databio.org</a>

**Source Code**: <a href="https://github.com/pepkit/pepdbagent" target="_blank">https://github.com/pepkit/pepdbagent</a>

---

`pepdbagent` is a Python library and toolkit that gives a user-friendly 
interface to connect, upload, update and retrieve information from the pep database. This library is designed to work 
with PEPhub, but it can be used for any other purpose.

`pepdbagent` creates a connection to the database and creates table schemas for the PEPhub database if necessary.
Core database is `postgres` database, but it can be easily extended to other relational databases.
To use `pepdbagent`, you need to have a database instance running with its credentials.
If the version of the database schema is not compatible with the version of `pepdbagent`, it will throw an exception.

## Installation
To install `pepdbagent` use this command: 
```
pip install pepdbagent
```
or install the latest version from the GitHub repository:
```
pip install git+https://github.com/pepkit/pepdbagent.git
```

---
## Overview:

The pepdbagent provides a core class called **PEPDatabaseAgent**. This class has 4 modules, divided 
to increase readability, maintainability, and user experience of pepdbagent, which are:

**The `pepdbagent` consists of 6 main modules:**
- <u>Namespace</u>: Includes methods for searching namespaces, retrieving statistics, and fetching information.
- <u>Project</u>: Provides functionality for retrieving, uploading, updating, and managing projects.
- <u>Annotation</u>: Offers features for searching projects in the database and namespaces, retrieving annotations, and other related information.
- <u>Sample</u>: Handles the creation, modification, and deletion of samples, without modification of the entire project.
- <u>View</u>: Manages the creation, modification, and deletion of views for specific projects.
- <u>User</u>: Contains user-related information such as favorites and other user-related data.

## Example:

#### Instiantiate a PEPDatabaseAgent object and connect to database:

```python
import pepdbagent
# 1) By providing credentials and connection information:
agent = pepdbagent.PEPDatabaseAgent(user="postgres", password="docker", )
# 2) or By providing connection string:
agent = pepdbagent.PEPDatabaseAgent(dsn="postgresql://postgres:docker@localhost:5432/pep-db")
```

#### Example of usage of the pepdbagent modules:

```python
import peppy

prj_obj = peppy.Project("sample_pep/basic/project_config.yaml")

# create a project
namespace = "demo"
name = "basic_project"
tag = None
agent.project.create(prj_obj, namespace, name, tag)

update_dict = {"is_private" = True}
# after creation of the dict, update record by providing update_dict and namespace, name and tag:
agent.project.update(update_dict, namespace, name, tag)
```


#### Annotation example:


The `.annotation` module provides an interface to PEP annotations. 
PEP annotations refers to the information *about* the PEPs (or, the PEP metadata). 
Retrieved information contains: [number of samples, submission date, last update date,
is private, PEP description, digest, namespace, name, tag]

```python

```python
# Get annotation of one project:
agent.annotation.get(namespace, name, tag)

# Get annotations of all projects from db:
agent.annotation.get()

# Get annotations of all projects within a given namespace:
agent.annotation.get(namespace='namespace')

# Search for a project with partial string matching, either within namespace or entire database
# This returns a list of projects
agent.annotation.get(query='query')
agent.annotation.get(query='query', namespace='namespace')

# Get annotation of multiple projects given a list of registry paths
agent.annotation.get_by_rp(["namespace1/project1:tag1", "namespace2/project2:tag2"])

# By default get function will retrun annotations for public projects,
# To get annotation including private projects admin list should be provided.
# admin list means list of namespaces where user has admin rights
# For example:
agent.annotation.get(query='search_pattern', admin=['databio', 'ncbi'])
```


#### Namespace
The `.namespace` module contains search namespace functionality that helps to find namespaces in database 
and retrieve information: `number of samples`, `number of projects`.

Example:
```python
# Get info about namespace by providing query argument. Then pepdbagent will
# search for a specified pattern of namespace in database.
agent.namespace.get(query='Namespace')

# By default all get functions will return namespace information for public projects,
# To get information with private projects, admin list should be provided.
# admin list means list of namespaces where user has admin rights
# For example:
agent.namespace.get(query='search_pattern', admin=['databio', 'geo', 'ncbi'])
```
For more information, developers should use `pepdbagent pytest` as documentation due to its natural language syntax and the 
ability to write tests that serve as executable examples. 
This approach not only provides detailed explanations but also ensures that code examples are kept 
up-to-date with the latest changes in the codebase.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pepkit/pepdbagent/",
    "name": "pepdbagent",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "project,metadata,bioinformatics,database",
    "author": "Oleksandr Khoroshevskyi <khorosh@virginia.edu>",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/b0/88/9716a965cb1687bc9499f67268a3d939fd45a2f8707144928674e5173983/pepdbagent-0.7.3.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">pepdbagent</h1>\n\n[![PEP compatible](https://pepkit.github.io/img/PEP-compatible-green.svg)](https://pep.databio.org/)\n![Run pytests](https://github.com/pepkit/pepdbagent/workflows/Run%20pytests/badge.svg)\n[![pypi-badge](https://img.shields.io/pypi/v/pepdbagent?color=%2334D058)](https://pypi.org/project/pepdbagent)\n[![pypi-version](https://img.shields.io/pypi/pyversions/pepdbagent.svg?color=%2334D058)](https://pypi.org/project/pepdbagent)\n[![Downloads](https://static.pepy.tech/badge/pepdbagent)](https://pepy.tech/project/pepdbagent)\n[![Github badge](https://img.shields.io/badge/source-github-354a75?logo=github)](https://github.com/pepkit/pepdbagent)\n\n\n---\n\n**Documentation**: <a href=\"https://pep.databio.org\" target=\"_blank\">https://pep.databio.org</a>\n\n**Source Code**: <a href=\"https://github.com/pepkit/pepdbagent\" target=\"_blank\">https://github.com/pepkit/pepdbagent</a>\n\n---\n\n`pepdbagent` is a Python library and toolkit that gives a user-friendly \ninterface to connect, upload, update and retrieve information from the pep database. This library is designed to work \nwith PEPhub, but it can be used for any other purpose.\n\n`pepdbagent` creates a connection to the database and creates table schemas for the PEPhub database if necessary.\nCore database is `postgres` database, but it can be easily extended to other relational databases.\nTo use `pepdbagent`, you need to have a database instance running with its credentials.\nIf the version of the database schema is not compatible with the version of `pepdbagent`, it will throw an exception.\n\n## Installation\nTo install `pepdbagent` use this command: \n```\npip install pepdbagent\n```\nor install the latest version from the GitHub repository:\n```\npip install git+https://github.com/pepkit/pepdbagent.git\n```\n\n---\n## Overview:\n\nThe pepdbagent provides a core class called **PEPDatabaseAgent**. This class has 4 modules, divided \nto increase readability, maintainability, and user experience of pepdbagent, which are:\n\n**The `pepdbagent` consists of 6 main modules:**\n- <u>Namespace</u>: Includes methods for searching namespaces, retrieving statistics, and fetching information.\n- <u>Project</u>: Provides functionality for retrieving, uploading, updating, and managing projects.\n- <u>Annotation</u>: Offers features for searching projects in the database and namespaces, retrieving annotations, and other related information.\n- <u>Sample</u>: Handles the creation, modification, and deletion of samples, without modification of the entire project.\n- <u>View</u>: Manages the creation, modification, and deletion of views for specific projects.\n- <u>User</u>: Contains user-related information such as favorites and other user-related data.\n\n## Example:\n\n#### Instiantiate a PEPDatabaseAgent object and connect to database:\n\n```python\nimport pepdbagent\n# 1) By providing credentials and connection information:\nagent = pepdbagent.PEPDatabaseAgent(user=\"postgres\", password=\"docker\", )\n# 2) or By providing connection string:\nagent = pepdbagent.PEPDatabaseAgent(dsn=\"postgresql://postgres:docker@localhost:5432/pep-db\")\n```\n\n#### Example of usage of the pepdbagent modules:\n\n```python\nimport peppy\n\nprj_obj = peppy.Project(\"sample_pep/basic/project_config.yaml\")\n\n# create a project\nnamespace = \"demo\"\nname = \"basic_project\"\ntag = None\nagent.project.create(prj_obj, namespace, name, tag)\n\nupdate_dict = {\"is_private\" = True}\n# after creation of the dict, update record by providing update_dict and namespace, name and tag:\nagent.project.update(update_dict, namespace, name, tag)\n```\n\n\n#### Annotation example:\n\n\nThe `.annotation` module provides an interface to PEP annotations. \nPEP annotations refers to the information *about* the PEPs (or, the PEP metadata). \nRetrieved information contains: [number of samples, submission date, last update date,\nis private, PEP description, digest, namespace, name, tag]\n\n```python\n\n```python\n# Get annotation of one project:\nagent.annotation.get(namespace, name, tag)\n\n# Get annotations of all projects from db:\nagent.annotation.get()\n\n# Get annotations of all projects within a given namespace:\nagent.annotation.get(namespace='namespace')\n\n# Search for a project with partial string matching, either within namespace or entire database\n# This returns a list of projects\nagent.annotation.get(query='query')\nagent.annotation.get(query='query', namespace='namespace')\n\n# Get annotation of multiple projects given a list of registry paths\nagent.annotation.get_by_rp([\"namespace1/project1:tag1\", \"namespace2/project2:tag2\"])\n\n# By default get function will retrun annotations for public projects,\n# To get annotation including private projects admin list should be provided.\n# admin list means list of namespaces where user has admin rights\n# For example:\nagent.annotation.get(query='search_pattern', admin=['databio', 'ncbi'])\n```\n\n\n#### Namespace\nThe `.namespace` module contains search namespace functionality that helps to find namespaces in database \nand retrieve information: `number of samples`, `number of projects`.\n\nExample:\n```python\n# Get info about namespace by providing query argument. Then pepdbagent will\n# search for a specified pattern of namespace in database.\nagent.namespace.get(query='Namespace')\n\n# By default all get functions will return namespace information for public projects,\n# To get information with private projects, admin list should be provided.\n# admin list means list of namespaces where user has admin rights\n# For example:\nagent.namespace.get(query='search_pattern', admin=['databio', 'geo', 'ncbi'])\n```\nFor more information, developers should use `pepdbagent pytest` as documentation due to its natural language syntax and the \nability to write tests that serve as executable examples. \nThis approach not only provides detailed explanations but also ensures that code examples are kept \nup-to-date with the latest changes in the codebase.\n",
    "bugtrack_url": null,
    "license": "BSD2",
    "summary": "A python-based database manager for portable encapsulated projects",
    "version": "0.7.3",
    "project_urls": {
        "Homepage": "https://github.com/pepkit/pepdbagent/"
    },
    "split_keywords": [
        "project",
        "metadata",
        "bioinformatics",
        "database"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a5bbe0914405e5d273b537d3f9006c5addb017b57d40d486800f1f78fbceb240",
                "md5": "156223e5e3ed6c56bf8ccb0c90a72975",
                "sha256": "5df9ad4dc7e0f148af16baf685d6e1a3d8f4da9644444994c1ac89adcda44b61"
            },
            "downloads": -1,
            "filename": "pepdbagent-0.7.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "156223e5e3ed6c56bf8ccb0c90a72975",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 38297,
            "upload_time": "2024-02-08T18:28:12",
            "upload_time_iso_8601": "2024-02-08T18:28:12.418323Z",
            "url": "https://files.pythonhosted.org/packages/a5/bb/e0914405e5d273b537d3f9006c5addb017b57d40d486800f1f78fbceb240/pepdbagent-0.7.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b0889716a965cb1687bc9499f67268a3d939fd45a2f8707144928674e5173983",
                "md5": "4b7d841088b838e2fc2c5b8e8d759657",
                "sha256": "5af268e9f4122ae81c2f0000eeea1e8554a59bb73569291c970783940324b635"
            },
            "downloads": -1,
            "filename": "pepdbagent-0.7.3.tar.gz",
            "has_sig": false,
            "md5_digest": "4b7d841088b838e2fc2c5b8e8d759657",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 33852,
            "upload_time": "2024-02-08T18:28:14",
            "upload_time_iso_8601": "2024-02-08T18:28:14.072146Z",
            "url": "https://files.pythonhosted.org/packages/b0/88/9716a965cb1687bc9499f67268a3d939fd45a2f8707144928674e5173983/pepdbagent-0.7.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-08 18:28:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pepkit",
    "github_project": "pepdbagent",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pepdbagent"
}
        
Elapsed time: 0.22794s