Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impl log collection opt #29

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
6 changes: 6 additions & 0 deletions q2_autopepsirf/actions/diffEnrich.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
PepsirfInfoSumOfProbesFmt, PepsirfInfoSNPNFormat,
PepsirfContingencyTSVFormat, ZscoreNanFormat, EnrichedPeptideDirFmt
)
from subprocess import run

import csv
import os
import pandas as pd
import qiime2
from q2_autopepsirf.utils import collect_logs


# Name: diffenrich
# Process: automatically runs through q2-ps-plot modules and q2-pepsirf modules
Expand Down Expand Up @@ -38,6 +41,7 @@ def diffEnrich(
exact_cs_thresh="20",
exact_zenrich_thresh=None,
pepsirf_tsv_dir="./",
pepsirf_logs_dir="./logs",
tsv_base_str=None,
step_z_thresh=5,
upper_z_thresh=30,
Expand Down Expand Up @@ -304,6 +308,8 @@ def diffEnrich(
pepsirf_binary=pepsirf_binary
)

collect_logs(pepsirf_logs_dir)

# return all files created
return (
col_sum, diff, diff_ratio, zscore_out, nan_out, sample_names,
Expand Down
5 changes: 5 additions & 0 deletions q2_autopepsirf/actions/diffEnrich_deconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
)

import os
from q2_autopepsirf.utils import collect_logs

def diffEnrich_deconv(
ctx,
Expand All @@ -27,6 +28,7 @@ def diffEnrich_deconv(
exact_cs_thresh="20",
exact_zenrich_thresh=None,
pepsirf_tsv_dir="./",
pepsirf_logs_dir="./logs",
tsv_base_str=None,
step_z_thresh=5,
upper_z_thresh=30,
Expand Down Expand Up @@ -62,6 +64,7 @@ def diffEnrich_deconv(
exact_cs_thresh=exact_cs_thresh,
exact_zenrich_thresh=exact_zenrich_thresh,
pepsirf_tsv_dir=pepsirf_tsv_dir,
pepsirf_logs_dir=pepsirf_logs_dir,
tsv_base_str=tsv_base_str,
step_z_thresh=step_z_thresh,
upper_z_thresh=upper_z_thresh,
Expand Down Expand Up @@ -93,6 +96,8 @@ def diffEnrich_deconv(
deconv_tsv = dir_out.view(PepsirfDeconvBatchDirFmt)
deconv_tsv.save(os.path.join(pepsirf_tsv_dir, deconv_base), ext=".tsv")

collect_logs(pepsirf_logs_dir)

return (
dir_out, score_per_round, map_dir, col_sum, diff, diff_ratio,
zscore_out, nan_out, sample_names, read_counts, rc_boxplot_out,
Expand Down
2 changes: 2 additions & 0 deletions q2_autopepsirf/actions/diffEnrich_deconv_tsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def diffEnrich_deconv_tsv(
exact_cs_thresh="20",
exact_zenrich_thresh=None,
pepsirf_tsv_dir="./",
pepsirf_logs_dir="./logs",
tsv_base_str=None,
step_z_thresh=5,
upper_z_thresh=30,
Expand Down Expand Up @@ -114,6 +115,7 @@ def diffEnrich_deconv_tsv(
exact_cs_thresh=exact_cs_thresh,
exact_zenrich_thresh=exact_zenrich_thresh,
pepsirf_tsv_dir=pepsirf_tsv_dir,
pepsirf_logs_dir=pepsirf_logs_dir,
tsv_base_str=tsv_base_str,
step_z_thresh=step_z_thresh,
upper_z_thresh=upper_z_thresh,
Expand Down
2 changes: 2 additions & 0 deletions q2_autopepsirf/actions/diffEnrich_tsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def diffEnrich_tsv(
exact_cs_thresh="20",
exact_zenrich_thresh=None,
pepsirf_tsv_dir="./",
pepsirf_logs_dir="./logs",
tsv_base_str=None,
step_z_thresh=5,
upper_z_thresh=30,
Expand Down Expand Up @@ -104,6 +105,7 @@ def diffEnrich_tsv(
exact_cs_thresh=exact_cs_thresh,
exact_zenrich_thresh=exact_zenrich_thresh,
pepsirf_tsv_dir=pepsirf_tsv_dir,
pepsirf_logs_dir=pepsirf_logs_dir,
tsv_base_str=tsv_base_str,
step_z_thresh=step_z_thresh,
upper_z_thresh=upper_z_thresh,
Expand Down
4 changes: 3 additions & 1 deletion q2_autopepsirf/plugin_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"upper_z_thresh": Int % Range(2, None),
"lower_z_thresh": Int % Range(1, None),
"pepsirf_tsv_dir": Str,
"pepsirf_logs_dir": Str,
"tsv_base_str": Str,
"hdi": Float % Range(0.0, 1.0),
"infer_pairs_source": Bool,
Expand Down Expand Up @@ -96,6 +97,8 @@
" tsv-base-str for output of tsv verison of qza files. The"
" source_samples file and png boxplot outputs will always be put"
" within this directory.",
"pepsirf_logs_dir": "Path to a directory which PepSIRF log files will be"
" collected.",
"tsv_base_str": "The base name for the output tsv files excluding ay"
" extensions, typcally the raw data filename (EX: --p-tsv-base-str"
" raw_data). Must also provide pepsirf-tsv-dir, if pepsirf-tsv-dir"
Expand Down Expand Up @@ -273,4 +276,3 @@
" that are used to determine enriched peptides and"
" **ADD DECONV DESCRIPTION**"
)

14 changes: 14 additions & 0 deletions q2_autopepsirf/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os
import glob
import shutil


def collect_logs(path):
# collect pepsirf logs into a directory at `path`
# check for there is not a directory for logs already
if not os.path.isdir(path):
os.mkdir(path)
# collect log files
files = glob.glob("*.log", recursive=True)
for file in files:
shutil.move(file, path)