Skip to content

Commit 5fb150a

Browse files
committed
add obsolete but still in use uniq tools
1 parent 4c8b23e commit 5fb150a

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed

file_manipulation/uniq.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import sys
2+
import subprocess
3+
4+
"""
5+
We only need that file because galaxy do not understand the -t $'\t' term.
6+
Otherwise that would be the right XML-only solution:
7+
sort -u
8+
$ignore_case
9+
$is_numeric
10+
-t \$'\t'
11+
#if $adv_opts.adv_opts_selector=="advanced":
12+
-k$adv_opts.column_start,$adv_opts.column_end
13+
#end if
14+
-o $outfile
15+
$input
16+
"""
17+
18+
if sys.argv[1].strip() != 'false':
19+
ignore_case = sys.argv[1]
20+
else:
21+
ignore_case = ''
22+
23+
if sys.argv[2].strip() != 'false':
24+
is_numeric = sys.argv[2]
25+
else:
26+
is_numeric = ''
27+
28+
try:
29+
col_start = sys.argv[3]
30+
col_end = sys.argv[4]
31+
com = "sort -u %s %s -t ' ' -k%s,%s -o %s %s" % (is_numeric, ignore_case, col_start, col_end, sys.argv[5], sys.argv[6])
32+
except:
33+
# no advanced options selected
34+
com = "sort -u %s %s -t ' ' -o %s %s" % (is_numeric, ignore_case, sys.argv[3], sys.argv[4])
35+
36+
subprocess.call(com, shell=True)

file_manipulation/uniq.xml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<tool id="bg_uniq" name="Unique" version="0.3">
2+
<description>occurrences of each record</description>
3+
<command interpreter='python'>
4+
uniq.py
5+
$ignore_case
6+
$is_numeric
7+
#if $adv_opts.adv_opts_selector=="advanced":
8+
$adv_opts.column_start
9+
$adv_opts.column_end
10+
#end if
11+
$outfile
12+
$input
13+
</command>
14+
<inputs>
15+
<param name="input" type="data" format="tabular,text" label="from query" />
16+
<param name="ignore_case" type="boolean" label="ignore differences in case when comparing" truevalue="-f" falsevalue="false" checked="false" help="ignore differences in case when comparing"/>
17+
<param name="is_numeric" type="boolean" label="column only contains numeric values" truevalue="-n" falsevalue="false" checked="false" help="did the calumn have numeric values"/>
18+
<conditional name="adv_opts">
19+
<param name="adv_opts_selector" type="select" label="Advanced Options">
20+
<option value="basic" selected="True">Hide Advanced Options</option>
21+
<option value="advanced">Show Advanced Options</option>
22+
</param>
23+
<when value="basic" />
24+
<when value="advanced">
25+
<param name="column_start" label="Column start" type="data_column" data_ref="input" help="Unique on specific column range"/>
26+
<param name="column_end" label="Column end" type="data_column" data_ref="input" help="Unique on specific column range"/>
27+
</when>
28+
</conditional>
29+
</inputs>
30+
<outputs>
31+
<data format="input" name="outfile" />
32+
</outputs>
33+
<tests>
34+
<test>
35+
</test>
36+
</tests>
37+
<help>
38+
39+
.. class:: infomark
40+
41+
**Syntax**
42+
43+
This tool returns all unique lines using the 'sort -u' command.
44+
45+
-----
46+
47+
.. class:: infomark
48+
49+
The input file needs to be tab separated. Please convert your file if necessary.
50+
51+
-----
52+
53+
**Example**
54+
55+
- Input file::
56+
57+
chr1 10 100 gene1
58+
chr1 105 200 gene2
59+
chr1 10 100 gene1
60+
chr2 10 100 gene4
61+
chr2 1000 1900 gene5
62+
chr3 15 1656 gene6
63+
chr2 10 100 gene4
64+
65+
- Unique lines will result in::
66+
67+
chr1 10 100 gene1
68+
chr1 105 200 gene2
69+
chr2 10 100 gene4
70+
chr2 1000 1900 gene5
71+
chr3 15 1656 gene6
72+
73+
74+
</help>
75+
</tool>

0 commit comments

Comments
 (0)