88import logging
99from multiqc import config
1010
11+ from pathlib import Path
12+ import os
13+ from pmultiqc .modules .common .file_utils import is_archive_file , extract_archive_file , get_clean_stem
14+
1115# Initialise the main MultiQC logger
1216log = logging .getLogger ("pmultiqc" )
1317
@@ -30,21 +34,32 @@ def pmultiqc_plugin_execution_start():
3034
3135 log .warning ("Running pmultiqc Plugin v{}" .format (config .pmultiqc_version ))
3236
37+ # If a compressed file is submitted, extract it first.
38+ analysis_dir_new = list ()
39+ for anal_dir in config .analysis_dir :
40+ if is_archive_file (anal_dir ):
41+
42+ root = Path (anal_dir ).parent
43+ file = Path (anal_dir ).name
44+ extract_archive_file (root , file )
45+
46+ output_dir = os .path .join (root , get_clean_stem (anal_dir ))
47+
48+ if os .path .exists (output_dir ):
49+ analysis_dir_new .append (output_dir )
50+ else :
51+ raise SystemExit (f"Illegal file path: { output_dir } " )
52+ else :
53+ analysis_dir_new .append (anal_dir )
54+ config .analysis_dir = analysis_dir_new
55+
56+ # Module filename search patterns
3357 if "quantms/exp_design" not in config .sp :
34- config .update_dict (
35- config .sp ,
36- {
37- "quantms/exp_design" : {"fn" : "experimental_design.tsv" , "num_lines" : 0 },
38- "shared" : False ,
39- },
40- )
58+ config .update_dict (config .sp , {"quantms/exp_design" : {"fn" : "experimental_design.tsv" , "num_lines" : 0 }})
4159
4260 if "quantms/sdrf" not in config .sp :
43- config .update_dict (
44- config .sp , {"quantms/sdrf" : {"fn" : "*.sdrf.tsv" , "num_lines" : 0 }, "shared" : False }
45- )
61+ config .update_dict (config .sp , {"quantms/sdrf" : {"fn" : "*.sdrf.tsv" , "num_lines" : 0 }})
4662
47- # Add to the search patterns used by modules
4863 if "quantms/mztab" not in config .sp :
4964 config .update_dict (config .sp , {"quantms/mztab" : {"fn" : "*.mzTab" , "num_lines" : 0 }})
5065
@@ -58,24 +73,16 @@ def pmultiqc_plugin_execution_start():
5873 config .update_dict (config .sp , {"quantms/mzid" : {"fn" : "*.mzid" , "num_lines" : 0 }})
5974
6075 if "quantms/ms_info" not in config .sp :
61- config .update_dict (
62- config .sp , {"quantms/ms_info" : {"fn" : "*_ms_info.parquet" , "num_lines" : 0 }}
63- )
76+ config .update_dict (config .sp , {"quantms/ms_info" : {"fn" : "*_ms_info.parquet" , "num_lines" : 0 }})
6477
6578 if "quantms/idXML" not in config .sp :
6679 config .update_dict (config .sp , {"quantms/idXML" : {"fn" : "*.idXML" , "num_lines" : 0 }})
6780
6881 if "quantms/msstats" not in config .sp :
69- config .update_dict (
70- config .sp , {"quantms/msstats" : {"fn" : "*msstats_in.csv" , "num_lines" : 0 }}
71- )
82+ config .update_dict (config .sp , {"quantms/msstats" : {"fn" : "*msstats_in.csv" , "num_lines" : 0 }})
7283
7384 if "quantms/diann_report" not in config .sp :
74- # TODO Why is the 'shared' suddenly inside the dict???
75- config .update_dict (
76- config .sp ,
77- {"quantms/diann_report" : {"fn" : "*report.tsv" , "num_lines" : 0 , "shared" : False }},
78- )
85+ config .update_dict (config .sp , {"quantms/diann_report" : {"fn" : "*report.tsv" , "num_lines" : 0 }})
7986
8087 if "quantms/maxquant_result" not in config .sp :
8188 config .update_dict (config .sp , {"quantms/maxquant_result" : {"fn" : "*.txt" , "num_lines" : 0 }})
0 commit comments