Repository 'matchms_split'
hg clone https://toolshed.g2.bx.psu.edu/repos/recetox/matchms_split

Changeset 18:05b91d5045ce (2024-04-22)
Previous changeset 17:3155f877b9d5 (2024-04-16) Next changeset 19:072c7a101da6 (2024-05-30)
Commit message:
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit c626c8db7ba4dd30f85f7086e16e1e2413e36bd8
removed:
formatter.py
b
diff -r 3155f877b9d5 -r 05b91d5045ce formatter.py
--- a/formatter.py Tue Apr 16 11:23:36 2024 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
@@ -1,51 +0,0 @@
-import click
-from matchms.importing import scores_from_json
-from pandas import DataFrame
-
-
-def scores_to_dataframe(scores):
-    """Unpack scores from matchms.scores into two dataframes of scores and matches.
-
-    Args:
-        scores (matchms.scores): matchms.scores object.
-
-    Returns:
-        DataFrame: Scores
-        DataFrame: Matches
-    """
-    data = []
-
-    for i, (row, col) in enumerate(zip(scores.scores.row, scores.scores.col)):
-        data.append([scores.queries[col].metadata['compound_name'], scores.references[row].metadata['compound_name'], *scores.scores.data[i]])
-
-    dataframe = DataFrame(data, columns=['query', 'reference', *scores.scores.score_names])
-
-    return dataframe
-
-
-def load_data(scores_filename: str) -> DataFrame:
-    """Load data from filenames and join on compound id.
-
-    Args:
-        scores_filename (str): Path to json file with serialized scores.
-
-    Returns:
-        DataFrame: Joined dataframe on compounds containing scores and matches in long format.
-    """
-    scores = scores_from_json(scores_filename)
-    scores = scores_to_dataframe(scores)
-
-    return scores
-
-
-@click.group(invoke_without_command=True)
-@click.option('--sf', 'scores_filename', type=click.Path(exists=True), required=True)
-@click.option('--o', 'output_filename', type=click.Path(writable=True), required=True)
-def cli(scores_filename, output_filename):
-    result = load_data(scores_filename)
-    result.to_csv(output_filename, sep="\t", index=False)
-    pass
-
-
-if __name__ == '__main__':
-    cli()