-
Notifications
You must be signed in to change notification settings - Fork 5
/
generate_products.py
executable file
·55 lines (43 loc) · 1.57 KB
/
generate_products.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
from antismash.detection import hmm_detection
STATEMENT = """
CREATE TABLE antismash.bgc_categories (
category text PRIMARY KEY,
description text UNIQUE NOT NULL
);
COMMENT ON TABLE antismash.bgc_categories IS
'Biosynthetic gene cluster categories according to MIBiG spec.';
--- basic MIBiG types
INSERT INTO antismash.bgc_categories (category, description)
VALUES
('pks', 'Polyketide'),
('nrps', 'Nonribosomal peptide'),
('ripp', 'Ribosomally synthesized and post-translationally modified peptide'),
('terpene', 'Terpene'),
('saccharide', 'Saccharide'),
('alkaloid', 'Alkaloid'),
('other', 'Other');
CREATE TABLE antismash.bgc_types (
bgc_type_id serial NOT NULL,
term text NOT NULL,
description text NOT NULL,
category text NOT NULL,
CONSTRAINT bgc_types_pkey PRIMARY KEY (bgc_type_id),
CONSTRAINT bgc_types_term_unique UNIQUE (term),
CONSTRAINT bgc_types_category_fkey FOREIGN KEY (category) REFERENCES antismash.bgc_categories (category)
);
COMMENT ON TABLE antismash.bgc_types IS
'Biosynthetic gene cluster types.';
--- More detailed antiSMASH types
INSERT INTO antismash.bgc_types (term, description, category)
SELECT val.term, val.description, val.parent_term
FROM (
VALUES
{0}
) val ( term, description, parent_term );"""
rules = hmm_detection._get_rules("relaxed")
lines = []
for rule in rules:
name = rule.name
lines.append((name.lower(), rule.description, rule.category.lower())) # TODO remove lowering
print(STATEMENT.format(",\n ".join(map(str, lines))))