kazius-alerts 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fd5c89372096f5368e0a985fd5aa755be37784ea
4
+ data.tar.gz: 2d4e65adeff7ed18b4bad037cd67f83c3d1884b9
5
+ SHA512:
6
+ metadata.gz: 627e56312fa5e7bf364c18e447efc2ec96327d9ff67625bb62e64fcd7d8a7e0bab1f2bb38924fb2b99a34c9d73c5e5ae1c2518ec2aa5047a73c1c40f9dfe2359
7
+ data.tar.gz: 4bcb57fdb14ec488fd19488cb28c1fbbb3aac68e9e35b32bb17fd42bf516819af824896f78cb69e0b50b9435c048356edaffeef2315bc4754401379de6801ada
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "kazius-alerts"
3
+ s.version = "0.0.1"
4
+ s.authors = ["Christoph Helma"]
5
+ s.email = ["helma@in-silico.ch"]
6
+ s.homepage = "http://github.com/opentox/kazius-alerts"
7
+ s.summary = %q{Kazius structural alerts}
8
+ s.license = 'GPL-3.0'
9
+
10
+ s.rubyforge_project = "kazius-alerts"
11
+ s.files = `git ls-files`.split("\n")
12
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ s.require_paths = ["lib"]
14
+ end
@@ -0,0 +1,109 @@
1
+ re 'openbabel'
2
+
3
+ class KaziusAlerts
4
+
5
+ SMARTS = [ # name, smarts, excluded smarts
6
+ ["specific arom nitro", 'O=N(~O)a', 'O=N(O)c[$(aS(=O)=O),$(aaS(=O)=O),$(aaaS(=O)=O),$(aC((F)F)F),$(aaC((F)F)F),$(aaaC((F)F)F)]'],
7
+ ["specific arom amine", 'a[NH2]', '[NH2]a[$(a[$(C((F)F)F),$(S(=O)=O),$(C(=O)O)]),$(aa[$(C((F)F)F),$(S(=O)=O),$(C(=O)O)]),$(aaa[$(C((F)F)F),$(S(=O)=O),$(C(=O)O)])]'],
8
+ ["aromatic nitroso", 'a[N;X2]=O'],
9
+ ["alkyl nitrite", 'CO[N;X2]=O'],
10
+ ["nitrosamine", 'N[N;X2]=O'],
11
+ ["epoxide", 'O1[c,C]-[c,C]1'],
12
+ ["aziridine", 'C1NC1'],
13
+ ["azide", 'N=[N+]=[N-]'],
14
+ ["diazo", 'C=[N+]=[N-]'],
15
+ ["triazene", 'N=N-N'],
16
+ ["aromatic azo", 'c[N;X2]!@;=[N,X2]c', '[$([N;X2]([$(acS((=O)=O)),$(aacS((=O)=O)),$(aaacS((=O)=O)),$(aaaacS((=O)=O))])=[N;X2][$(acS((=O)=O)),$(aacS((=O)=O)),$(aaacS((=O)=O)),$(aaaacS((=O)=O))])]'],
17
+ ["unsubstituted heteroatom-bonded heteroatom", '[OH,NH2][N,O]', 'O=N(O)[O-]'],
18
+ ["aromatic", '[OH]Na'],
19
+ ["aliphatic halide", '[Cl,Br,I]C'],
20
+ ["carboxylic acid halide", '[Cl,Br,I]C=O'],
21
+ ["nitrogen or sulphur mustard", '[N,S]!@[C;X4]!@[CH2][Cl,Br,I]'],
22
+ ["bay region in PAHs", '[cH]1[cH]ccc2c1c3c(cc2)cc[cH][cH]3'],
23
+ ["k-region in PAHs", '[cH]1cccc2c1[cH][cH]c3c2ccc[cH]3'],
24
+ ["polycyclic aromatic system", '[$(a13~a~a~a~a2~a1~a(~a~a~a3)~a~a~a2),$(a1~a~a~a2~a1~a~a3~a(~a2)~a~a~a3),$(a1~a~a~a2~a1~a~a~a3~a2~a~a~a3),$(a1~a~a~a~a2~a1~a3~a(~a2)~a~a~a~a3),$(a1~a~a~a~a2~a1~a~a3~a(~a2)~a~a~a3),$(a1~a~a~a~a2~a1~a~a3~a(~a2)~a~a~a~a3),$(a1~a~a~a~a2~a1~a~a~a3~a2~a~a~a3),$(a1~a~a~a~a2~a1~a~a~a3~a2~a~a~a~a3),$(a13~a~a~a~a2~a1~a(~a~a~a3)~a~a2)]'], # smarts error of original smarts fixed
25
+ ["sulphonate bonded carbon", '[$([C,c]OS((=O)=O)O!@[c,C]),$([c,C]S((=O)=O)O!@[c,C])]'],
26
+ ["aliphatic N-nitro", 'O=N(~O)N'],
27
+ ["alpha,beta unsaturated aldehyde", '[$(O=[CH]C=C),$(O=[CH]C=O)]', '[$(O=[CH]C([N,O,S])=C),$(O=[CH]C=C[N,O,S]),$(O=[CH]C=Ca)]'],
28
+ ["diazonium", '[N;v4]#N'],
29
+ ["beta-propriolactone", 'O=C1CCO1'],
30
+ ["alpha,beta unsaturated alkoxy group", '[CH]=[CH]O'],
31
+ ["1-aryl-2-monoalkyl hydrazine", '[NH;!R][NH;!R]a'],
32
+ ["aromatic methylamine", '[CH3][NH]a', '[CH3][NH]a[$(a[$(C((F)F)F),$(S=O),$(C(=O)O)]),$(aa[$(C((F)F)F),$(S=O),$(C(=O)O)]),$(aaa[$(C((F)F)F),$(S=O),$(C(=O)O)])]'],
33
+ ["ester derivative of aromatic hydroxylamine", 'aN([$([OH]),$(O*=O)])[$([#1]),$(C(=O)[CH3]),$([CH3]),$([OH]),$(O*=O)]'],
34
+ ["polycyclic planar system", '[$([X2,X3]13~[X2,X3]~[X2,X3]~[X2,X3]~[X2,X3]2~[X2,X3]1~[X2,X3
35
+ ](~[X2,X3]~[X2,X3]~[X2,X3]3)~[X2,X3]~[X2,X3]~[X2,X3]2),$([X2,X3]1~[X2,X3]~[X2,X3]~[X2,X3]2~[X2,
36
+ X3]1~[X2,X3]~[X2,X3]3~[X2,X3](~[X2,X3]2)~[X2,X3]~[X2,X3]~[X2,X3]3),$([X2,X3]1~[X2,X3]~[X2,X3]~[
37
+ X2,X3]2~[X2,X3]1~[X2,X3]~[X2,X3]~[X2,X3]3~[X2,X3]2~[X2,X3]~[X2,X3]~[X2,X3]3),$([X2,X3]1~[X2,X3]
38
+ ~[X2,X3]~[X2,X3]~[X2,X3]2~[X2,X3]1~[X2,X3]3~[X2,X3](~[X2,X3]2)~[X2,X3]~[X2,X3]~[X2,X3]~[X2,X3]3),$([X2,X3]1~[X2,X3]~[X2,X3]~[X2,X3]~[X2,X3]2~[X2,X3]1~[X2,X3]~[X2,X3]3~[X2,X3](~[X2,X3]2)~[X2,X3]~[X2,X3]~[X2,X3]3),$([X2,X3]1~[X2,X3]~[X2,X3]~[X2,X3]~[X2,X3]2~[X2,X3]1~[X2,X3]~[X2,X3]3~[X2,X3](~[X2,X3]2)~[X2,X3]~[X2,X3]~[X2,X3]~[X2,X3]3),$([X2,X3]1~[X2,X3]~[X2,X3]~[X2,X3]~[X2,X3]2~[X2,X3]1~[X2,X3]~[X2,X3]~[X2,X3]3~[X2,X3]2~[X2,X3]~[X2,X3]~[X2,X3]3),$([X2,X3]1~[X2,X3]~[X2,X3]~[X2,X3]~[X2,X3]2~[X2,X3]1~[X2,X3]~[X2,X3]~[X2,X3]3~[X2,X3]2~[X2,X3]~[X2,X3]~[X2,X3]~[X2,X3]3),$([X2,X3]13~[X2,X3]~[X2,X3]~[X2,X3]~[X2,X3]2~[X2,X3]1~[X2,X3](~[X2,X3]~[X2,X3]~[X2,X3]3)~[X2,X3]~[X2,X3]2)]', '[S]1-*~*-[N,O,S]-*~*-1'] # smarts error of original smarts fixed
39
+ ]
40
+
41
+ CONFIDENCES = {
42
+ "specific arom nitro" => 0.81,
43
+ "specific arom amine" => 0.79,
44
+ "nitrosamine" => 0.90,
45
+ "epoxide" => 0.85,
46
+ "aliphatic halide" => 0.79,
47
+ "polycyclic aromatic system" => 0.90,
48
+ "other SAs" => 0.81
49
+ }
50
+
51
+ def self.predict smiles
52
+ smi2mol = OpenBabel::OBConversion.new
53
+ smi2mol.set_in_format("smi")
54
+ mol = OpenBabel::OBMol.new
55
+ smi2mol.read_string(mol, smiles)
56
+
57
+ matches = []
58
+ prediction = false
59
+ error_product = 1
60
+
61
+ smarts_pattern = OpenBabel::OBSmartsPattern.new
62
+ SMARTS.each do |sma|
63
+ if sma[2]
64
+ smarts_pattern.init sma[1]
65
+ if smarts_pattern.match(mol)
66
+ smarts_pattern.init sma[2]
67
+ matches << sma if !smarts_pattern.match(mol)
68
+ end
69
+ else
70
+ smarts_pattern.init sma[1]
71
+ matches << sma if smarts_pattern.match(mol)
72
+ end
73
+
74
+ matches.each { |m| error_product *= error(m) }
75
+
76
+ prediction = true if matches.size > 0
77
+ {:prediction => prediction, :error_product => error_product, :matches => matches}
78
+ end
79
+
80
+ def self.error(alert)
81
+ if CONFIDENCES[alert[0]]
82
+ return 1 - CONFIDENCES[alert[0]]
83
+ else
84
+ return 1 - CONFIDENCES["other SAs"]
85
+ end
86
+ end
87
+
88
+ end
89
+
90
+ class ConsensusMutagenicity
91
+
92
+ def self.predict smiles
93
+ sa_prediction = KaziusAlerts.predict smiles
94
+ lazar_prediction = Lazar.predict smiles
95
+ confidence = 0
96
+ if sa_prediction[:prediction] == false && lazar_mutagenicity.prediction == 0
97
+ confidence = 0.85
98
+ elsif sa_prediction[:prediction] == true && lazar_mutagenicity.prediction == 1
99
+ confidence = 0.85 * ( 1 - sa_prediction[:error_product] )
100
+ elsif sa_prediction[:prediction] == false && lazar_mutagenicity.prediction == 1
101
+ confidence = 0.11
102
+ elsif sa_prediction[:prediction] == true && lazar_mutagenicity.prediction == 0
103
+ confidence = ( 1 - sa_prediction[:error_product] ) - 0.57
104
+ end
105
+ {:prediction => prediction, :confidence => confidence}
106
+ end
107
+
108
+ end
109
+
@@ -0,0 +1,17 @@
1
+ require 'minitest/autorun'
2
+ #require 'kazius-alerts'
3
+ require_relative '../lib/kazius-alerts.rb'
4
+
5
+ class KaziusAlertsTest < MiniTest::Test
6
+
7
+ def test_alerts_size
8
+ assert_equal 29, KaziusAlerts::SMARTS.size
9
+ end
10
+
11
+ def test_kazius_alerts_prediction
12
+ prediction = KaziusAlerts.predict("c1ccccc1NN")
13
+ assert prediction[:prediction]
14
+ assert_equal [["unsubstituted heteroatom-bonded heteroatom", "[OH,NH2][N,O]", "O=N(O)[O-]"]], prediction[:matches]
15
+ end
16
+
17
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kazius-alerts
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Christoph Helma
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - helma@in-silico.ch
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - kazius-alerts.gemspec
21
+ - lib/kazius-alerts.rb
22
+ - test/kazius-alerts.rb
23
+ homepage: http://github.com/opentox/kazius-alerts
24
+ licenses:
25
+ - GPL-3.0
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project: kazius-alerts
43
+ rubygems_version: 2.6.11
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Kazius structural alerts
47
+ test_files:
48
+ - test/kazius-alerts.rb