diff --git a/irodsadmin/management/commands/irodsorphans.py b/irodsadmin/management/commands/irodsorphans.py index 0dd8b184..74f52048 100644 --- a/irodsadmin/management/commands/irodsorphans.py +++ b/irodsadmin/management/commands/irodsorphans.py @@ -21,6 +21,7 @@ logger = ManagementCommandLogger(__name__) +table_builder = SampleSheetTableBuilder() def get_assay_collections(assays, irods_backend): @@ -30,12 +31,10 @@ def get_assay_collections(assays, irods_backend): def get_assay_subcollections(studies, irods_backend): """Return a list of all assay row colletion names.""" - tb = SampleSheetTableBuilder() collections = [] - for study in studies: try: - study_tables = tb.get_study_tables(study) + study_tables = table_builder.get_study_tables(study) except Exception as ex: logger.error( 'Study table building exception for "{}" ' @@ -60,7 +59,6 @@ def get_assay_subcollections(studies, irods_backend): ) if row_path not in collections: collections.append(row_path) - shortcuts = assay_plugin.get_shortcuts(assay) if shortcuts: for shortcut in shortcuts: @@ -70,7 +68,6 @@ def get_assay_subcollections(studies, irods_backend): collections.append(assay_path + '/' + TRACK_HUBS_COLL) collections.append(assay_path + '/' + RESULTS_COLL) collections.append(assay_path + '/' + MISC_FILES_COLL) - return collections @@ -154,7 +151,6 @@ def get_orphans(irods, irods_backend, expected, assays): ): if collection.path not in expected: orphans.append(collection.path) - return orphans @@ -163,7 +159,6 @@ def get_output(orphans, irods_backend, irods): for orphan in orphans: stats = irods_backend.get_object_stats(irods, orphan) m = re.search(r'/projects/([^/]{2})/(\1[^/]+)', orphan) - if m: uuid = m.group(2) try: @@ -174,7 +169,6 @@ def get_output(orphans, irods_backend, irods): else: uuid = '' title = '' - lines.append( ';'.join( [ diff --git a/samplesheets/plugins.py b/samplesheets/plugins.py index 91fb7197..60bc51cf 100644 --- a/samplesheets/plugins.py +++ b/samplesheets/plugins.py @@ -50,6 +50,7 @@ app_settings = AppSettingAPI() logger = logging.getLogger(__name__) +table_builder = SampleSheetTableBuilder() # SODAR constants @@ -898,7 +899,6 @@ def _update_cache_rows(self, app_name, name=None, project=None, user=None): if not cache_backend or not irods_backend: return - tb = SampleSheetTableBuilder() projects = ( [project] if project @@ -924,7 +924,7 @@ def _update_cache_rows(self, app_name, name=None, project=None, user=None): # Get assay paths for study in studies: - study_tables = tb.get_study_tables(study) + study_tables = table_builder.get_study_tables(study) for assay in [a for a in study.assays.all() if a in config_assays]: assay_table = study_tables['assays'][str(assay.sodar_uuid)] assay_path = irods_backend.get_path(assay) diff --git a/samplesheets/sheet_config.py b/samplesheets/sheet_config.py index e7964106..64499ab8 100644 --- a/samplesheets/sheet_config.py +++ b/samplesheets/sheet_config.py @@ -15,6 +15,7 @@ app_settings = AppSettingAPI() logger = logging.getLogger(__name__) +table_builder = SampleSheetTableBuilder() # Local constants @@ -106,8 +107,7 @@ def get_sheet_config(self, investigation, inv_tables=None): if not sheet_ok: logger.info(msg) if not inv_tables: - tb = SampleSheetTableBuilder() - inv_tables = tb.build_inv_tables( + inv_tables = table_builder.build_inv_tables( investigation, use_config=False ) sheet_config = self.build_sheet_config(investigation, inv_tables) diff --git a/samplesheets/studyapps/cancer/plugins.py b/samplesheets/studyapps/cancer/plugins.py index 690b7f26..0212d29b 100644 --- a/samplesheets/studyapps/cancer/plugins.py +++ b/samplesheets/studyapps/cancer/plugins.py @@ -23,12 +23,12 @@ logger = logging.getLogger(__name__) +table_builder = SampleSheetTableBuilder() User = auth.get_user_model() # SODAR constants PROJECT_TYPE_PROJECT = SODAR_CONSTANTS['PROJECT_TYPE_PROJECT'] - # Local constants APP_NAME = 'samplesheets.studyapps.cancer' @@ -268,7 +268,6 @@ def update_cache(self, name=None, project=None, user=None): if not cache_backend: return - tb = SampleSheetTableBuilder() projects = ( [project] if project @@ -301,7 +300,7 @@ def update_cache(self, name=None, project=None, user=None): vcf_paths = {} # Get/build render tables - study_tables = tb.get_study_tables(study) + study_tables = table_builder.get_study_tables(study) for library in get_study_libraries(study, study_tables): if not library.assay: continue diff --git a/samplesheets/studyapps/cancer/views.py b/samplesheets/studyapps/cancer/views.py index f75a1348..97b6387f 100644 --- a/samplesheets/studyapps/cancer/views.py +++ b/samplesheets/studyapps/cancer/views.py @@ -25,6 +25,9 @@ from samplesheets.studyapps.cancer.utils import get_library_file_path +table_builder = SampleSheetTableBuilder() + + class BaseCancerConfigView( LoginRequiredMixin, LoggedInPermissionMixin, @@ -85,8 +88,7 @@ def get(self, request, *args, **kwargs): return redirect(self.redirect_url) # Get/build render tables - tb = SampleSheetTableBuilder() - study_tables = tb.get_study_tables(self.material.study) + study_tables = table_builder.get_study_tables(self.material.study) # Get libraries libraries = get_sample_libraries(samples, study_tables) bam_urls = {} diff --git a/samplesheets/studyapps/germline/plugins.py b/samplesheets/studyapps/germline/plugins.py index d72cecd3..529aec89 100644 --- a/samplesheets/studyapps/germline/plugins.py +++ b/samplesheets/studyapps/germline/plugins.py @@ -23,6 +23,7 @@ ) logger = logging.getLogger(__name__) +table_builder = SampleSheetTableBuilder() User = auth.get_user_model() @@ -294,8 +295,7 @@ def _update_study_cache(cls, study, user, cache_backend, irods_backend): bam_paths = {} vcf_paths = {} # Get/build render tables - tb = SampleSheetTableBuilder() - study_tables = tb.get_study_tables(study) + study_tables = table_builder.get_study_tables(study) # Pre-fetch study objects to eliminate redundant queries obj_len = 0 diff --git a/samplesheets/studyapps/germline/views.py b/samplesheets/studyapps/germline/views.py index ff65c74a..db27051f 100644 --- a/samplesheets/studyapps/germline/views.py +++ b/samplesheets/studyapps/germline/views.py @@ -26,6 +26,9 @@ from sodar.users.auth import fallback_to_auth_basic +table_builder = SampleSheetTableBuilder() + + class BaseGermlineConfigView( LoginRequiredMixin, LoggedInPermissionMixin, @@ -64,10 +67,8 @@ def get(self, request, *args, **kwargs): if not settings.IRODS_WEBDAV_ENABLED or not settings.IRODS_WEBDAV_URL: messages.error(self.request, 'iRODS WebDAV not available') return redirect(self.redirect_url) - # Get/build render tables - tb = SampleSheetTableBuilder() - self.study_tables = tb.get_study_tables(self.source.study) + self.study_tables = table_builder.get_study_tables(self.source.study) @fallback_to_auth_basic diff --git a/samplesheets/views_api.py b/samplesheets/views_api.py index 445eed64..78d934ae 100644 --- a/samplesheets/views_api.py +++ b/samplesheets/views_api.py @@ -46,6 +46,7 @@ app_settings = AppSettingAPI() logger = logging.getLogger(__name__) +table_builder = SampleSheetTableBuilder() MD5_RE = re.compile(r'([a-fA-F\d]{32})') @@ -399,11 +400,10 @@ def get(self, request, **kwargs): # Rendered tables if not isa or int(isa) != 1: ret = {'studies': {}} - tb = SampleSheetTableBuilder() # Get/build study tables for study in investigation.studies.all(): try: - tables = tb.get_study_tables(study) + tables = table_builder.get_study_tables(study) except Exception as ex: return Response(str(ex), status=500) ret['studies'][str(study.sodar_uuid)] = tables