diff --git a/taca/analysis/analysis_element.py b/taca/analysis/analysis_element.py index 32439610..06d4e252 100755 --- a/taca/analysis/analysis_element.py +++ b/taca/analysis/analysis_element.py @@ -74,8 +74,11 @@ def _process(run): elif sequencing_done and demultiplexing_status == "finished": transfer_status = run.get_transfer_status() if transfer_status == "not started": - #TODO: if multiple demux dir exist, move the data dirs into Demultiplexing - run.aggregate_demux_results() + demux_results_dirs = glob.glob( + os.path.join(run.run_dir, "Delmultiplexing*") + ) + if len(demux_results_dirs > 1): + run.aggregate_demux_results(demux_results_dirs) run.sync_metadata() run.make_transfer_indicator() run.status = "transferring" diff --git a/taca/element/Element_Runs.py b/taca/element/Element_Runs.py index fed22e28..67222304 100644 --- a/taca/element/Element_Runs.py +++ b/taca/element/Element_Runs.py @@ -4,6 +4,7 @@ import re import zipfile import subprocess +import shutil from datetime import datetime from pathlib import Path from glob import glob @@ -374,14 +375,14 @@ def generate_demux_command(self, run_manifest, demux_dir): + " -p 8" + f" -r {run_manifest}" + " --legacy-fastq" # TODO: except if Smart-seq3 - + f" --force-index-orientation; echo $? > {self.rsync_exit_file}" + + f" --force-index-orientation" ) # TODO: any other options? return command def start_demux(self, run_manifest, demux_dir): with chdir(self.run_dir): cmd = self.generate_demux_command(run_manifest, demux_dir) - # TODO handle multiple composite manifests for demux + # TODO: handle multiple composite manifests for demux try: p_handle = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, cwd=self.run_dir) logger.info( @@ -426,9 +427,12 @@ def rsync_successful(self): else: return False - def aggregate_demux_results(self): - # TODO: aggregate demux results. Move project data dir from each sub demux dir to Demultiplexing - pass + def aggregate_demux_results(self, demux_results_dirs): + for demux_dir in demux_results_dirs: + data_dirs = [f.path for f in os.scandir(os.path.join(demux_dir, 'Samples')) if f.is_dir()] + for data_dir in data_dirs: + if not "PhiX" in data_dir and not "Unassigned" in data_dir: + shutil.move(data_dir, self.demux_dir) def sync_metadata(self): # TODO: copy metadata from demuxed run to ngi-nas-ns