# HG changeset patch
# User devteam
# Date 1594059056 0
# Node ID 81a6c3de5de3f0a331eed8c34e99a1916313d75d
# Parent 3100886bf698996b47ceae7a0dc729cf58a00d1d
"planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/convert_characters commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
diff -r 3100886bf698 -r 81a6c3de5de3 convert_characters.py
--- a/convert_characters.py Mon Nov 09 11:25:21 2015 -0500
+++ b/convert_characters.py Mon Jul 06 18:10:56 2020 +0000
@@ -1,42 +1,45 @@
#!/usr/bin/env python
-#By, Guruprasad Ananda.
+"""
+By, Guruprasad Ananda.
+"""
+from __future__ import print_function
-from galaxy import eggs
-import sys, re
+import re
+import sys
-def stop_err(msg):
- sys.stderr.write(msg)
- sys.exit()
-
+
def main():
if len(sys.argv) != 4:
- stop_err("usage: convert_characters infile from_char outfile")
+ sys.exit("usage: convert_characters infile from_char outfile")
try:
- fin = open(sys.argv[1],'r')
- except:
- stop_err("Input file cannot be opened for reading.")
-
+ fin = open(sys.argv[1], 'r')
+ except Exception:
+ sys.exit("Input file cannot be opened for reading.")
+
from_char = sys.argv[2]
-
+
try:
- fout = open(sys.argv[3],'w')
- except:
- stop_err("Output file cannot be opened for writing.")
-
- char_dict = {'T':'\t','s':'\s','Dt':'\.','C':',','D':'-','U':'_','P':'\|','Co':':'}
- from_ch = char_dict[from_char] + '+' #making an RE to match 1 or more occurences.
+ fout = open(sys.argv[3], 'w')
+ except Exception:
+ sys.exit("Output file cannot be opened for writing.")
+
+ char_dict = {'T': r'\t', 's': r'\s', 'Dt': r'\.', 'C': r',', 'D': r'-',
+ 'U': r'_', 'P': r'\|', 'Co': r':'}
+ # making an RE to match 1 or more occurences.
+ from_ch = char_dict[from_char] + '+'
skipped = 0
-
+
for line in fin:
line = line.strip()
try:
- fout.write("%s\n" %(re.sub(from_ch,'\t',line)))
- except:
+ fout.write("%s\n" % (re.sub(from_ch, '\t', line)))
+ except Exception:
skipped += 1
-
+
if skipped:
- print "Skipped %d lines as invalid." %skipped
-
-if __name__ == "__main__":
- main()
\ No newline at end of file
+ print("Skipped %d lines as invalid." % skipped)
+
+
+if __name__ == "__main__":
+ main()
diff -r 3100886bf698 -r 81a6c3de5de3 convert_characters.xml
--- a/convert_characters.xml Mon Nov 09 11:25:21 2015 -0500
+++ b/convert_characters.xml Mon Jul 06 18:10:56 2020 +0000
@@ -1,58 +1,66 @@
-
- delimiters to TAB
- convert_characters.py "${input}" "${convert_from}" "${out_file1}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-**What it does**
-
-Converts all delimiters of a specified type into TABs. Consecutive characters are condensed. For example, if columns are separated by 5 spaces they will converted into 1 tab.
-
------
-
-**Example**
-
-- Input file::
-
- chrX||151283558|151283724|NM_000808_exon_8_0_chrX_151283559_r|0|-
- chrX|151370273|151370486|NM_000808_exon_9_0_chrX_151370274_r|0|-
- chrX|151559494|151559583|NM_018558_exon_1_0_chrX_151559495_f|0|+
- chrX|151564643|151564711|NM_018558_exon_2_0_chrX_151564644_f||||0|+
-
-- Converting all pipe delimiters of the above file to TABs will get::
-
- chrX 151283558 151283724 NM_000808_exon_8_0_chrX_151283559_r 0 -
- chrX 151370273 151370486 NM_000808_exon_9_0_chrX_151370274_r 0 -
- chrX 151559494 151559583 NM_018558_exon_1_0_chrX_151559495_f 0 +
- chrX 151564643 151564711 NM_018558_exon_2_0_chrX_151564644_f 0 +
-
-
-
+
+ delimiters to TAB
+
+ python
+
+
+ python '$__tool_directory__/convert_characters.py'
+ '${input}'
+ '${convert_from}'
+ '${out_file1}'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+**What it does**
+
+Converts all delimiters of a specified type into TABs. Consecutive characters are condensed. For example, if columns are separated by 5 spaces they will converted into 1 tab.
+
+-----
+
+**Example**
+
+- Input file::
+
+ chrX||151283558|151283724|NM_000808_exon_8_0_chrX_151283559_r|0|-
+ chrX|151370273|151370486|NM_000808_exon_9_0_chrX_151370274_r|0|-
+ chrX|151559494|151559583|NM_018558_exon_1_0_chrX_151559495_f|0|+
+ chrX|151564643|151564711|NM_018558_exon_2_0_chrX_151564644_f||||0|+
+
+- Converting all pipe delimiters of the above file to TABs will get::
+
+ chrX 151283558 151283724 NM_000808_exon_8_0_chrX_151283559_r 0 -
+ chrX 151370273 151370486 NM_000808_exon_9_0_chrX_151370274_r 0 -
+ chrX 151559494 151559583 NM_018558_exon_1_0_chrX_151559495_f 0 +
+ chrX 151564643 151564711 NM_018558_exon_2_0_chrX_151564644_f 0 +
+
+
+