comparison harmonize2antismash.py @ 5:bc88856eddab draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
author bgruening
date Tue, 05 Jul 2022 10:37:38 +0000
parents
children
comparison
equal deleted inserted replaced
4:e78e25d3b4bd 5:bc88856eddab
1 #!/usr/bin/env python
2 import json
3 import sys
4
5
6 output = {
7 "tool": {
8 "name": "hAMRonize",
9 "version": "?",
10 "description": "Tool for combining results",
11 "configuration": {
12 "verbose": "true", "multisetting": ["first", "second"]
13 },
14 },
15 "records": [],
16 }
17
18 with open(sys.argv[1], "r") as handle:
19 records = json.load(handle)
20
21 for i in records:
22 start = i["input_gene_start"]
23 end = i["input_gene_stop"]
24 label = i["gene_name"]
25 seqid = i["input_sequence_id"]
26
27 score = i["sequence_identity"]
28 if start <= end:
29 fstart = start - 1
30 fend = end
31 else:
32 fstart = end - 1
33 fend = start
34
35 record = {
36 "name": seqid,
37 "subregions": [
38 {
39 "start": fstart,
40 "end": fend,
41 "label": label,
42 "details": {"score": str(score)},
43 }
44 ],
45 }
46 output["records"].append(record)
47
48
49 with open(sys.argv[2], "w") as handle:
50 json.dump(output, handle, indent=2)