Mercurial > repos > greg > ideas_preprocessor
comparison ideas_preprocessor.xml @ 0:f060a0fbd4fe draft
Uploaded
author | greg |
---|---|
date | Mon, 22 Jan 2018 14:35:19 -0500 |
parents | |
children | 248b5f72fc02 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f060a0fbd4fe |
---|---|
1 <tool id="ideas_preprocessor" name="IDEAS preprocessor" version="1.0.0"> | |
2 <description></description> | |
3 <requirements> | |
4 <requirement type="package" version="2.5.4">deeptools</requirement> | |
5 <requirement type="package" version="1.10.4">r-data.table</requirement> | |
6 <requirement type="package" version="1.4.4">r-optparse</requirement> | |
7 <requirement type="package" version="1.6">samtools</requirement> | |
8 <requirement type="package" version="357">ucsc-bigwigaverageoverbed</requirement> | |
9 </requirements> | |
10 <command detect_errors="exit_code"><![CDATA[ | |
11 #set tmp_dir = "tmp" | |
12 #set prep_input_config = "prep_input_config.txt" | |
13 #set prep_output_config = "prep_output_config.txt" | |
14 #set specify_genomic_window = $specify_genomic_window_cond.specify_genomic_window | |
15 #set windows_positions_by_chroms_config = "windows_positions_by_chroms_config.txt" | |
16 ############################################## | |
17 ## Create the config file and prepare the data | |
18 ############################################## | |
19 #set output_dir = $output_txt_dir | |
20 #set tmp_dir = "tmp" | |
21 mkdir '$output_txt_dir' && | |
22 cp '$gen_prep_input_config' $prep_input_config && | |
23 sort $prep_input_config -o $prep_input_config && | |
24 Rscript '$__tool_directory__/ideas_preprocessor.R' | |
25 --prep_input_config '$prep_input_config' | |
26 #if str($specify_genomic_window) == "yes": | |
27 --bed_input '$specify_genomic_window_cond.bed_input' | |
28 #else: | |
29 --chrom_len_file '$chromInfo' | |
30 --window_size $specify_genomic_window_cond.window_size | |
31 #set restrict_chromosomes = $specify_genomic_window_cond.restrict_chromosomes_cond.restrict_chromosomes | |
32 #if str($restrict_chromosomes) == "yes": | |
33 #set chroms = [] | |
34 #set chrom_repeat = $specify_genomic_window_cond.restrict_chromosomes_cond.chrom_repeat | |
35 #for $i in $chrom_repeat.chrom | |
36 $chroms.append($i) | |
37 #end for | |
38 --restrict_to_chroms ",".join(chroms) | |
39 #end if | |
40 #end if | |
41 --reads_per_bp $reads_per_bp | |
42 #if str($blacklist_input) not in ["None", ""]: | |
43 --exclude_input '$exclude_input' | |
44 #end if | |
45 --output '$output' | |
46 --output_files_path '$output.files_path' | |
47 &> ideas_preprocessor_log.txt; | |
48 if [[ $? -ne 0 ]]; then | |
49 cp ideas_preprocessor_log.txt '$output'; | |
50 exit 1; | |
51 fi | |
52 ############################################## | |
53 ## Coerce the prepMat config output to the | |
54 ## format expected by IDEAS. | |
55 ############################################## | |
56 && cut -d' ' $prep_input_config -f1,2 > file1.txt | |
57 && ls $tmp_dir/*.bed.gz > file2.txt | |
58 && paste <(cat file1.txt) <(cat file2.txt) -d' ' > $prep_output_config | |
59 #if str($specify_genomic_window) == "yes": | |
60 ############################################## | |
61 ## Using a genomic window bed file, so categorize | |
62 ## the window positions by chromosome to enable | |
63 ## the IDEAS -inv option. | |
64 ############################################## | |
65 && cp '$gen_windows_positions_by_chroms_config' $windows_positions_by_chroms_config | |
66 #end if | |
67 ]]></command> | |
68 <configfiles> | |
69 <configfile name="gen_prep_input_config"><![CDATA[#if str($cell_type_epigenetic_factor_cond.cell_type_epigenetic_factor) == "extract": | |
70 #set input_name_positions = $cell_type_epigenetic_factor_cond.input_name_positions | |
71 #for $i in $cell_type_epigenetic_factor_cond.input: | |
72 #set file_name_with_ext = $i.name | |
73 #if str($file_name_with_ext).find("http") >= 0 or str($file_name_with_ext).find("ftp") >= 0: | |
74 #set file_name_with_ext = $file_name_with_ext.split('/')[-1] | |
75 #end if | |
76 #assert str($file_name_with_ext).find("-") >= 0, "The selected input '%s' is invalid because it does not include the '-' character which is required when setting cell type and epigenetic factor names by extracting them from the input file names." % $file_name_with_ext | |
77 #set file_name = $file_name_with_ext.split(".")[0] | |
78 #if str($input_name_positions) == "cell_first": | |
79 #set cell_type_name = $file_name.split("-")[0] | |
80 #set epigenetic_factor_name = $file_name.split("-")[1] | |
81 #else: | |
82 #set cell_type_name = $file_name.split("-")[1] | |
83 #set epigenetic_factor_name = $file_name.split("-")[0] | |
84 #end if | |
85 ${cell_type_name} ${epigenetic_factor_name} ${i} ${i.filename} ${i.ext} | |
86 #end for | |
87 #else: | |
88 #for $input_items in $cell_type_epigenetic_factor_cond.input_repeat: | |
89 ${input_items.cell_type_name} ${input_items.epigenetic_factor_name} ${input_items.input} ${input_items.input.filename} ${input_items.input.ext} | |
90 #end for | |
91 #end if]]></configfile> | |
92 <configfile name="gen_windows_positions_by_chroms_config"><![CDATA[#if str($specify_genomic_window_cond.specify_genomic_window) == "yes": | |
93 #import collections | |
94 #set window_positions_by_chroms_odict = $collections.OrderedDict() | |
95 #for count, line in enumerate(open($specify_genomic_window_cond.bed_input.file_name, 'r')): | |
96 #set $line = $line.strip() | |
97 #if not $line or $line.startswith('#'): | |
98 #continue | |
99 #end if | |
100 #set items = $line.split('\t') | |
101 #if $items[0] in $window_positions_by_chroms_odict: | |
102 #set tup = $window_positions_by_chroms_odict[$items[0]] | |
103 #set $tup[1] += 1 | |
104 #set $window_positions_by_chroms_odict[$items[0]] = $tup | |
105 #else: | |
106 #set $window_positions_by_chroms_odict[$items[0]] = [$count, $count+1] | |
107 #end if | |
108 #end for | |
109 #for $chrom, $tup in $window_positions_by_chroms_odict.items(): | |
110 ${chrom} ${tup[0]} ${tup[1]} | |
111 #end for | |
112 #end if]]></configfile> | |
113 </configfiles> | |
114 <inputs> | |
115 <conditional name="cell_type_epigenetic_factor_cond"> | |
116 <param name="cell_type_epigenetic_factor" type="select" label="Set cell type and epigenetic factor names by"> | |
117 <option value="extract" selected="true">extracting them from the selected input file names</option> | |
118 <option value="manual">manually setting them for each selected input</option> | |
119 </param> | |
120 <when value="extract"> | |
121 <param name="input" type="data" format="bigwig,bam" multiple="True" label="BAM or BigWig files"> | |
122 <validator type="empty_field"/> | |
123 <validator type="unspecified_build"/> | |
124 </param> | |
125 <param name="input_name_positions" type="select" display="radio" label="Selected input file name pattern is" help="A '-' character must separate cell type and epigenetic factor names within the selected input file names"> | |
126 <option value="cell_first" selected="true">Cell type name - Epigenetic factor name</option> | |
127 <option value="cell_last">Epigenetic factor name - Cell type name</option> | |
128 </param> | |
129 </when> | |
130 <when value="manual"> | |
131 <repeat name="input_repeat" title="Cell type, Epigenetic factor and Input" min="1"> | |
132 <param name="cell_type_name" type="text" value="" label="Cell type name"> | |
133 <validator type="empty_field"/> | |
134 </param> | |
135 <param name="epigenetic_factor_name" type="text" value="" label="Epigenetic factor name"> | |
136 <validator type="empty_field"/> | |
137 </param> | |
138 <param name="input" type="data" format="bigwig,bam" label="BAM or BigWig file"> | |
139 <validator type="empty_field"/> | |
140 <validator type="unspecified_build"/> | |
141 </param> | |
142 </repeat> | |
143 </when> | |
144 </conditional> | |
145 <conditional name="specify_genomic_window_cond"> | |
146 <param name="specify_genomic_window" type="select" label="Select Bed file that defines genomic windows on which to process the data"> | |
147 <option value="no" selected="true">No</option> | |
148 <option value="yes">Yes</option> | |
149 </param> | |
150 <when value="no"> | |
151 <param name="window_size" type="integer" value="200" label="Window size in base pairs"/> | |
152 <conditional name="restrict_chromosomes_cond"> | |
153 <param name="restrict_chromosomes" type="select" label="Restrict processing to specified chromosomes"> | |
154 <option value="no" selected="true">No</option> | |
155 <option value="yes">Yes</option> | |
156 </param> | |
157 <when value="no"/> | |
158 <when value="yes"> | |
159 <repeat name="chrom_repeat" title="Chromosomes" min="1"> | |
160 <param name="chrom" type="text" value="" label="Chromosome" help="One chromosome (e.g., chr1, chr2, chrX) per text field"/> | |
161 </repeat> | |
162 </when> | |
163 </conditional> | |
164 </when> | |
165 <when value="yes"> | |
166 <param name="bed_input" type="data" format="bed" label="Bed file specifying the genomic windows"/> | |
167 </when> | |
168 </conditional> | |
169 <param argument="--bychr" type="boolean" truevalue="true" falsevalue="" checked="False" label="Output chromosomes in separate files"/> | |
170 <param name="reads_per_bp" type="select" display="radio" label="Calculate the signal in each genomic window using"> | |
171 <option value="6" selected="true">mean</option> | |
172 <option value="8">max</option> | |
173 </param> | |
174 <param name="exclude_input" type="data" format="bed" optional="True" multiple="True" label="Select file(s) containing regions to exclude"/> | |
175 <param argument="--standardize_datasets" type="boolean" truevalue="true" falsevalue="" checked="False" label="Standardize all datasets"/> | |
176 </inputs> | |
177 <outputs> | |
178 <data name="output" format="html"/> | |
179 </outputs> | |
180 <tests> | |
181 <test> | |
182 </test> | |
183 </tests> | |
184 <help> | |
185 **What it does** | |
186 | |
187 ----- | |
188 | |
189 **Required options** | |
190 | |
191 </help> | |
192 <citations> | |
193 <citation type="doi">10.1093/nar/gkw278</citation> | |
194 </citations> | |
195 </tool> |