diff add_input_name_as_column.py @ 6:3284b72eef56 draft default tip

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/add_input_name_as_column commit 9292c57c34283543e86ecc65f805977224f6fc7b"
author iuc
date Wed, 25 Mar 2020 07:11:05 -0400
parents 06061aa49527
children
line wrap: on
line diff
--- a/add_input_name_as_column.py	Wed Mar 06 09:16:29 2019 -0500
+++ b/add_input_name_as_column.py	Wed Mar 25 07:11:05 2020 -0400
@@ -1,5 +1,5 @@
+import argparse
 import io
-import argparse
 
 
 def Parser():
@@ -8,6 +8,8 @@
     the_parser.add_argument('--output', required=True, action="store", type=str, help="output file path")
     the_parser.add_argument('--label', required=True, action="store", type=str, help="label to add in last column")
     the_parser.add_argument('--header', action="store", type=str, help="column label for last column")
+    the_parser.add_argument('--prepend', action='store_true', default=False, help='Prepend column instead of appending' )
+
     args = the_parser.parse_args()
     return args
 
@@ -19,7 +21,11 @@
     for i, line in enumerate(input):
         line = line.strip('\n')
         if (i == 0) and args.header:
-            line = "%s\t%s\n" % (line, args.header)
+            new_entry = args.header
         else:
-            line = "%s\t%s\n" % (line, args.label)
+            new_entry = args.label
+        if args.prepend:
+            line = "%s\t%s\n" % (new_entry, line)
+        else:
+            line = "%s\t%s\n" % (line, new_entry)
         output.write(line)