Skip to content

Commit

Permalink
Merge pull request #68 from databio/dev
Browse files Browse the repository at this point in the history
Updated bedbase docs
  • Loading branch information
khoroshevskyi authored Apr 15, 2024
2 parents 990a110 + 140691f commit 94ba0d4
Show file tree
Hide file tree
Showing 41 changed files with 627 additions and 41,199 deletions.
2 changes: 1 addition & 1 deletion autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@
with open(out, "w") as stream:
stream.write(md_result)
else:
print("Skipping jupyter notebooks")
print("Skipping jupyter notebooks")
23 changes: 17 additions & 6 deletions ci/scripts/count_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,26 @@

parser = ArgumentParser(description="Count records in a PostgreSQL table and verify")

parser.add_argument("-t", "--table", help="Table to count records in",
required=True, type=str)
parser.add_argument("-e", "--expected-count", help="Expected number of records",
type=int, required=False, default=None)
parser.add_argument(
"-t", "--table", help="Table to count records in", required=True, type=str
)
parser.add_argument(
"-e",
"--expected-count",
help="Expected number of records",
type=int,
required=False,
default=None,
)

args = parser.parse_args()

bbc = BedBaseConf(get_bedbase_cfg('$GITHUB_WORKSPACE/ci/cfg/config_min.yaml'))
bbc = BedBaseConf(get_bedbase_cfg("$GITHUB_WORKSPACE/ci/cfg/config_min.yaml"))
row_count = bbc._count_rows(table_name=args.table)
if args.expected_count:
assert row_count == args.expected_count, "Number of records in the '{}' table ({}) not equal {}".format(args.table, row_count, args.expected_count)
assert (
row_count == args.expected_count
), "Number of records in the '{}' table ({}) not equal {}".format(
args.table, row_count, args.expected_count
)
sys.exit(0)
37 changes: 35 additions & 2 deletions docs/bbconf/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# bbconf
<h1 align="center">bbconf</h1>

