Mercurial > repos > bgruening > antismash
annotate harmonize2antismash.py @ 31:2186d516fffb 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:00 +0000 |
parents | |
children |
rev | line source |
---|---|
31
2186d516fffb
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 |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
2 import json |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
3 import sys |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
4 |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
5 |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
6 output = { |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
7 "tool": { |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
8 "name": "hAMRonize", |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
9 "version": "?", |
2186d516fffb
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", |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
11 "configuration": { |
2186d516fffb
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"] |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
13 }, |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
14 }, |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
15 "records": [], |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
16 } |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
17 |
2186d516fffb
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: |
2186d516fffb
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) |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
20 |
2186d516fffb
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: |
2186d516fffb
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"] |
2186d516fffb
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"] |
2186d516fffb
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"] |
2186d516fffb
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"] |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
26 |
2186d516fffb
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"] |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
28 if start <= end: |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
29 fstart = start - 1 |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
30 fend = end |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
31 else: |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
32 fstart = end - 1 |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
33 fend = start |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
34 |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
35 record = { |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
36 "name": seqid, |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
37 "subregions": [ |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
38 { |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
39 "start": fstart, |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
40 "end": fend, |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
41 "label": label, |
2186d516fffb
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)}, |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
43 } |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
44 ], |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
45 } |
2186d516fffb
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) |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
47 |
2186d516fffb
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/antismash commit dc45770442ff516d6f3733e4bdb284be3163de67
bgruening
parents:
diff
changeset
|
48 |
2186d516fffb
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: |
2186d516fffb
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) |