annotate table_pandas_rename_columns_regex.py @ 0:505a8e975968 draft default tip

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
author recetox
date Wed, 29 Jan 2025 15:35:08 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
1 import argparse
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
2 import logging
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
3 import re
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
4 from typing import List, Tuple
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
5
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
6
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
7 import pandas as pd
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
8 from utils import LoadDataAction, SplitColumnIndicesAction, StoreOutputAction
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
9
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
10
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
11 def rename_columns(
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
12 df: pd.DataFrame, columns: List[int], regex_check: str, regex_replace: str
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
13 ) -> pd.DataFrame:
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
14 """
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
15 Rename columns in the dataframe based on regex patterns.
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
16
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
17 Parameters:
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
18 df (pd.DataFrame): The input dataframe.
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
19 columns (List[int]): The 0-based indices of the columns to rename.
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
20 regex_check (str): The regex pattern to check for in column names.
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
21 regex_replace (str): The regex pattern to replace with in column names.
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
22
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
23 Returns:
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
24 pd.DataFrame: The dataframe with renamed columns.
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
25 """
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
26 try:
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
27 # Map column indices to column names
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
28 column_names = [df.columns[i] for i in columns]
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
29
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
30 # Rename the specified columns using the regex patterns
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
31 for column in column_names:
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
32 if column in df.columns:
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
33 new_column_name = re.sub(regex_check, regex_replace, column)
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
34 df.rename(columns={column: new_column_name}, inplace=True)
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
35 return df
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
36 except IndexError as e:
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
37 logging.error(f"Invalid column index: {e}")
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
38 raise
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
39 except re.error as e:
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
40 logging.error(f"Invalid regex pattern: {e}")
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
41 raise
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
42 except Exception as e:
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
43 logging.error(f"Error renaming columns: {e}")
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
44 raise
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
45
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
46
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
47 def main(
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
48 input_dataset: pd.DataFrame,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
49 columns: List[int],
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
50 regex_check: str,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
51 regex_replace: str,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
52 output_dataset: Tuple[callable, str],
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
53 ) -> None:
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
54 """
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
55 Main function to load the dataset, rename columns, and save the result.
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
56
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
57 Parameters:
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
58 input_dataset (Tuple[pd.DataFrame, str]): The input dataset and its file extension.
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
59 columns (List[int]): The 0-based indices of the columns to rename.
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
60 regex_check (str): The regex pattern to check for in column names.
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
61 regex_replace (str): The regex pattern to replace with in column names.
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
62 output_dataset (Tuple[callable, str]): The output dataset and its file extension.
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
63 """
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
64 try:
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
65 write_func, file_path = output_dataset
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
66 write_func(rename_columns(input_dataset, columns, regex_check, regex_replace), file_path)
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
67 except Exception as e:
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
68 logging.error(f"Error in main function: {e}")
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
69 raise
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
70
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
71
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
72 if __name__ == "__main__":
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
73 logging.basicConfig(level=logging.INFO)
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
74 parser = argparse.ArgumentParser(
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
75 description="Apply regex-based transformations on multiple dataframe columns."
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
76 )
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
77 parser.add_argument(
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
78 "--input_dataset",
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
79 nargs=2,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
80 action=LoadDataAction,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
81 required=True,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
82 help="Path to the input dataset and its file extension (csv, tsv, parquet)",
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
83 )
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
84 parser.add_argument(
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
85 "--columns",
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
86 action=SplitColumnIndicesAction,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
87 required=True,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
88 help="Comma-separated list of 1-based indices of the columns to apply the transformation on",
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
89 )
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
90 parser.add_argument(
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
91 "--regex_check",
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
92 type=str,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
93 required=True,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
94 help="Regex pattern to check for in column names",
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
95 )
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
96 parser.add_argument(
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
97 "--regex_replace",
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
98 type=str,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
99 required=True,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
100 help="Regex pattern to replace with in column names",
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
101 )
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
102 parser.add_argument(
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
103 "--output_dataset",
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
104 nargs=2,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
105 action=StoreOutputAction,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
106 required=True,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
107 help="Path to the output dataset and its file extension (csv, tsv, parquet)",
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
108 )
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
109
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
110 args = parser.parse_args()
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
111 main(
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
112 args.input_dataset,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
113 args.columns,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
114 args.regex_check,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
115 args.regex_replace,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
116 args.output_dataset,
505a8e975968 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/tables commit d0ff40eb2b536fec6c973c3a9ea8e7f31cd9a0d6
recetox
parents:
diff changeset
117 )