Skip to content

Commit

Permalink
Merge pull request #24 from databio/pipestat_060_update
Browse files Browse the repository at this point in the history
adjust get_orm to get_model, update version number
  • Loading branch information
khoroshevskyi authored Oct 4, 2023
2 parents 847942c + 6065901 commit 2d81835
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 34 deletions.
2 changes: 1 addition & 1 deletion bbconf/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.0a2"
__version__ = "0.4.0a3"
5 changes: 3 additions & 2 deletions bbconf/bbconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

_LOGGER = getLogger(PKG_NAME)


class BedBaseConf:
"""
This class standardizes reporting of bedstat and bedbuncher results.
Expand Down Expand Up @@ -399,14 +400,14 @@ def BedfileORM(self) -> SQLModel:
"""
return: ORM of bedfile table (SQLModelMetaclass)
"""
return self.bed.backend.get_orm("bedfile__sample")
return self.bed.backend.get_model("bedfile__sample")

@property
def BedsetORM(self) -> SQLModel:
"""
return: ORM of bedset table (SQLModelMetaclass)
"""
return self.bedset.backend.get_orm("bedsets__sample")
return self.bedset.backend.get_model("bedsets__sample")

@property
def t2bsi(self) -> text2bednn.Text2BEDSearchInterface:
Expand Down
2 changes: 1 addition & 1 deletion bbconf/schemas/bedfiles_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ samples:
type: image
label: GC_content
description: GC content plot
paritions:
partitions:
type: image
label: Regions_dist_partitions
description: Regions distribution over genomic partitions plot
Expand Down
3 changes: 2 additions & 1 deletion requirements/requirements-all.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
logmuse
yacman>=0.9.1
pipestat>=0.4.0
pipestat>=0.6.0a1
sqlalchemy<2.0.0
qdrant_client
# geniml
2 changes: 1 addition & 1 deletion requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pipestat>=0.4.0

56 changes: 28 additions & 28 deletions tests/test_bbconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,31 @@ def test_data_insert(self, cfg_pth, test_data_bed, test_data_bedset):
bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
# bedfiles table
ori_cnt = bbc.bed.record_count
bbc.bed.report(sample_name="bed1", values=test_data_bed)
bbc.bed.report(record_identifier="bed1", values=test_data_bed)
assert ori_cnt + 1 == bbc.bed.record_count
# bedsets table
ori_cnt = bbc.bedset.record_count
bbc.bedset.report(sample_name="bedset1", values=test_data_bedset)
bbc.bedset.report(record_identifier="bedset1", values=test_data_bedset)
assert ori_cnt + 1 == bbc.bedset.record_count

def test_nonunique_digest_insert_error(
self, cfg_pth, test_data_bed, test_data_bedset
):
with ContextManagerDBTesting(DB_URL):
bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
bbc.bed.report(sample_name="bed1", values=test_data_bed)
assert not bbc.bed.report(sample_name="bed1", values=test_data_bed)
bbc.bedset.report(sample_name="bedset1", values=test_data_bedset)
assert not bbc.bedset.report(sample_name="bedset1", values=test_data_bedset)
bbc.bed.report(record_identifier="bed1", values=test_data_bed)
assert not bbc.bed.report(record_identifier="bed1", values=test_data_bed)
bbc.bedset.report(record_identifier="bedset1", values=test_data_bedset)
assert not bbc.bedset.report(record_identifier="bedset1", values=test_data_bedset)

def test_reporting_relationships(self, cfg_pth, test_data_bed, test_data_bedset):
with ContextManagerDBTesting(DB_URL):
bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
bbc.bed.report(sample_name="bed1", values=test_data_bed)
bed_id = bbc.bed.retrieve(sample_name="bed1", result_identifier="id")
bbc.bedset.report(sample_name="bedset1", values=test_data_bedset)
bbc.bed.report(record_identifier="bed1", values=test_data_bed)
bed_id = bbc.bed.retrieve(record_identifier="bed1", result_identifier="id")
bbc.bedset.report(record_identifier="bedset1", values=test_data_bedset)
bedset_id = bbc.bedset.retrieve(
sample_name="bedset1", result_identifier="id"
record_identifier="bedset1", result_identifier="id"
)
bbc.report_relationship(bedfile_id=bed_id, bedset_id=bedset_id)
print("a")
Expand All @@ -84,52 +84,52 @@ def test_cant_remove_record_if_in_reltable(
):
with ContextManagerDBTesting(DB_URL):
bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
bbc.bed.report(sample_name="bed1", values=test_data_bed)
bed_id = bbc.bed.retrieve(sample_name="bed1", result_identifier="id")
bbc.bedset.report(sample_name="bedset1", values=test_data_bedset)
bbc.bed.report(record_identifier="bed1", values=test_data_bed)
bed_id = bbc.bed.retrieve(record_identifier="bed1", result_identifier="id")
bbc.bedset.report(record_identifier="bedset1", values=test_data_bedset)
bedset_id = bbc.bedset.retrieve(
sample_name="bedset1", result_identifier="id"
record_identifier="bedset1", result_identifier="id"
)
bbc.report_relationship(bedfile_id=bed_id, bedset_id=bedset_id)
with pytest.raises(IntegrityError):
bbc.bed.remove(sample_name="bed1")
bbc.bed.remove(record_identifier="bed1")
with pytest.raises(IntegrityError):
bbc.bedset.remove(sample_name="bedset1")
bbc.bedset.remove(record_identifier="bedset1")

def test_select(self, cfg_pth, test_data_bed, test_data_bedset):
with ContextManagerDBTesting(DB_URL):
bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
bbc.bed.report(sample_name="bed1", values=test_data_bed)
bbc.bedset.report(sample_name="bedset1", values=test_data_bedset)
bbc.bed.report(record_identifier="bed1", values=test_data_bed)
bbc.bedset.report(record_identifier="bedset1", values=test_data_bedset)
bedset_id = bbc.bedset.retrieve(
sample_name="bedset1", result_identifier="id"
record_identifier="bedset1", result_identifier="id"
)
bed_id = bbc.bed.retrieve(sample_name="bed1", result_identifier="id")
bed_id = bbc.bed.retrieve(record_identifier="bed1", result_identifier="id")
bbc.report_relationship(bedfile_id=bed_id, bedset_id=bedset_id)

unique_bedfiles = bbc.select_unique(table_name="bedfile__sample")
assert unique_bedfiles[0].sample_name == "bed1"
assert unique_bedfiles[0].record_identifier == "bed1"
unique_bedsets = bbc.select_unique(table_name="bedsets__sample")
assert unique_bedsets[0].sample_name == "bedset1"
assert unique_bedsets[0].record_identifier == "bedset1"
results = bbc.select_bedfiles_for_bedset()
assert results is not None

def test_removal(self, cfg_pth, test_data_bed, test_data_bedset):
with ContextManagerDBTesting(DB_URL):
bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
bbc.bed.report(sample_name="bed1", values=test_data_bed)
bbc.bedset.report(sample_name="bedset1", values=test_data_bedset)
bbc.bed.report(record_identifier="bed1", values=test_data_bed)
bbc.bedset.report(record_identifier="bedset1", values=test_data_bedset)
bedset_id = bbc.bedset.retrieve(
sample_name="bedset1", result_identifier="id"
record_identifier="bedset1", result_identifier="id"
)
bed_id = bbc.bed.retrieve(sample_name="bed1", result_identifier="id")
bed_id = bbc.bed.retrieve(record_identifier="bed1", result_identifier="id")
bbc.report_relationship(bedfile_id=bed_id, bedset_id=bedset_id)
bbc.remove_relationship(bedset_id=bedset_id, bedfile_ids=[bed_id])
ori_cnt = bbc.bed.record_count
bbc.bed.remove(sample_name="bed1")
bbc.bed.remove(record_identifier="bed1")
assert ori_cnt - 1 == bbc.bed.record_count
ori_cnt = bbc.bedset.record_count
bbc.bedset.remove(sample_name="bedset1")
bbc.bedset.remove(record_identifier="bedset1")
assert ori_cnt - 1 == bbc.bedset.record_count

def test_config_variables_are_set(self, cfg_pth, test_data_bed, test_data_bedset):
Expand Down

0 comments on commit 2d81835

Please sign in to comment.