1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/633c27341859/ Changeset: 633c27341859 User: dannon Date: 2014-06-09 16:52:03 Summary: Merged in saketkc/galaxy-fork (pull request #403) PEP8 fixes, close find handles for 'convert delimiters to tab' tool Affected #: 1 file diff -r 42d46284ef22b9520b637661d3f15e31b5f5379a -r 633c27341859df116d2dd039bb16e9c29bedd65a tools/filters/convert_characters.py --- a/tools/filters/convert_characters.py +++ b/tools/filters/convert_characters.py @@ -1,52 +1,57 @@ #!/usr/bin/env python #By, Guruprasad Ananda. -from galaxy import eggs -import sys, re +import sys +import re + 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") try: - fin = open(sys.argv[1],'r') + fin = open(sys.argv[1], 'r') except: stop_err("Input file cannot be opened for reading.") - + from_char = sys.argv[2] - + try: - fout = open(sys.argv[3],'w') + fout = open(sys.argv[3], 'w') except: stop_err("Output file cannot be opened for writing.") - - char_dict = { + + char_dict = { 'T': '\t', - 's': '\s', + 's': '\s', 'Dt': '\.', 'C': ',', 'D': '-', - 'U': '_', + 'U': '_', 'P': '\|', 'Co': ':', 'Sc': ';' } - from_ch = char_dict[from_char] + '+' #making an RE to match 1 or more occurences. + # regexp 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))) + fout.write("%s\n" % (re.sub(from_ch, '\t', line))) except: skipped += 1 - + + fin.close() + fout.close() 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() Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.