Skip to content

Commit

Permalink
added pep standardization
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Sep 12, 2024
1 parent 1b9ad92 commit ed04ce3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
8 changes: 8 additions & 0 deletions bedboss/bbuploader/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def upload_all(
True, help="Run skipped projects. [Default: False]"
),
run_failed: bool = typer.Option(True, help="Run failed projects. [Default: False]"),
standardize_pep: bool = typer.Option(
False, help="Standardize pep with BEDMESS. [Default: False]"
),
):
from .main import upload_all as upload_all_function

Expand All @@ -57,6 +60,7 @@ def upload_all(
rerun=rerun,
run_skipped=run_skipped,
run_failed=run_failed,
standardize_pep=standardize_pep,
)


Expand All @@ -79,6 +83,9 @@ def upload_gse(
True, help="Run skipped projects. [Default: False]"
),
run_failed: bool = typer.Option(True, help="Run failed projects. [Default: False]"),
standardize_pep: bool = typer.Option(
False, help="Standardize pep with BEDMESS. [Default: False]"
),
):
from .main import upload_gse as upload_gse_function

Expand All @@ -91,6 +98,7 @@ def upload_gse(
rerun=rerun,
run_skipped=run_skipped,
run_failed=run_failed,
standardize_pep=standardize_pep,
)


Expand Down
21 changes: 16 additions & 5 deletions bedboss/bbuploader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from bedboss.bedboss import run_all
from bedboss.bedbuncher.bedbuncher import run_bedbuncher
from bedboss.exceptions import BedBossException
from bedboss.utils import standardize_genome_name
from bedboss.utils import standardize_genome_name, standardize_pep as pep_standardizer

_LOGGER = logging.getLogger(PKG_NAME)
_LOGGER.setLevel(logging.DEBUG)
Expand All @@ -36,8 +36,9 @@ def upload_all(
genome: str = None,
create_bedset: bool = True,
rerun: bool = False,
run_skipped=False,
run_failed=True,
run_skipped: bool = False,
run_failed: bool = True,
standardize_pep: bool = False,
):
"""
This is main function that is responsible for processing bed files from PEPHub.
Expand All @@ -54,6 +55,7 @@ def upload_all(
:param rerun: rerun processing of the series
:param run_skipped: rerun files that were skipped
:param run_failed: rerun failed files
:param standardize_pep: standardize pep metadata using BEDMS
"""

phc = PEPHubClient()
Expand Down Expand Up @@ -122,6 +124,7 @@ def upload_all(
genome=genome,
sa_session=session,
gse_status_sa_model=gse_status,
standardize_pep=standardize_pep,
)
except Exception as err:
_LOGGER.error(
Expand Down Expand Up @@ -244,8 +247,9 @@ def upload_gse(
create_bedset: bool = True,
genome: str = None,
rerun: bool = False,
run_skipped=False,
run_failed=True,
run_skipped: bool = False,
run_failed: bool = True,
standardize_pep: bool = False,
):
"""
Upload bed files from GEO series to BedBase
Expand All @@ -258,6 +262,7 @@ def upload_gse(
:param rerun: rerun processing of the series
:param run_skipped: rerun files that were skipped
:param run_failed: rerun failed files
:param standardize_pep: standardize pep metadata using BEDMS
:return: None
"""
Expand Down Expand Up @@ -302,6 +307,7 @@ def upload_gse(
genome=genome,
sa_session=session,
gse_status_sa_model=gse_status,
standardize_pep=standardize_pep,
)
except Exception as e:
_LOGGER.error(f"Processing of '{gse}' failed with error: {e}")
Expand Down Expand Up @@ -347,6 +353,7 @@ def _upload_gse(
genome: str = None,
sa_session: Session = None,
gse_status_sa_model: GeoGseStatus = None,
standardize_pep: bool = False,
) -> ProjectProcessingStatus:
"""
Upload bed files from GEO series to BedBase
Expand All @@ -358,6 +365,7 @@ def _upload_gse(
:param genome: reference genome to upload to database. If None, all genomes will be processed
:param sa_session: opened session to the database
:param gse_status_sa_model: sqlalchemy model for project status
:param standardize_pep: standardize pep metadata using BEDMS
:return: None
"""
Expand All @@ -371,6 +379,9 @@ def _upload_gse(

project = phc.load_project(f"bedbase/{gse}:{DEFAULT_GEO_TAG}")

if standardize_pep:
project = pep_standardizer(project)

project_status = ProjectProcessingStatus(number_of_samples=len(project.samples))
uploaded_files = []
gse_status_sa_model.number_of_files = len(project.samples)
Expand Down

0 comments on commit ed04ce3

Please sign in to comment.