Skip to content

Commit

Permalink
πŸŒ™ 🚲
Browse files Browse the repository at this point in the history
  • Loading branch information
adRn-s committed Sep 19, 2024
1 parent c758568 commit a375c44
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
16 changes: 11 additions & 5 deletions BRB/PushButton.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import stat
from pathlib import Path

def createPath(config, group, project, organism, libraryType, tuples):
def createPath(config, group, project, organism, libraryType, tuples, stats):
"""Ensures that the output path exists, creates it otherwise, and return where it is"""
if tuples[0][3]:
baseDir = "{}/{}/Analysis_{}".format(config.get('Paths', 'baseData'),
Expand All @@ -20,10 +20,11 @@ def createPath(config, group, project, organism, libraryType, tuples):
BRB.misc.getLatestSeqdir(config.get('Paths','groupData'), group),
config.get('Options', 'runID'),
BRB.misc.pacifier(project))
os.makedirs(baseDir, mode=0o700, exist_ok=True)

if not stats: os.makedirs(baseDir, mode=0o700, exist_ok=True)

oDir = os.path.join(baseDir, "{}_{}".format(BRB.misc.pacifier(libraryType), organism.split(' ')[0].lower()))
os.makedirs(oDir, mode=0o700, exist_ok=True)
if not stats: os.makedirs(oDir, mode=0o700, exist_ok=True)
return oDir


Expand Down Expand Up @@ -564,7 +565,7 @@ def scATAC(config, group, project, organism, libraryType, tuples):
return outputDir, 0, True


def GetResults(config, project, libraries):
def GetResults(config, project, libraries, stats):
"""
Project is something like '352_Grzes_PearceEd' and libraries is a dictionary with libraries as keys:
{'18L005489': ['FAT_first_A',
Expand Down Expand Up @@ -638,7 +639,12 @@ def GetResults(config, project, libraries):
reruncount = 0
# RELACS needs the unpacified project name to copy the original sample sheet to the dest dir
# hence the pacifier is applied on the project in each pipeline separately
outputDir, rv, sambaUpdate = globals()[pipeline](config, group, project, organism, libraryType, tuples)
if stats:
outputDir, rv, sambaUpdate = (
createPath(config, group, BRB.misc.pacifier(project), organism, libraryType, tuples, stats),
0, False)
else:
outputDir, rv, sambaUpdate = globals()[pipeline](config, group, project, organism, libraryType, tuples)
if reruncount == 0 and rv != 0:
# Allow for one re-run
reruncount += 1
Expand Down
8 changes: 4 additions & 4 deletions BRB/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
from rich import print


def process_data(config, ParkourDict):
def process_data(config, ParkourDict, stats):
bdir = "{}/{}".format(config.get('Paths', 'baseData'), config.get('Options', 'runID'))
msg = []
for k, v in ParkourDict.items():
if not os.path.exists("{}/Project_{}".format(bdir, BRB.misc.pacifier(k))):
log.info("{}/Project_{} doesn't exist, probably lives on another lane.".format(bdir, BRB.misc.pacifier(k)))
continue
try:
msg = msg + BRB.PushButton.GetResults(config, k, v)
msg = msg + BRB.PushButton.GetResults(config, k, v, stats)
except Exception as e:
BRB.email.errorEmail(config, sys.exc_info(), "Received an error running PushButton.GetResults() with {} and {}".format(k, v))
log.critical("Received an error running PushButton.GetResults() with {} and {}".format(k, v))
Expand Down Expand Up @@ -116,10 +116,10 @@ def run_brb(configfile, stats, fcid):
log.info(f"Pushing stats for flowcell: {fcid}")

# Process each group's data, ignore cases where the project isn't in the lanes being processed
process_data(config, ParkourDict)
process_data(config, ParkourDict, stats)

if stats and dual_lane:
process_data(config1, ParkourDict1)
process_data(config1, ParkourDict1, stats)


if not stats:
Expand Down

0 comments on commit a375c44

Please sign in to comment.