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