Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions VERSIONLOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# TACA Version Log

##20251121.1

Exclude pod5 from delivery by default

## 20251106.1

Improve logging
Expand Down
2 changes: 1 addition & 1 deletion taca/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Main TACA module"""

__version__ = "1.6.12"
__version__ = "1.6.13"
10 changes: 8 additions & 2 deletions taca/organise/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@
required=True,
help="Project ID (e.g. P12345)",
) # future todo: option to organise all flowcells in a project
@click.option(
"--include_pod5",
is_flag=True,
default=False,
help="Include pod5 files when organising Nanopore flowcells. Default is False.",
)
@click.argument("flowcells")
def organise_flowcells(flowcells, project):
def organise_flowcells(flowcells, project, include_pod5):
"""Organise FLOWCELLS.

FLOWCELLS is the name of one or more sequencing flowcells, separated by a comma. e.g.:
241122_VH00204_464_AAG77JJN5,241120_VH00202_453_AAG76JJM7
"""
flowcells_to_organise = flowcells.split(",")
for fc in flowcells_to_organise:
organise.organise_flowcell(fc, project)
organise.organise_flowcell(fc, project, include_pod5)
22 changes: 18 additions & 4 deletions taca/organise/flowcells.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
logger = logging.getLogger(__name__)


def get_flowcell_object(flowcell, project):
def get_flowcell_object(flowcell, project, include_pod5=False):
if re.match(filesystem.RUN_RE_ONT, flowcell):
return NanoporeFlowcell(flowcell=flowcell, project_id=project)
return NanoporeFlowcell(
flowcell=flowcell, project_id=project, include_pod5=include_pod5
)
elif re.match(filesystem.RUN_RE_ILLUMINA, flowcell):
return IlluminaFlowcell(flowcell=flowcell, project_id=project)
elif re.match(filesystem.RUN_RE_ELEMENT, flowcell):
Expand Down Expand Up @@ -44,13 +46,14 @@ def create_org_dir(self):
class NanoporeFlowcell(Flowcell):
"""Defines a Nanopore Flowcell"""

def __init__(self, flowcell, project_id):
def __init__(self, flowcell, project_id, include_pod5=False):
super().__init__(flowcell, project_id)
self.destination_path = CONFIG.get("organise").get("nanopore_path")
self.organised_project_dir = os.path.join(self.destination_path, project_id)
self.tar_file = self.fc_id + ".tar"
self.tar_path = os.path.join(self.organised_project_dir, self.tar_file)
self.md5_path = self.tar_path + ".md5"
self.include_pod5 = include_pod5

def organise_data(self):
"""Tarball data into ONT_TAR"""
Expand All @@ -59,7 +62,18 @@ def organise_data(self):
tar_err = os.path.join(self.organised_project_dir, "tar.err")
with filesystem.chdir(self.incoming_path):
with open(tar_err, "w") as error_file:
tar_command = ["tar", "-cvf", self.tar_path, self.fc_id]
if not self.include_pod5:
# exclude pod5 files from tarball
tar_command = [
"tar",
"--exclude=pod5*",
"-cvf",
self.tar_path,
self.fc_id,
]
else:
# include pod5 files from tarball
tar_command = ["tar", "-cvf", self.tar_path, self.fc_id]
result = subprocess.run(tar_command, stderr=error_file)
if result.returncode != 0:
logger.error(
Expand Down
4 changes: 2 additions & 2 deletions taca/organise/organise.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
logger = logging.getLogger(__name__)


def organise_flowcell(flowcell, project):
def organise_flowcell(flowcell, project, include_pod5=False):
"""Determine flowcell type and organise the data accordingly."""
flowcell_object = get_flowcell_object(flowcell, project)
flowcell_object = get_flowcell_object(flowcell, project, include_pod5)
flowcell_object.create_org_dir()
flowcell_object.organise_data()
logger.info(f"Finished organisation of flowcell {flowcell}.")