changeset 1:d0960e1b25a8 draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/imagecoordinates_flipaxis/ commit da043bdec956714abb0fa82f278931bbe1a6d41d
author imgteam
date Mon, 25 Mar 2019 11:15:54 -0400
parents 5a210baa2ff1
children f8f1100d0701
files imagecoordinates_flipaxis.py imagecoordinates_flipaxis.xml test-data/out.tsv test-data/out2.tsv test-data/out_offset.tsv
diffstat 5 files changed, 32 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/imagecoordinates_flipaxis.py	Wed Mar 20 12:06:07 2019 -0400
+++ b/imagecoordinates_flipaxis.py	Mon Mar 25 11:15:54 2019 -0400
@@ -2,12 +2,12 @@
 import pandas as pd
 
 
-def imagecoordinates_flipyaxis(input_file, output_file, image_height):
+def imagecoordinates_flipyaxis(input_file, output_file, image_height, offset=[0,0]):
     df = pd.read_csv(input_file, sep='\t')
 
     x = df.copy().y # create copy instead of view
-    df.y = image_height-(df.x + 1) # since maximal y index = height-1 
-    df.x = x
+    df.y = image_height-(df.x + 1) + offset[1] # since maximal y index = height-1 
+    df.x = x + offset[0]
     df.to_csv(output_file, sep="\t", index=False)
 
 
@@ -16,8 +16,9 @@
     parser = argparse.ArgumentParser()
     parser.add_argument('input_file', type=argparse.FileType('r'), help='original file')
     parser.add_argument('out_file_str', type=str, help='string of output file name')
-    # parser.add_argument('image_height', help='height of image')
     parser.add_argument('image_height', type=int, help='height of image')
+    parser.add_argument('offset_x', type=int, help='offset in x direction (width)', default=0)
+    parser.add_argument('offset_y', type=int, help='offset in y direction (height)', default=0)
     args = parser.parse_args()
-    imagecoordinates_flipyaxis(args.input_file.name, args.out_file_str, args.image_height)
+    imagecoordinates_flipyaxis(args.input_file.name, args.out_file_str, args.image_height, [args.offset_x, args.offset_y])
     # imagecoordinates_flipyaxis(args.input_file.name, args.out_file_str, int(args.image_height))
--- a/imagecoordinates_flipaxis.xml	Wed Mar 20 12:06:07 2019 -0400
+++ b/imagecoordinates_flipaxis.xml	Mon Mar 25 11:15:54 2019 -0400
@@ -6,20 +6,30 @@
   <command detect_errors="aggressive"> 
         <![CDATA[
         python "$__tool_directory__/imagecoordinates_flipaxis.py" '$input' '$output' $img_height
+        $offset_x $offset_y
         ]]> 
   </command>
   <inputs> 
     <param name="input" type="data" format="tabular" label="File with image coordinates"/> 
     <param name="img_height" type="integer" value="100" label="Height of the corresponding image"/>
-  </inputs>
+    <param name="offset_x" type="integer" value="0" label="Added offset in x direction (=width direction)" />
+    <param name="offset_y" type="integer" value="0" label="Added offset in y direction (=height direction)" />
+    </inputs>
   <outputs>
     <data name="output" format="tabular"/>
   </outputs>
   <tests>
     <test>
 	    <param name="input" value="table.tsv" />
+      <output name="output" value="out.tsv" ftype="tabular" />
       <param name="img_height" value="500"/>
-      <output name="output" value="out2.tsv" ftype="tabular" />
+    </test>
+    <test>
+	    <param name="input" value="table.tsv" />
+      <output name="output" value="out_offset.tsv" ftype="tabular" />
+      <param name="img_height" value="500"/>
+      <param name="offset_x" value="1"/>
+      <param name="offset_y" value="2"/>
     </test>
   </tests>
   <help>Makes x the horizontal axis (left to right) and y the vertical axis (bottom to top), 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/out.tsv	Mon Mar 25 11:15:54 2019 -0400
@@ -0,0 +1,7 @@
+x	y
+4	495
+104	494
+204	493
+34	492
+4	491
+4	490
--- a/test-data/out2.tsv	Wed Mar 20 12:06:07 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-x	y
-4	495
-104	494
-204	493
-34	492
-4	491
-4	490
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/out_offset.tsv	Mon Mar 25 11:15:54 2019 -0400
@@ -0,0 +1,7 @@
+x	y
+5	497
+105	496
+205	495
+35	494
+5	493
+5	492