comparison matchms_networking_wrapper.py @ 5:8147d93d372d draft

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit f79a5b51599254817727bc9028b9797ea994cb4e
author recetox
date Tue, 27 Jun 2023 14:29:16 +0000
parents e4ec3592507f
children 0fd1e5d4ca3c
comparison
equal deleted inserted replaced
4:8ae521f89988 5:8147d93d372d
6 6
7 7
8 def main(argv): 8 def main(argv):
9 parser = argparse.ArgumentParser(description="Create network-graph from similarity scores.") 9 parser = argparse.ArgumentParser(description="Create network-graph from similarity scores.")
10 parser.add_argument("--graph_format", type=str, help="Format of the output similarity network.") 10 parser.add_argument("--graph_format", type=str, help="Format of the output similarity network.")
11 parser.add_argument("--score_name", type=str, help="Name of the score layer to use for creating the network graph.")
11 parser.add_argument("--identifier", type=str, help="Unique metadata identifier of each spectrum from which scores are computed.") 12 parser.add_argument("--identifier", type=str, help="Unique metadata identifier of each spectrum from which scores are computed.")
12 parser.add_argument("--top_n", type=int, help="Number of highest-score edges to keep.") 13 parser.add_argument("--top_n", type=int, help="Number of highest-score edges to keep.")
13 parser.add_argument("--max_links", type=int, help="Maximum number of links to add per node.") 14 parser.add_argument("--max_links", type=int, help="Maximum number of links to add per node.")
14 parser.add_argument("--score_cutoff", type=float, help="Minimum similarity score value to link two spectra.") 15 parser.add_argument("--score_cutoff", type=float, help="Minimum similarity score value to link two spectra.")
15 parser.add_argument("--link_method", type=str, help="Method for selecting top N edges for each node.") 16 parser.add_argument("--link_method", type=str, help="Method for selecting top N edges for each node.")
16 parser.add_argument("--keep_unconnected_nodes", help="Keep unconnected nodes in the network.", action="store_true") 17 parser.add_argument("--keep_unconnected_nodes", help="Keep unconnected nodes in the network.", action="store_true")
17 parser.add_argument("scores", type=str, help="Path to matchMS similarity-scores .json file.") 18 parser.add_argument("scores", type=str, help="Path to matchms similarity-scores .json file.")
18 parser.add_argument("output_filename", type=str, help="Path where to store the output similarity network.") 19 parser.add_argument("output_filename", type=str, help="Path where to store the output similarity network.")
19 args = parser.parse_args() 20 args = parser.parse_args()
20 21
21 scores = scores_from_json(args.scores) 22 scores = scores_from_json(args.scores)
22 23
25 max_links=args.max_links, 26 max_links=args.max_links,
26 score_cutoff=args.score_cutoff, 27 score_cutoff=args.score_cutoff,
27 link_method=args.link_method, 28 link_method=args.link_method,
28 keep_unconnected_nodes=args.keep_unconnected_nodes) 29 keep_unconnected_nodes=args.keep_unconnected_nodes)
29 30
30 network.create_network(scores) 31 network.create_network(scores, args.score_name)
31 network.export_to_file(filename=args.output_filename, graph_format=args.graph_format) 32 network.export_to_file(filename=args.output_filename, graph_format=args.graph_format)
32 33
33 return 0 34 return 0
34 35
35 36