diff table2geojson.xml @ 2:402faa5eab62 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/geopandas commit 28236fa503017adc781fc8e7bee547eeb44182f2
author iuc
date Tue, 18 Nov 2025 22:46:21 +0000
parents fb5081261c10
children
line wrap: on
line diff
--- a/table2geojson.xml	Mon Jun 30 09:28:17 2025 +0000
+++ b/table2geojson.xml	Tue Nov 18 22:46:21 2025 +0000
@@ -1,10 +1,10 @@
-<tool id="geopandas_table2geojson" name="Table to GeoJSON" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="24.2" license="MIT">
+<tool id="geopandas_table2geojson" name="Table to GeoJSON" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@" license="MIT">
     <description></description>
     <macros>
         <token name="@TOOL_VERSION@">1.1.1</token>
-        <token name="@VERSION_SUFFIX@">0</token>
+        <token name="@VERSION_SUFFIX@">1</token>
+        <token name="@PROFILE@">24.2</token>
     </macros>
-
     <requirements>
         <requirement type="package" version="@TOOL_VERSION@">geopandas</requirement>
     </requirements>
@@ -16,23 +16,26 @@
 import json
 import pandas as pd
 import geopandas as gpd
-df = pd.read_csv('$infile', encoding="utf-8")
+
+df = pd.read_csv('$infile', encoding="utf-8", sep=None, engine='python', header=None if '$has_header' == "false" else 0)
 
-#set exc = [int($col) - 1 for $col in $exclude_columns]
-#set inc = [int($col) - 1 for $col in $include_columns]
+inc = [int(x)-1 for x in str('$include_columns').split(",") if x.strip().isdigit()] if '$include_columns' and str('$include_columns').lower() != "none" else []
+exc = [int(x)-1 for x in str('$exclude_columns').split(",") if x.strip().isdigit()] if '$exclude_columns' and str('$exclude_columns').lower() != "none" else []
+
 property_df = df
 
-if "$include_columns" != "None":
-    property_df = df.iloc[:, $inc]
+if inc:
+    property_df = df.iloc[:, inc]
+if exc:
+    property_df = property_df.drop(columns=df.columns[exc])
 
-if "$exclude_columns" != "None":
-    property_df = df.drop(columns=df.columns[$exc])
-       
 gdf = gpd.GeoDataFrame(
     property_df,
-    geometry=gpd.points_from_xy(df.iloc[:,$lat_column-1], df.iloc[:,$long_column-1]),
-    crs="$crs",
-    )
+    geometry=gpd.points_from_xy(
+        df.iloc[:, int($lat_column)-1],   
+        df.iloc[:, int($long_column)-1]),
+    crs="$crs"
+)
         
 # drop_id: bool, default: False
 data = json.loads(gdf.to_json())
@@ -43,8 +46,9 @@
     </configfiles>
     <inputs>
         <param name="infile" type="data" format="csv,tabular,tsv" label="The file you want to convert"/>
-        <param name="lat_column" type="data_column" data_ref="infile" use_header_names="true" label="Latitude column"/>
-        <param name="long_column" type="data_column" data_ref="infile" use_header_names="true" label="Longitude column"/>
+        <param name="has_header" type="boolean" truevalue="true" falsevalue="false" label="First row contains column names (header)?" help="Does your input file consists of a header"/>
+        <param name="lat_column" type="integer" value="1" label="Latitude column"/>
+        <param name="long_column" type="integer" value="2" label="Longitude column"/>
         <param name="include_columns" type="data_column" data_ref="infile" use_header_names="true" multiple="true" optional="true"
             label="Include the following columns" help="Either include or exclude columns, by default, all columns will be taken over into the properties field"/>
         <param name="exclude_columns" type="data_column" data_ref="infile" use_header_names="true" multiple="true" optional="true"
@@ -61,6 +65,7 @@
     <tests>
         <test expect_num_outputs="1">
             <param name="infile" value="geolocation.csv"/>
+            <param name="has_header" value="true"/>
             <param name="lat_column" value="1"/>
             <param name="long_column" value="2"/>
             <param name="crs" value="EPSG:3857"/>
@@ -78,7 +83,21 @@
             </output>
         </test>
         <test expect_num_outputs="1">
+            <param name="infile" value="geolocation_without_header.csv"/>
+            <param name="has_header" value="false"/>
+            <param name="lat_column" value="1"/>
+            <param name="long_column" value="2"/>
+            <param name="crs" value="EPSG:3857"/>
+            <output name="outfile">
+                <assert_contents>
+                    <has_json_property_with_text property="type" text="FeatureCollection"/>
+                    <has_n_lines n="371"/>
+                </assert_contents>
+            </output>
+        </test>
+        <test expect_num_outputs="1">
             <param name="infile" value="geolocation.csv"/>
+            <param name="has_header" value="true"/>
             <param name="lat_column" value="1"/>
             <param name="long_column" value="2"/>
             <param name="include_columns" value="3,4"/>
@@ -95,6 +114,7 @@
         </test>
         <test expect_num_outputs="1">
             <param name="infile" value="geolocation.csv"/>
+            <param name="has_header" value="true"/>
             <param name="lat_column" value="1"/>
             <param name="long_column" value="2"/>
             <param name="exclude_columns" value="5"/>