Skip to content

Commit 8042c64

Browse files
authored
Merge pull request #1158 from fls-bioinformatics-core/refactor-autoprocess-cli-commands
Refactor how command functionality is attached to 'AutoProcess' class
2 parents 2a6810b + b5b4db1 commit 8042c64

4 files changed

Lines changed: 102 additions & 135 deletions

File tree

auto_process_ngs/auto_processor.py

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
# auto_processor.py: automated processing of Illumina sequence data
44
# Copyright (C) University of Manchester 2013-2026 Peter Briggs
55
#
6-
#########################################################################
7-
#
8-
# auto_processor.py
9-
#
10-
#########################################################################
116

127
#######################################################################
138
# Imports
@@ -24,70 +19,53 @@
2419
import gzip
2520
import atexit
2621
import bcftbx.IlluminaData as IlluminaData
27-
import bcftbx.TabFile as TabFile
2822
import bcftbx.utils as bcf_utils
29-
import bcftbx.htmlpagewriter as htmlpagewriter
30-
from bcftbx.JobRunner import fetch_runner
31-
from bcftbx.FASTQFile import FastqIterator
32-
from . import commands
3323
from .analysis import AnalysisProject
3424
from .analysis import run_id
3525
from .analysis import run_reference_id
36-
from .decorators import add_command
3726
from .metadata import AnalysisDirParameters
3827
from .metadata import AnalysisDirMetadata
3928
from .metadata import ProjectMetadataFile
4029
from .utils import edit_file
4130
from .utils import get_numbered_subdir
4231
from .utils import sort_sample_names
4332
from .bcl2fastq.utils import get_sequencer_platform
44-
from .samplesheet_utils import check_and_warn
4533
from .settings import Settings
4634
from .exceptions import MissingParameterFileException
4735
from functools import reduce
48-
from . import get_version
4936

5037
#######################################################################
5138
# Classes
5239
#######################################################################
5340

54-
@add_command("setup",commands.setup)
55-
@add_command("make_fastqs",commands.make_fastqs)
56-
@add_command("analyse_barcodes",commands.analyse_barcodes)
57-
@add_command("merge_fastq_dirs",commands.merge_fastq_dirs)
58-
@add_command("setup_analysis_dirs",commands.setup_analysis_dirs)
59-
@add_command("run_qc",commands.run_qc)
60-
@add_command("publish_qc",commands.publish_qc)
61-
@add_command("archive",commands.archive)
62-
@add_command("update",commands.update)
63-
@add_command("report",commands.report)
64-
@add_command("update_fastq_stats",commands.update_fastq_stats)
65-
@add_command("import_project",commands.import_project)
66-
@add_command("clone",commands.clone)
67-
@add_command("samplesheet",commands.samplesheet)
41+
6842
class AutoProcess:
6943
"""
7044
Class implementing an automatic fastq generation and QC
7145
processing procedure for Illumina sequencing data
7246
47+
The 'AutoProcess' class provides an interface to a directory
48+
being used for processing Illumina sequencing data, including
49+
Fastq generation and QC operations.
50+
51+
The auto_process data processing and QC pipelines are
52+
constructed around this class, which allows the current state
53+
of the processing directory (and associated metadata) to be
54+
accessed and modified.
55+
56+
Arguments:
57+
analysis_dir (str): name/path for existing analysis
58+
directory
59+
settings (Settings): optional, if supplied then should
60+
be a Settings instance; otherwise use a default
61+
instance populated from the installation-specific
62+
'auto_process.ini' file
63+
allow_save_params (bool): if True then allow updates
64+
to parameters to be saved back to the parameter file
65+
(this is the default)
7366
"""
7467
def __init__(self,analysis_dir=None,settings=None,
7568
allow_save_params=True):
76-
"""
77-
Create a new AutoProcess instance
78-
79-
Arguments:
80-
analysis_dir (str): name/path for existing analysis
81-
directory
82-
settings (Settings): optional, if supplied then should
83-
be a Settings instance; otherwise use a default
84-
instance populated from the installation-specific
85-
'auto_process.ini' file
86-
allow_save_params (bool): if True then allow updates
87-
to parameters to be saved back to the parameter file
88-
(this is the default)
89-
90-
"""
9169
# Initialise
9270
self._master_log_dir = "logs"
9371
self._log_dir = self._master_log_dir

auto_process_ngs/cli/auto_process.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
# cli/auto_process.py: command line interface for auto_process_ngs
44
# Copyright (C) University of Manchester 2013-2026 Peter Briggs
55
#
6-
#########################################################################
7-
#
8-
# auto_process.py
9-
#
10-
#########################################################################
116

127
"""
138
Automated data processing & QC pipeline for Illumina sequence data
@@ -60,28 +55,26 @@
6055

6156
import sys
6257
import os
63-
import subprocess
6458
import argparse
6559
import time
6660
import logging
6761
import bcftbx.utils as bcf_utils
68-
import bcftbx.platforms
6962
from bcftbx.cmdparse import CommandParser
7063
from bcftbx.cmdparse import add_debug_option
7164
from bcftbx.cmdparse import add_no_save_option
7265
from bcftbx.cmdparse import add_dry_run_option
7366
from bcftbx.cmdparse import add_nprocessors_option
7467
from bcftbx.cmdparse import add_runner_option
75-
from bcftbx.cmdparse import add_arg
7668
from bcftbx.JobRunner import fetch_runner
7769
from .. import get_version
78-
from ..auto_processor import AutoProcess
70+
from .. import auto_processor
71+
from .. import commands
7972
from ..bcl2fastq.pipeline import PROTOCOLS
8073
from ..bcl2fastq.pipeline import subset
8174
from ..commands.make_fastqs_cmd import BCL2FASTQ_DEFAULTS
8275
from ..commands.report_cmd import ReportingMode
8376
from ..commands.samplesheet_cmd import SampleSheetOperation
84-
from ..samplesheet_utils import predict_outputs
77+
from ..decorators import add_command
8578
from ..settings import Settings
8679
from ..settings import locate_auto_process_settings_file
8780
from ..tenx import CELLRANGER_ASSAY_CONFIGS
@@ -95,6 +88,29 @@
9588
__version__ = get_version()
9689
__settings = Settings()
9790

91+
#######################################################################
92+
# Classes
93+
#######################################################################
94+
95+
@add_command("setup", commands.setup)
96+
@add_command("make_fastqs", commands.make_fastqs)
97+
@add_command("analyse_barcodes", commands.analyse_barcodes)
98+
@add_command("merge_fastq_dirs", commands.merge_fastq_dirs)
99+
@add_command("setup_analysis_dirs", commands.setup_analysis_dirs)
100+
@add_command("run_qc", commands.run_qc)
101+
@add_command("publish_qc", commands.publish_qc)
102+
@add_command("archive", commands.archive)
103+
@add_command("update", commands.update)
104+
@add_command("report", commands.report)
105+
@add_command("update_fastq_stats", commands.update_fastq_stats)
106+
@add_command("import_project", commands.import_project)
107+
@add_command("clone", commands.clone)
108+
@add_command("samplesheet", commands.samplesheet)
109+
class AutoProcess(auto_processor.AutoProcess):
110+
"""
111+
Augmented AutoProcess class with commands attached
112+
"""
113+
98114
#######################################################################
99115
# Functions
100116
#######################################################################

0 commit comments

Comments
 (0)