diff formatter.py @ 1:364976b9aba6 draft

"planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 67040e686204e86c07ec46ca90129e50e40eb737"
author recetox
date Tue, 11 Jan 2022 15:13:57 +0000
parents 0a08bed94964
children 4ca9807c56e6
line wrap: on
line diff
--- a/formatter.py	Sat Oct 30 13:48:25 2021 +0000
+++ b/formatter.py	Tue Jan 11 15:13:57 2022 +0000
@@ -73,8 +73,8 @@
     Returns:
         DataFrame: Joined dataframe on compounds containing scores an matches in long format.
     """
-    matches = read_csv(matches_filename, sep='\t', index_col=0)
-    scores = read_csv(scores_filename, sep='\t', index_col=0)
+    matches = read_csv(matches_filename, sep=None, index_col=0)
+    scores = read_csv(scores_filename, sep=None, index_col=0)
 
     scores_long = create_long_table(scores, 'score')
     matches_long = create_long_table(matches, 'matches')
@@ -113,8 +113,11 @@
 
 @cli.resultcallback()
 def write_output(result: DataFrame, scores_filename, matches_filename, output_filename):
+    input_file = read_csv(scores_filename, sep=None, iterator=True)
+    sep = input_file._engine.data.dialect.delimiter
+
     result = result.reset_index().rename(columns={'level_0': 'query', 'compound': 'reference'})
-    result.to_csv(output_filename, sep="\t", index=False)
+    result.to_csv(output_filename, sep=sep, index=False)
 
 
 if __name__ == '__main__':