Skip to content

Commit 6cbb11b

Browse files
authored
Merge pull request #181 from yueqixuan/main
Update
2 parents 633965f + bdce57f commit 6cbb11b

File tree

16 files changed

+38110
-8707
lines changed

16 files changed

+38110
-8707
lines changed

docs/DIANN/multiqc_report.html

Lines changed: 4669 additions & 937 deletions
Large diffs are not rendered by default.

docs/LFQ_PXD007683/multiqc_report.html

Lines changed: 6928 additions & 1896 deletions
Large diffs are not rendered by default.

docs/PXD003133/multiqc_report.html

Lines changed: 5852 additions & 1143 deletions
Large diffs are not rendered by default.

docs/PXD051187/multiqc_report.html

Lines changed: 4229 additions & 756 deletions
Large diffs are not rendered by default.

docs/PXD054720/multiqc_report.html

Lines changed: 4229 additions & 756 deletions
Large diffs are not rendered by default.

docs/TMT_PXD007683/multiqc_report.html

Lines changed: 6928 additions & 1896 deletions
Large diffs are not rendered by default.

docs/dia/multiqc_report.html

Lines changed: 4284 additions & 671 deletions
Large diffs are not rendered by default.

docs/update_examples.py

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
import shutil
55
import time
66
import urllib
7-
import zipfile
8-
import gzip
9-
import tarfile
107
from ftplib import FTP
118
from pathlib import Path
129
from urllib.parse import urlparse
1310

1411
from tqdm import tqdm
1512

13+
from pmultiqc.modules.common.file_utils import extract_files
14+
1615

1716
def download_file(url, save_path, max_retries=3, backoff_factor=2):
1817
parsed_url = urlparse(url)
@@ -84,46 +83,6 @@ def reporthook(block_num, block_size, total_size):
8483
raise http_err
8584

8685

87-
def extract_zip(file_path, extract_to):
88-
with zipfile.ZipFile(file_path, "r") as zip_ref:
89-
zip_ref.extractall(extract_to)
90-
print(f"Extracted {file_path} to {extract_to}")
91-
92-
93-
def extract_gz(file_path, extract_to):
94-
with gzip.open(file_path, "rb") as f_in:
95-
out_path = os.path.join(extract_to, os.path.basename(file_path).replace(".gz", ""))
96-
with open(out_path, "wb") as f_out:
97-
shutil.copyfileobj(f_in, f_out)
98-
print(f"Extracted {file_path} to {out_path}")
99-
100-
101-
def extract_tar(file_path, extract_to):
102-
with tarfile.open(file_path, "r:*") as tar_ref:
103-
tar_ref.extractall(extract_to)
104-
print(f"Extracted {file_path} to {extract_to}")
105-
106-
107-
def extract_files(folder_path):
108-
for root, _, files in os.walk(folder_path):
109-
for file in files:
110-
file_path = os.path.join(root, file)
111-
# *.zip
112-
if file.endswith(".zip"):
113-
extract_zip(file_path, root)
114-
# *.gz
115-
elif file.endswith(".gz") and not file.endswith(".tar.gz"):
116-
extract_gz(file_path, root)
117-
# .tar, .tar.gz, .tar.bz2
118-
elif (
119-
file.endswith(".tar")
120-
or file.endswith(".tar.gz")
121-
or file.endswith(".tgz")
122-
or file.endswith(".tar.bz2")
123-
):
124-
extract_tar(file_path, root)
125-
126-
12786
def delete_old_examples(folder_path):
12887
for filename in os.listdir(folder_path):
12988
file_path = os.path.join(folder_path, filename)

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ channels:
44
- bioconda
55
- defaults
66
dependencies:
7-
- multiqc==1.26
7+
- multiqc==1.29
88
- pandas<=2.0.3
99
- pyteomics
1010
- pyopenms

pmultiqc/main.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
import logging
99
from 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
1216
log = 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

Comments
 (0)