Mercurial > repos > rnateam > dewseq
annotate dewseq_wrapper.py @ 0:e1cb2e012307 draft default tip
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
author | rnateam |
---|---|
date | Thu, 20 Oct 2022 08:18:30 +0000 |
parents | |
children |
rev | line source |
---|---|
0
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
1 #!/usr/bin/env python3 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
2 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
3 import argparse |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
4 import os |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
5 import re |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
6 import shutil |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
7 import subprocess |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
8 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
9 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
10 """ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
11 DEWSeq wrapper script dependencies: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
12 conda install -c bioconda bioconductor-dewseq |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
13 conda install -c conda-forge r-rmarkdown |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
14 conda install -c bioconda bioconductor-biocstyle |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
15 conda install -c conda-forge r-tidyverse |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
16 conda install -c bioconda r-ggrepel |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
17 conda install -c bioconda bioconductor-ihw |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
18 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
19 Wrapper for DEWSeq R markdown file: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
20 https://github.com/EMBL-Hentze-group/DEWSeq_analysis_helpers/tree/master/Parametrized_Rmd |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
21 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
22 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
23 Test runs |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
24 ========= |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
25 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
26 # This reports 150 significant regions. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
27 python dewseq_wrapper.py --annot test-data/windows.exp.txt --matrix test-data/Rbp_count_matrix.exp.txt --info test-data/sample_info.exp.txt --out test_out --ds-pvc 0.5 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
28 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
29 # Wherease, with LRT, DEWSeq reports just one siginificant region. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
30 python dewseq_wrapper.py --annot test-data/windows.exp.txt --matrix test-data/Rbp_count_matrix.exp.txt --info test-data/sample_info.exp.txt --out test2_out --ds-pvc 0.5 --ds-use-lrt |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
31 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
32 """ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
33 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
34 ################################################################################ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
35 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
36 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
37 def setup_argument_parser(): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
38 """Setup argparse parser.""" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
39 help_description = """ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
40 Wrapping DEWSeq R markdown script, to call peak regions on the CLIP-seq data, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
41 preprocessed by htseq-clip. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
42 """ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
43 # Define argument parser. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
44 p = argparse.ArgumentParser(add_help=False, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
45 prog="dewseq_wrapper.py", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
46 description=help_description, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
47 formatter_class=argparse.MetavarTypeHelpFormatter) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
48 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
49 # Required arguments. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
50 p.add_argument("-h", "--help", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
51 action="help", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
52 help="Print help message") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
53 p.add_argument("--annot", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
54 dest="in_annot", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
55 type=str, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
56 metavar='str', |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
57 required=True, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
58 help="DEWseq annotation file, i.e. windows mapped to IDs table file (output of htseq-clip mapToId)") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
59 p.add_argument("--matrix", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
60 dest="in_matrix", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
61 type=str, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
62 metavar='str', |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
63 required=True, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
64 help="DEWseq count matrix file (output of htseq-clip createMatrix)") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
65 p.add_argument("--info", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
66 dest="in_info", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
67 type=str, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
68 metavar='str', |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
69 required=True, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
70 help="DEWseq sample information file (output of htsc_create_count_table.py / htseq-clip Create count table Galaxy wrapper)") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
71 p.add_argument("--out", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
72 dest="out_folder", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
73 type=str, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
74 metavar='str', |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
75 required=True, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
76 help="Results output folder") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
77 p.add_argument("--ds-ms", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
78 dest="ds_ms", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
79 type=int, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
80 metavar='int', |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
81 default=2, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
82 help="DEWSeq min_sample parameter. Keep only the windows with at least min_sample number of samples with crosslink site count > min_count (default: 2)") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
83 p.add_argument("--ds-mc", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
84 dest="ds_mc", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
85 type=int, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
86 metavar='int', |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
87 default=2, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
88 help="DEWSeq min_count parameter. Minimum crosslink site per window per sample (default: 2)") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
89 p.add_argument("--ds-pvc", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
90 dest="ds_pvc", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
91 type=float, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
92 metavar='float', |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
93 default=0.1, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
94 help="DEWSeq p_value_cutoff parameter. p adjusted value threshold for significant windows (default: 0.1)") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
95 p.add_argument("--ds-lfcc", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
96 dest="ds_lfcc", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
97 type=float, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
98 metavar='float', |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
99 default=1, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
100 help="DEWSeq lfc_cutoff parameter. Log2 fold change threshold for significant windows (default: 1)") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
101 p.add_argument("--ds-oc", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
102 dest="ds_use_oc", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
103 default=False, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
104 action="store_true", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
105 help="DEWSeq overlap_correction parameter. By default FALSE, i.e., do not adjust p-value for overlapping windows. If TRUE use Bonferroni family wise error rate correction on overlapping sliding windows (default: false)") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
106 p.add_argument("--ds--disable-ihw", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
107 dest="ds_disable_ihw", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
108 default=False, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
109 action="store_true", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
110 help="Disable DEWSeq IHW parameter. By default, use IHW for multiple tesing correction instead of default BH (Benjamini Hochberg). NOTE: We recommend using IHW instead of default BH for FDR correction") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
111 p.add_argument("--ds--disable-df", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
112 dest="ds_disable_df", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
113 default=False, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
114 action="store_true", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
115 help="Disable DEWSeq decide_fit parameter. By default, decide on dispersion estimation fit type local or parametric. If disabled, Use parametric fit. NOTE: decide_fit=TRUE will fit data using both parametric and local fit types and will choose the best fit of the two (see DESeq2 vignette for details). Typically, this should give better results compared to using the default fit type parametric. But, keep in mind that this will also increase the total run time") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
116 p.add_argument("--ds-use-lrt", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
117 dest="ds_use_lrt", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
118 default=False, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
119 action="store_true", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
120 help="DEWSeq LRT parameter. Use LRT if the given value is TRUE (see DESeq2 vignette for details). By default, DEWSeq uses Wald test. NOTE: In our experience, LRT is more accurate than Wald test. But, keep in mind that LRT is a stringent test in comparison to Wald. So if your protein of interest is a very active binder, run the analysis with LRT=TRUE, otherwise use it with caution as you may end up with no significant windows or regions in your final output") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
121 p.add_argument("--ds-id", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
122 dest="ds_id", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
123 type=str, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
124 default="RBP", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
125 metavar='str', |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
126 help="DEWSeq dataset ID for output report (default: RBP)") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
127 p.add_argument("--ds-markdown", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
128 dest="ds_markdown", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
129 type=str, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
130 default="analyseStudy.Rmd", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
131 metavar='str', |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
132 help="Provide path to DEWSeq R markdown file. By default assumed to be in working directory") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
133 p.add_argument("--copy-md", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
134 dest="copy_markdown", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
135 default=False, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
136 action="store_true", |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
137 help="Copy DEWSeq R markdown file to output directory and execute [sic!] it there (default: False)") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
138 return p |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
139 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
140 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
141 ################################################################################ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
142 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
143 def count_file_rows(in_file, |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
144 nr_cols=False): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
145 """ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
146 Count number of file rows. If nr_cols set, demand certain (nr_cols) number |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
147 of columns (separated by tab), in order for row to be counted. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
148 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
149 """ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
150 c = 0 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
151 with open(in_file) as f: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
152 for line in f: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
153 cols = line.strip().split("\t") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
154 if nr_cols: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
155 if len(cols) == nr_cols: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
156 c += 1 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
157 else: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
158 c += 1 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
159 f.closed |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
160 return c |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
161 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
162 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
163 ################################################################################ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
164 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
165 def check_two_dic_same_keys(d1, d2): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
166 """ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
167 Check if two dictionaries have same keys. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
168 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
169 >>> d1 = {'k1': 1, 'k2': 2} |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
170 >>> d2 = {'k1': 3, 'k2': 4} |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
171 >>> check_two_dic_same_keys(d1, d2) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
172 True |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
173 >>> d2 = {'k1': 3, 'k3': 4} |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
174 >>> check_two_dic_same_keys(d1, d2) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
175 False |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
176 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
177 """ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
178 assert d1, "given dictionary d1 empty" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
179 assert d2, "given dictionary d2 empty" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
180 for k in d1: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
181 if k not in d2: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
182 return False |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
183 for k in d2: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
184 if k not in d1: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
185 return False |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
186 return True |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
187 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
188 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
189 ################################################################################ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
190 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
191 if __name__ == '__main__': |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
192 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
193 parser = setup_argument_parser() |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
194 args = parser.parse_args() |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
195 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
196 assert os.path.exists(args.in_annot), "--annot file \"%s\" not found" % (args.in_annot) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
197 assert os.path.exists(args.in_matrix), "--matrix file \"%s\" not found" % (args.in_matrix) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
198 assert os.path.exists(args.in_info), "--info file \"%s\" not found" % (args.in_info) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
199 assert os.path.exists(args.ds_markdown), "--ds-markdown file \"%s\" not found" % (args.ds_markdown) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
200 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
201 # Input files. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
202 annot_in = os.path.abspath(args.in_annot) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
203 matrix_in = os.path.abspath(args.in_matrix) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
204 info_in = os.path.abspath(args.in_info) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
205 md_in = os.path.abspath(args.ds_markdown) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
206 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
207 # Sum Sanity Checks. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
208 matrix_ids = {} |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
209 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
210 with open(matrix_in) as f: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
211 for line in f: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
212 cols = line.strip().split("\t") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
213 for c in cols[1:]: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
214 matrix_ids[c] = 1 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
215 break |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
216 f.closed |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
217 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
218 assert matrix_ids, "no dataset columns found in count table file" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
219 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
220 info_ids = {} |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
221 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
222 with open(info_in) as f: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
223 for line in f: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
224 if re.search("^Sample name", line): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
225 continue |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
226 cols = line.strip().split("\t") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
227 if cols[0] == "Sample name": |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
228 continue |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
229 else: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
230 info_ids[cols[0]] = 1 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
231 f.closed |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
232 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
233 assert info_ids, "no dataset columns found in info table file" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
234 assert len(matrix_ids) == len(info_ids), "differing numbers of dataset IDs in count table and info table file" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
235 assert check_two_dic_same_keys(matrix_ids, info_ids), "dataset IDs in count table and info table file not identical" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
236 assert args.ds_ms <= len(matrix_ids), "set DEWSeq min_sample > number of data samples in count / info table files (%i > %i)" % (args.ds_ms, len(matrix_ids)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
237 print("Dataset IDs are valid ... ") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
238 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
239 # Output folder. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
240 if not os.path.exists(args.out_folder): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
241 os.makedirs(args.out_folder) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
242 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
243 # Output files. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
244 abs_path_out = os.path.abspath(args.out_folder) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
245 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
246 # Copy markdown file to results folder. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
247 if args.copy_markdown: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
248 md_source = md_in |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
249 md_in = abs_path_out + "/analyseStudy.Rmd" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
250 if not os.path.exists(md_in): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
251 print("Copying markdown file to output folder ... ") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
252 shutil.copyfile(md_source, md_in) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
253 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
254 html_out = abs_path_out + "/report.html" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
255 win_csv_out = abs_path_out + "/windows.csv" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
256 sig_reg_csv_out = abs_path_out + "/significant_regions.csv" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
257 sig_win_reg_bed_out = abs_path_out + "/significant_windows_and_regions.bed" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
258 sig_reg_bed_out = abs_path_out + "/significant_regions.bed" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
259 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
260 # Delete existing files (as if no peaks found old files would be reported). |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
261 if os.path.exists(html_out): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
262 os.remove(html_out) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
263 if os.path.exists(win_csv_out): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
264 os.remove(win_csv_out) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
265 if os.path.exists(sig_reg_csv_out): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
266 os.remove(sig_reg_csv_out) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
267 if os.path.exists(sig_win_reg_bed_out): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
268 os.remove(sig_win_reg_bed_out) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
269 if os.path.exists(sig_reg_bed_out): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
270 os.remove(sig_reg_bed_out) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
271 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
272 """ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
273 Run DEWSeq R markdown file. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
274 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
275 """ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
276 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
277 md_ihw = "TRUE" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
278 md_df = "TRUE" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
279 md_lrt = "FALSE" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
280 md_olc = "FALSE" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
281 if args.ds_disable_ihw: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
282 md_ihw = "FALSE" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
283 if args.ds_disable_df: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
284 md_df = "FALSE" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
285 if args.ds_use_lrt: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
286 md_lrt = "TRUE" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
287 if args.ds_use_oc: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
288 md_olc = "TRUE" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
289 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
290 md_cmd = "Rscript -e 'rmarkdown::render(" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
291 md_cmd += 'input = "%s", ' % (md_in) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
292 md_cmd += 'output_file = "%s", ' % (html_out) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
293 md_cmd += 'params = list(protein = "%s", ' % (args.ds_id) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
294 md_cmd += 'sampleinfo_file = "%s", ' % (info_in) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
295 md_cmd += 'countmatrix_file = "%s", ' % (matrix_in) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
296 md_cmd += 'annotation_file = "%s", ' % (annot_in) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
297 md_cmd += 'output_windows_file = "%s", ' % (win_csv_out) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
298 md_cmd += 'output_regions_file = "%s", ' % (sig_reg_csv_out) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
299 md_cmd += 'output_bed_file = "%s", ' % (sig_win_reg_bed_out) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
300 md_cmd += 'min_count = %i, ' % (args.ds_mc) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
301 md_cmd += 'min_sample = %i, ' % (args.ds_ms) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
302 md_cmd += 'p_value_cutoff = %s, ' % (str(args.ds_pvc)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
303 md_cmd += 'lfc_cutoff = %s, ' % (str(args.ds_lfcc)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
304 md_cmd += 'overlap_correction = %s, ' % (md_olc) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
305 md_cmd += 'IHW = %s, ' % (md_ihw) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
306 md_cmd += 'decide_fit = %s, ' % (md_df) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
307 md_cmd += 'LRT = %s))' % (md_lrt) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
308 md_cmd += "'" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
309 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
310 print("Running DEWSeq R markdown file ... ") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
311 print(md_cmd) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
312 output = subprocess.getoutput(md_cmd) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
313 print(output) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
314 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
315 print("") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
316 print("Checking for output files ... ") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
317 if os.path.exists(html_out): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
318 print("FOUND HTML report file \"%s\" ... " % (html_out)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
319 else: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
320 print("MISSING HTML report file \"%s\" ... " % (html_out)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
321 if os.path.exists(win_csv_out): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
322 print("FOUND windows CSV file \"%s\" ... " % (win_csv_out)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
323 else: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
324 print("MISSING windows CSV file \"%s\" ... " % (win_csv_out)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
325 if os.path.exists(sig_reg_csv_out): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
326 print("FOUND significant regions CSV file \"%s\" ... " % (sig_reg_csv_out)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
327 else: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
328 print("MISSING significant regions CSV file \"%s\" ... " % (sig_reg_csv_out)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
329 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
330 assert os.path.exists(html_out) and os.path.exists(win_csv_out), "DEWSeq terminated / did no produce any output files. This could be due to too strict filter settings (e.g., min_sample, min_count ... ). Please try again with more relaxed settings" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
331 assert os.path.exists(html_out), "output file \"%s\" not found" % (html_out) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
332 assert os.path.exists(win_csv_out), "output file \"%s\" not found" % (win_csv_out) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
333 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
334 print("") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
335 if not os.path.exists(sig_reg_csv_out): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
336 print("WARNING: no significant regions found! (missing \"%s\" file)" % (sig_reg_csv_out)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
337 else: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
338 assert os.path.exists(sig_win_reg_bed_out), "output file \"%s\" not found" % (sig_win_reg_bed_out) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
339 c_sig_reg = count_file_rows(sig_reg_csv_out) - 1 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
340 print("# significant regions: %i" % (c_sig_reg)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
341 # Save contiguous BED regions in separate file. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
342 OUTBED = open(sig_reg_bed_out, "w") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
343 with open(sig_reg_csv_out) as f: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
344 for line in f: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
345 row = line.strip() |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
346 cols = line.strip().split("\t") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
347 if cols[1] == "region_begin": |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
348 continue |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
349 chr_id = cols[0] |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
350 reg_s = cols[1] |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
351 reg_e = cols[2] |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
352 pol = cols[3] |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
353 win_in_reg = int(cols[4]) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
354 padj_mean = cols[7] |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
355 logfc_mean = cols[10] |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
356 reg_id = cols[12] |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
357 new_reg_id = reg_id |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
358 # For regions consisting of > 1 window. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
359 if win_in_reg > 1: |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
360 new_reg_id = reg_id + "@region" |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
361 # Print out BED with additional columns (padj, logfc). |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
362 OUTBED.write("%s\t%s\t%s\t%s\t0\t%s\t%s\t%s\n" % (chr_id, reg_s, reg_e, new_reg_id, pol, padj_mean, logfc_mean)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
363 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
364 f.closed |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
365 OUTBED.close() |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
366 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
367 """ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
368 Report. |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
369 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
370 """ |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
371 |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
372 print("") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
373 print("OUTPUT FILES") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
374 print("============") |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
375 print("HTML report:\n%s" % (html_out)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
376 print("Windows CSV:\n%s" % (win_csv_out)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
377 if os.path.exists(sig_reg_csv_out): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
378 print("Significant regions CSV:\n%s" % (sig_reg_csv_out)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
379 if os.path.exists(sig_win_reg_bed_out): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
380 print("Significant windows + regions BED:\n%s" % (sig_win_reg_bed_out)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
381 if os.path.exists(sig_reg_bed_out): |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
382 print("Significant regions BED:\n%s" % (sig_reg_bed_out)) |
e1cb2e012307
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/dewseq commit 71db0e65b3b306904ae2b17ce3de677244aea776"
rnateam
parents:
diff
changeset
|
383 print("") |