Skip to content

Commit

Permalink
Added trackHub file creation to bedset
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Nov 11, 2024
1 parent 75b84d2 commit d21e497
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bbconf/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.9.0"
__version__ = "0.9.1_dev0"
48 changes: 48 additions & 0 deletions bbconf/modules/bedsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,54 @@ def get_bedset_pep(self, identifier: str) -> dict:
"_subsample_list": [],
}

def get_track_hub_file(self, identifier: str) -> str:
"""
Get track hub file for bedset.
:param identifier: bedset identifier
:return: track hub file
"""
statement = select(BedFileBedSetRelation).where(
BedFileBedSetRelation.bedset_id == identifier
)

trackDb_txt = ""

with Session(self._db_engine.engine) as session:
bs2bf_objects = session.scalars(statement)
if not bs2bf_objects:
raise BedSetNotFoundError(f"Bedset with id: {identifier} not found.")

for bs2bf_obj in bs2bf_objects:
bed_obj = bs2bf_obj.bedfile
try:
bigbed_url = None
for bedfile in bed_obj.files:
if bedfile.name == "bigbed_file":
bigbed_url = self.config.get_prefixed_uri(
postfix=bedfile.path, access_id="http"
)
break
if not bigbed_url:
_LOGGER.debug(
f"BigBed file for bedfile {bs2bf_obj.bedfile_id} not found."
)
continue
except AttributeError:
_LOGGER.debug(
f"BigBed file for bedfile {bs2bf_obj.bedfile_id} not found."
)
continue
trackDb_txt = (
trackDb_txt + f"track\t {bed_obj.name}\n"
"type\t bigBed\n"
f"bigDataUrl\t {bigbed_url} \n"
f"shortLabel\t {bed_obj.name}\n"
f"longLabel\t {bed_obj.description}\n"
"visibility\t full\n\n"
)
return trackDb_txt

def create(
self,
identifier: str,
Expand Down
7 changes: 6 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

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.9.1] - 2024-XX-XX
## Changed
- Added trackHub file creation to bedset

# [0.9.0] - 2024-11-06
## Changed
- Fixed bug with uploading tss dist plot\
- Fixed bug with uploading tss dist plot

## Added
- Added annotations to bedsets (author, source)
Expand Down

0 comments on commit d21e497

Please sign in to comment.