Skip to content

Commit

Permalink
Merge pull request #46 from databio/dev
Browse files Browse the repository at this point in the history
release 0.5.0
  • Loading branch information
khoroshevskyi authored Apr 8, 2024
2 parents 3560eb3 + c75d006 commit 6599131
Show file tree
Hide file tree
Showing 47 changed files with 7,607 additions and 1,337 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cli-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: dockerpassword
POSTGRES_DB: pipestat-test
POSTGRES_PASSWORD: docker
POSTGRES_DB: bedbase
POSTGRES_HOST: localhost
ports:
- 5432:5432
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: dockerpassword
POSTGRES_DB: pipestat-test
POSTGRES_PASSWORD: docker
POSTGRES_DB: bedbase
POSTGRES_HOST: localhost
ports:
- 5432:5432
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ include README.md
include LICENSE.txt
include requirements/*
include bbconf/schemas/*
include bbconf/modules/*
include bbconf/config_parser/*
include bbconf/models/*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
## What is this?

`bbconf` is a configuration and management tool for BEDbase, facilitating the reading of configuration files,
setting up connections to PostgreSQL and Qdrant databases, managing file paths, and storing transformer models.
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."

---
Expand Down
6 changes: 4 additions & 2 deletions bbconf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import logging

import coloredlogs

from bbconf.bbconf import BedBaseConf, get_bedbase_cfg
from bbconf.bbagent import BedBaseAgent

from ._version import __version__
from .const import PKG_NAME

__all__ = ["BedBaseConf", "get_bedbase_cfg", "__version__"]
__all__ = ["BedBaseAgent", "__version__"]

_LOGGER = logging.getLogger(PKG_NAME)
coloredlogs.install(
Expand Down
2 changes: 1 addition & 1 deletion bbconf/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.2"
__version__ = "0.5.0"
62 changes: 62 additions & 0 deletions bbconf/bbagent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from pathlib import Path
from typing import Union

from sqlalchemy.orm import Session
from sqlalchemy.sql import distinct, func, select

from bbconf.config_parser.bedbaseconfig import BedBaseConfig
from bbconf.db_utils import Bed, BedSets
from bbconf.models.base_models import StatsReturn
from bbconf.modules.bedfiles import BedAgentBedFile
from bbconf.modules.bedsets import BedAgentBedSet
from bbconf.modules.objects import BBObjects


class BedBaseAgent(object):
def __init__(
self,
config: Union[Path, str],
):
"""
Initialize connection to the pep_db database. You can use The basic connection parameters
or libpq connection string.
"""

self.config = BedBaseConfig(config)

self.__bed = BedAgentBedFile(self.config)
self.__bedset = BedAgentBedSet(self.config)
self.__objects = BBObjects(self.config)

@property
def bed(self) -> BedAgentBedFile:
return self.__bed

@property
def bedset(self) -> BedAgentBedSet:
return self.__bedset

@property
def objects(self) -> BBObjects:
return self.__objects

def get_stats(self) -> StatsReturn:
"""
Get statistics for a bed file
:return: statistics
"""
with Session(self.config.db_engine.engine) as session:
number_of_bed = session.execute(select(func.count(Bed.id))).one()[0]
number_of_bedset = session.execute(select(func.count(BedSets.id))).one()[0]

number_of_genomes = session.execute(
select(func.count(distinct(Bed.genome_alias)))
).one()[0]

return StatsReturn(
bedfiles_number=number_of_bed,
bedsets_number=number_of_bedset,
genomes_number=number_of_genomes,
)
Loading

0 comments on commit 6599131

Please sign in to comment.