![Run pytests](https://github.com/databio/bbconf/workflows/Run%20pytests/badge.svg)
[![pypi-badge](https://img.shields.io/pypi/v/bbconf?color=%2334D058)](https://pypi.org/project/bbconf/)
[![pypi-version](https://img.shields.io/pypi/pyversions/bbconf.svg?color=%2334D058)](https://pypi.org/project/bbconf)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Github badge](https://img.shields.io/badge/source-github-354a75?logo=github)](https://github.com/databio/bbconf)
[![coverage](https://coverage-badge.samuelcolvin.workers.dev/databio/bbconf.svg)](https://coverage-badge.samuelcolvin.workers.dev/redirect/databio/bbconf)


*BEDBASE* project configuration package (agent)

## What is this?

`bbconf` is a configuration and management tool for BEDbase, facilitating the reading of configuration files,
setting up connections to PostgreSQL, PEPhub, S3, and Qdrant databases, managing file paths, and storing transformer models.
It formalizes communication pathways for pipelines and downstream tools, ensuring seamless interaction."

---

**Documentation**: <a href="https://docs.bedbase.org/bedboss" target="_blank">https://docs.bedbase.org/bedboss</a>

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

---

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

`bbconf` defines `BedBaseConf` class which is an in-memory representation of the configuration file for the *BEDBASE* project. This is the source of the project-wide constant variables. Additionally it implements multiple convenience methods for interacting with the database backend, i.e. [PostgreSQL](https://www.postgresql.org/)
192 changes: 1 addition & 191 deletions docs/bbconf/bbc_api.md
Original file line number Diff line number Diff line change
@@ -1,191 +1 @@
Final targets: BedBaseConf, get_bedbase_cfg
<script>
document.addEventListener('DOMContentLoaded', (event) => {
document.querySelectorAll('h3 code').forEach((block) => {
hljs.highlightBlock(block);
});
});
</script>

<style>
h3 .content {
padding-left: 22px;
text-indent: -15px;
}
h3 .hljs .content {
padding-left: 20px;
margin-left: 0px;
text-indent: -15px;
martin-bottom: 0px;
}
h4 .content, table .content, p .content, li .content { margin-left: 30px; }
h4 .content {
font-style: italic;
font-size: 1em;
margin-bottom: 0px;
}

</style>


# Package `bbconf` Documentation

## <a name="BedBaseConf"></a> Class `BedBaseConf`
This class standardizes reporting of bedstat and bedbuncher results. It formalizes a way for these pipelines and downstream tools to communicate -- the produced results can easily and reliably become an input for the server. The object exposes API for interacting with the results and is backed by a [PostgreSQL](https://www.postgresql.org/) database.


```python
def __init__(self, config_path=None, database_only=False)
```

Initialize the object
#### Parameters:

- `config_path` (`str`): path to the bedbase configuration file
- `database_only` (`bool`): whether the database managers should notkeep an in-memory copy of the data in the database




```python
def bed(self)
```

PipestatManager of the bedfiles table
#### Returns:

- `pipestat.PipestatManager`: manager of the bedfiles table




```python
def bedset(self)
```

PipestatManager of the bedsets table
#### Returns:

- `pipestat.PipestatManager`: manager of the bedsets table




```python
def config(self)
```

Config used to initialize the object
#### Returns:

- `yacman.YacAttMap`: bedbase configuration file contents




```python
def get_bedbuncher_output_path(self, remote=False)
```

Get path to the output of the bedbuncher pipeline
#### Parameters:

- `remote` (`bool`): whether to use remote url base


#### Returns:

- `str`: path to the bedbuncher pipeline output




```python
def get_bedstat_output_path(self, remote=False)
```

Get path to the output of the bedstat pipeline
#### Parameters:

- `remote` (`bool`): whether to use remote url base


#### Returns:

- `str`: path to the bedstat pipeline output




```python
def remove_relationship(self, bedset_id, bedfile_ids=None)
```

Remove entries from the relationships table
#### Parameters:

- `bedset_id` (`str`): id of the bedset to remove
- `bedfile_ids` (`list[str]`): ids of the bedfiles to remove for theselected bedset. If none provided, all the relationsips for the selected bedset will be removed.




```python
def report_relationship(self, bedset_id, bedfile_id)
```

Report a bedfile for bedset.

Inserts the ID pair into the relationship table, which allows to
manage many to many bedfile bedset relationships
#### Parameters:

- `bedset_id` (`int`): id of the bedset to report bedfile for
- `bedfile_id` (`int`): id of the bedfile to report




```python
def select_bedfiles_for_bedset(self, condition=None, condition_val=None, bedfile_col=None)
```

Select bedfiles that are part of a bedset that matches the query
#### Parameters:

- `condition` (`str`): bedsets table query to restrict the results with,for instance `"id=%s"`
- `condition_val` (`list[str]`): values to populate the condition stringwith
- `bedfile_col` (`list[str] | str`): bedfile columns to include in theresult, if none specified all columns will be included


#### Returns:

- `list[psycopg2.extras.DictRow]`: matched bedfiles table contents




```python
def get_bedbase_cfg(cfg=None)
```

Determine path to the bedbase configuration file

The path can be either explicitly provided
or read from a $BEDBASE environment variable
#### Parameters:

- `cfg` (`str`): path to the config file.Optional, the $BEDBASE config env var will be used if not provided


#### Returns:

- `str`: configuration file path







*Version Information: `bbconf` v0.1.0, generated by `lucidoc` v0.4.3*
### 🚧 Docs in progress! Stay tuned for updates. We're working hard to bring you valuable content soon!
39 changes: 36 additions & 3 deletions docs/bbconf/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,45 @@

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format.

## [0.4.0] - 2023-10-17
# [0.5.1] - 2024-04-09
## Changed

- updated qdrant uploader
- bedset bedfile list query improvement
- other minor fixes in uploading

# [0.5.0] - 2024-04-08
### Changed

- Rebuild bbconf
- Introduced new DB schema
- Added bbagent that will be used to interact with the database
- Updated config schema
- Added new functionality to the bbagent
- New tests


## [0.4.2] - 2024-03-12
### Change
- Updated logger
- Updated requirements
- Added `upload_status` column to the `bedfile` table


## [0.4.1] - 2024-01-01
### Fix
- Requirements


## [0.4.0] - 2023-12-18
### Change
- bbconf to use pipestat v0.4.1 and SQLModel
- Added qdrant search, and insert methods
- bbconf to use pipestat v0.6.0 and SQLModel
- Fixed tests

### Added
- `qdrant` search, insert and update functionality
- functions that return results in the DRS format for both bed and bedhost. [DRS](https://ga4gh.github.io/data-repository-service-schemas/preview/release/drs-1.2.0/docs/)

## [0.3.0] - 2022-08-18
### Change
- update select_bedfiles_for_distance
Expand Down
Loading

0 comments on commit 94ba0d4

Please sign in to comment.