changeset 3:ae7843d06f8f draft default tip

"planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/merge_cols commit ed2daf7024ea79a04bbb4a0896b9402ab2daf89f"
author devteam
date Thu, 16 Jul 2020 04:37:14 -0400
parents dd40b1e9eebe
children
files mergeCols.py mergeCols.xml
diffstat 2 files changed, 24 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/mergeCols.py	Wed Jun 03 10:22:39 2020 -0400
+++ b/mergeCols.py	Thu Jul 16 04:37:14 2020 -0400
@@ -2,31 +2,25 @@
 
 
 def __main__():
-    try:
-        infile = open(sys.argv[1], 'r')
-        outfile = open(sys.argv[2], 'w')
-    except Exception:
-        sys.exit('Cannot open or create a file\n')
-
     if len(sys.argv) < 4:
         sys.exit('No columns to merge\n')
     else:
         cols = sys.argv[3:]
 
-    skipped_lines = 0
+    with open(sys.argv[1], 'r') as infile, open(sys.argv[2], 'w') as outfile:
+        skipped_lines = 0
+        for line in infile:
+            line = line.rstrip('\r\n')
+            if line and not line.startswith('#'):
+                fields = line.split('\t')
+                line += '\t'
+                for col in cols:
+                    try:
+                        line += fields[int(col) - 1]
+                    except Exception:
+                        skipped_lines += 1
 
-    for line in infile:
-        line = line.rstrip('\r\n')
-        if line and not line.startswith('#'):
-            fields = line.split('\t')
-            line += '\t'
-            for col in cols:
-                try:
-                    line += fields[int(col) - 1]
-                except Exception:
-                    skipped_lines += 1
-
-            print(line, file=outfile)
+            outfile.write("{}\n".format(line))
 
     if skipped_lines > 0:
         print('Skipped %d invalid lines' % skipped_lines)
--- a/mergeCols.xml	Wed Jun 03 10:22:39 2020 -0400
+++ b/mergeCols.xml	Thu Jul 16 04:37:14 2020 -0400
@@ -1,18 +1,18 @@
-<tool id="mergeCols1" name="Merge Columns" version="1.0.2">
+<tool id="mergeCols1" name="Merge Columns" version="1.0.3" profile="16.04">
   <description>together</description>
   <requirements>
     <requirement type="package" version="3.7">python</requirement>
   </requirements>
-  <command interpreter="python">
-   mergeCols.py 
-      "${input1}"
-      "${out_file1}"
-      "${col1}"
-      "${col2}"
-      #for $col in $columns
-        ${col.datacol}
-      #end for
-  </command>
+  <command><![CDATA[
+python '$__tool_directory__/mergeCols.py'
+"${input1}"
+"${out_file1}"
+"${col1}"
+"${col2}"
+#for $col in $columns
+  ${col.datacol}
+#end for
+  ]]></command>
   <inputs>
     <param format="tabular" name="input1" type="data" label="Select data" help="Dataset missing? See TIP below."/>
     <param name="col1" label="Merge column" type="data_column" data_ref="input1" />