Skip to content

Commit

Permalink
Aggregate demux results if more than one
Browse files Browse the repository at this point in the history
  • Loading branch information
ssjunnebo committed Sep 17, 2024
1 parent 5790c1a commit 32f812c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions taca/analysis/analysis_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 9 additions & 5 deletions taca/element/Element_Runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re
import zipfile
import subprocess
import shutil
from datetime import datetime
from pathlib import Path
from glob import glob
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 32f812c

Please sign in to comment.