chemruby 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. data/README +120 -0
  2. data/Rakefile +195 -0
  3. data/ext/extconf.rb +4 -0
  4. data/ext/subcomp.c +416 -0
  5. data/lib/chem.rb +130 -0
  6. data/lib/chem/appl.rb +1 -0
  7. data/lib/chem/appl/chem3dole.rb +36 -0
  8. data/lib/chem/appl/tinker/nucleic.rb +40 -0
  9. data/lib/chem/appl/tinker/tinker_reader.rb +43 -0
  10. data/lib/chem/data.rb +4 -0
  11. data/lib/chem/data/atomic_weight.rb +124 -0
  12. data/lib/chem/data/character.rb +2 -0
  13. data/lib/chem/data/electronegativity.rb +14 -0
  14. data/lib/chem/data/periodic_table.rb +6 -0
  15. data/lib/chem/data/prime_numbers.rb +1 -0
  16. data/lib/chem/data/vdw_radii.rb +1 -0
  17. data/lib/chem/db.rb +64 -0
  18. data/lib/chem/db/cansmi.rb +234 -0
  19. data/lib/chem/db/cdx.rb +1525 -0
  20. data/lib/chem/db/eps.rb +164 -0
  21. data/lib/chem/db/g98.rb +909 -0
  22. data/lib/chem/db/gspan.rb +130 -0
  23. data/lib/chem/db/iupac.rb +5 -0
  24. data/lib/chem/db/iupac/a_1.rb +46 -0
  25. data/lib/chem/db/iupac/iuparser.rb +226 -0
  26. data/lib/chem/db/iupac/iuparser.ry +97 -0
  27. data/lib/chem/db/iupac/postfix.rb +2 -0
  28. data/lib/chem/db/kcf.rb +390 -0
  29. data/lib/chem/db/kcf_glycan.rb +19 -0
  30. data/lib/chem/db/kegg.rb +516 -0
  31. data/lib/chem/db/linucs/linparser.rb +144 -0
  32. data/lib/chem/db/linucs/linucs.ry +53 -0
  33. data/lib/chem/db/mdl.rb +379 -0
  34. data/lib/chem/db/molconnz.rb +12 -0
  35. data/lib/chem/db/mopac.rb +88 -0
  36. data/lib/chem/db/msi.rb +107 -0
  37. data/lib/chem/db/pdb_dic.rb +115 -0
  38. data/lib/chem/db/pdf.rb +131 -0
  39. data/lib/chem/db/pubchem.rb +113 -0
  40. data/lib/chem/db/rmagick.rb +70 -0
  41. data/lib/chem/db/sdf.rb +37 -0
  42. data/lib/chem/db/smbl.rb +88 -0
  43. data/lib/chem/db/smiles.rb +2 -0
  44. data/lib/chem/db/smiles/smiles.ry +203 -0
  45. data/lib/chem/db/smiles/smiparser.rb +375 -0
  46. data/lib/chem/db/swf.rb +74 -0
  47. data/lib/chem/db/sybyl.rb +150 -0
  48. data/lib/chem/db/tinker.rb +77 -0
  49. data/lib/chem/db/types/type_cansmi.rb +9 -0
  50. data/lib/chem/db/types/type_cdx.rb +24 -0
  51. data/lib/chem/db/types/type_gspan.rb +31 -0
  52. data/lib/chem/db/types/type_kcf.rb +28 -0
  53. data/lib/chem/db/types/type_kcf_glycan.rb +26 -0
  54. data/lib/chem/db/types/type_kegg.rb +92 -0
  55. data/lib/chem/db/types/type_mdl.rb +31 -0
  56. data/lib/chem/db/types/type_pdf.rb +33 -0
  57. data/lib/chem/db/types/type_png.rb +31 -0
  58. data/lib/chem/db/types/type_rxn.rb +25 -0
  59. data/lib/chem/db/types/type_sdf.rb +25 -0
  60. data/lib/chem/db/types/type_sybyl.rb +30 -0
  61. data/lib/chem/db/types/type_xyz.rb +26 -0
  62. data/lib/chem/db/vector.rb +128 -0
  63. data/lib/chem/db/xyz.rb +39 -0
  64. data/lib/chem/model.rb +119 -0
  65. data/lib/chem/model/skeleton.rb +37 -0
  66. data/lib/chem/utils.rb +11 -0
  67. data/lib/chem/utils/geometry.rb +27 -0
  68. data/lib/chem/utils/graph_db.rb +146 -0
  69. data/lib/chem/utils/math.rb +17 -0
  70. data/lib/chem/utils/prop.rb +123 -0
  71. data/lib/chem/utils/sssr.rb +101 -0
  72. data/lib/chem/utils/sub.rb +78 -0
  73. data/lib/chem/utils/transform.rb +110 -0
  74. data/lib/chem/utils/traverse.rb +37 -0
  75. data/lib/chem/utils/ullmann.rb +134 -0
  76. data/lib/graph.rb +41 -0
  77. data/lib/graph/cluster.rb +20 -0
  78. data/lib/graph/morgan.rb +38 -0
  79. data/sample/frequent_subgraph.rb +46 -0
  80. data/sample/images/ex1.rb +11 -0
  81. data/sample/images/ex2.rb +4 -0
  82. data/sample/images/ex3.rb +5 -0
  83. data/sample/images/ex4.rb +17 -0
  84. data/sample/images/ex5.rb +10 -0
  85. data/sample/images/mol/adenine.mol +26 -0
  86. data/sample/images/mol/atp.mol +69 -0
  87. data/sample/images/temp/ex5.mol +344 -0
  88. data/sample/kegg_db.rb +116 -0
  89. data/setup.rb +1551 -0
  90. data/test/all.rb +6 -0
  91. data/test/coord_test.rb +17 -0
  92. data/test/ctab_test.rb +31 -0
  93. data/test/data/A_21.tar.gz +0 -0
  94. data/test/data/A_21/aceanthrylene.cdx +0 -0
  95. data/test/data/A_21/aceanthrylene.mol +40 -0
  96. data/test/data/A_21/acenaphthylene.cdx +0 -0
  97. data/test/data/A_21/acenaphthylene.mol +31 -0
  98. data/test/data/A_21/acephenanthrylene.cdx +0 -0
  99. data/test/data/A_21/acephenanthrylene.mol +40 -0
  100. data/test/data/A_21/anthracene.cdx +0 -0
  101. data/test/data/A_21/anthracene.mol +35 -0
  102. data/test/data/A_21/as-indacene.cdx +0 -0
  103. data/test/data/A_21/as-indacene.mol +31 -0
  104. data/test/data/A_21/azulene.cdx +0 -0
  105. data/test/data/A_21/azulene.mol +26 -0
  106. data/test/data/A_21/biphenylene.cdx +0 -0
  107. data/test/data/A_21/biphenylene.mol +31 -0
  108. data/test/data/A_21/chrysene.cdx +0 -0
  109. data/test/data/A_21/chrysene.mol +44 -0
  110. data/test/data/A_21/coronen.cdx +0 -0
  111. data/test/data/A_21/coronen.mol +59 -0
  112. data/test/data/A_21/fluoranthene.cdx +0 -0
  113. data/test/data/A_21/fluoranthene.mol +40 -0
  114. data/test/data/A_21/fluorene.cdx +0 -0
  115. data/test/data/A_21/fluorene.mol +33 -0
  116. data/test/data/A_21/heptacene.cdx +0 -0
  117. data/test/data/A_21/heptacene.mol +71 -0
  118. data/test/data/A_21/heptalene.cdx +0 -0
  119. data/test/data/A_21/heptalene.mol +30 -0
  120. data/test/data/A_21/heptaphene.cdx +0 -0
  121. data/test/data/A_21/heptaphene.mol +71 -0
  122. data/test/data/A_21/hexacene.cdx +0 -0
  123. data/test/data/A_21/hexacene.mol +62 -0
  124. data/test/data/A_21/hexaphene.cdx +0 -0
  125. data/test/data/A_21/hexaphene.mol +62 -0
  126. data/test/data/A_21/indene.cdx +0 -0
  127. data/test/data/A_21/indene.mol +24 -0
  128. data/test/data/A_21/iupac.txt +41 -0
  129. data/test/data/A_21/naphthacene.cdx +0 -0
  130. data/test/data/A_21/naphthacene.mol +44 -0
  131. data/test/data/A_21/naphthalene.cdx +0 -0
  132. data/test/data/A_21/naphthalene.mol +26 -0
  133. data/test/data/A_21/ovalene.cdx +0 -0
  134. data/test/data/A_21/ovalene.mol +78 -0
  135. data/test/data/A_21/pentacene.cdx +0 -0
  136. data/test/data/A_21/pentacene.mol +53 -0
  137. data/test/data/A_21/pentalene.cdx +0 -0
  138. data/test/data/A_21/pentalene.mol +22 -0
  139. data/test/data/A_21/pentaphene.cdx +0 -0
  140. data/test/data/A_21/pentaphene.mol +53 -0
  141. data/test/data/A_21/perylene.cdx +0 -0
  142. data/test/data/A_21/perylene.mol +49 -0
  143. data/test/data/A_21/phenalene.cdx +0 -0
  144. data/test/data/A_21/phenalene.mol +33 -0
  145. data/test/data/A_21/phenanthrene.cdx +0 -0
  146. data/test/data/A_21/phenanthrene.mol +35 -0
  147. data/test/data/A_21/picene.cdx +0 -0
  148. data/test/data/A_21/picene.mol +53 -0
  149. data/test/data/A_21/pleiadene.cdx +0 -0
  150. data/test/data/A_21/pleiadene.mol +44 -0
  151. data/test/data/A_21/pyranthrene.cdx +0 -0
  152. data/test/data/A_21/pyranthrene.mol +72 -0
  153. data/test/data/A_21/pyrene.cdx +0 -0
  154. data/test/data/A_21/pyrene.mol +40 -0
  155. data/test/data/A_21/rubicene.cdx +0 -0
  156. data/test/data/A_21/rubicene.mol +63 -0
  157. data/test/data/A_21/s-indacene.cdx +0 -0
  158. data/test/data/A_21/s-indacene.mol +31 -0
  159. data/test/data/A_21/tetraphenylene.cdx +0 -0
  160. data/test/data/A_21/tetraphenylene.mol +57 -0
  161. data/test/data/A_21/trinaphthylene.cdx +0 -0
  162. data/test/data/A_21/trinaphthylene.mol +71 -0
  163. data/test/data/A_21/triphenylene.cdx +0 -0
  164. data/test/data/A_21/triphenylene.mol +44 -0
  165. data/test/data/C00147.kcf +25 -0
  166. data/test/data/G00147.kcf +13 -0
  167. data/test/data/atp.mol +69 -0
  168. data/test/data/cyclohexane.mol +17 -0
  169. data/test/data/cyclohexane.ps +485 -0
  170. data/test/data/fullerene.mol +155 -0
  171. data/test/data/glycan +33 -0
  172. data/test/data/hypericin.cdx +0 -0
  173. data/test/data/hypericin.cdxml +596 -0
  174. data/test/data/hypericin.chm +0 -0
  175. data/test/data/hypericin.ct +85 -0
  176. data/test/data/hypericin.f1d +0 -0
  177. data/test/data/hypericin.f1q +0 -0
  178. data/test/data/hypericin.gif +0 -0
  179. data/test/data/hypericin.mol +88 -0
  180. data/test/data/hypericin.mol2 +159 -0
  181. data/test/data/hypericin.msm +123 -0
  182. data/test/data/hypericin.pdf +359 -0
  183. data/test/data/hypericin.png +0 -0
  184. data/test/data/hypericin.ps +0 -0
  185. data/test/data/hypericin.skc +0 -0
  186. data/test/data/hypericin2.gif +0 -0
  187. data/test/data/hypericin2.ps +0 -0
  188. data/test/data/kegg/genomes/hsa/hsa_enzyme.list +4 -0
  189. data/test/data/kegg/genomes/hsa/hsa_pfam.list +4 -0
  190. data/test/data/kegg/ligand/mol/C00147.mol +26 -0
  191. data/test/data/kegg/ligand/reaction +14 -0
  192. data/test/data/kegg/ligand/reaction.lst +1 -0
  193. data/test/data/kegg/ligand/reaction_mapformula.lst +3 -0
  194. data/test/data/reaction +14 -0
  195. data/test/data/reaction.lst +1 -0
  196. data/test/data/reaction_mapformula.lst +3 -0
  197. data/test/data/rxn/C00001.mol +6 -0
  198. data/test/data/rxn/C00011.mol +10 -0
  199. data/test/data/rxn/C00014.mol +6 -0
  200. data/test/data/rxn/C01010.mol +18 -0
  201. data/test/data/rxn/sample.rxn +50 -0
  202. data/test/data/rxn/substitution.rxn +45 -0
  203. data/test/data/test.eps +0 -0
  204. data/test/data/test.mol +28 -0
  205. data/test/data/test.sdf +143 -0
  206. data/test/data/test.skc +0 -0
  207. data/test/data/test.xyz +4 -0
  208. data/test/data/test_lf.sdf +143 -0
  209. data/test/heavy_test_pubchem.rb +16 -0
  210. data/test/multiple_test.rb +22 -0
  211. data/test/test_adj.rb +54 -0
  212. data/test/test_canonical_smiles.rb +46 -0
  213. data/test/test_cdx.rb +32 -0
  214. data/test/test_chem.rb +18 -0
  215. data/test/test_cluster.rb +19 -0
  216. data/test/test_db.rb +11 -0
  217. data/test/test_eps.rb +24 -0
  218. data/test/test_geometry.rb +11 -0
  219. data/test/test_gspan.rb +28 -0
  220. data/test/test_iupac.rb +36 -0
  221. data/test/test_kcf.rb +24 -0
  222. data/test/test_kcf_glycan.rb +10 -0
  223. data/test/test_kegg.rb +118 -0
  224. data/test/test_linucs.rb +21 -0
  225. data/test/test_mdl.rb +45 -0
  226. data/test/test_mol2.rb +62 -0
  227. data/test/test_morgan.rb +21 -0
  228. data/test/test_pdf.rb +12 -0
  229. data/test/test_prop.rb +86 -0
  230. data/test/test_rmagick.rb +15 -0
  231. data/test/test_sbdb.rb +23 -0
  232. data/test/test_sdf.rb +30 -0
  233. data/test/test_smiles.rb +84 -0
  234. data/test/test_sssr.rb +18 -0
  235. data/test/test_sub.rb +47 -0
  236. data/test/test_subcomp.rb +37 -0
  237. data/test/test_traverse.rb +29 -0
  238. data/test/test_writer.rb +13 -0
  239. data/test/test_xyz.rb +15 -0
  240. data/test/type_test.rb +25 -0
  241. metadata +290 -0
@@ -0,0 +1,77 @@
1
+ #
2
+ # tinker.rb - TINKER
3
+ #
4
+ # http://dasher.wustl.edu/tinker/
5
+ #
6
+ #
7
+
8
+ module Chem
9
+
10
+ module TINKER
11
+
12
+ class TinkerAtom
13
+
14
+ include Atom
15
+
16
+ attr_reader :x, :y, :z, :element, :connection
17
+ def initialize ff, x, y, z, connection
18
+ @x, @y, @z = x.to_f, y.to_f, z.to_f
19
+ @element = ff[0..0]
20
+ @connection = []
21
+ connection.each do |n|
22
+ @connection.push(n)
23
+ end
24
+ end
25
+ end
26
+
27
+ class TinkerBond
28
+
29
+ include Bond
30
+
31
+ attr_accessor :b, :e, :v, :q
32
+ def initialize b, e
33
+ @b, @e = b, e
34
+ end
35
+ end
36
+
37
+ class TinkerMol
38
+ attr_reader :atoms, :bonds
39
+
40
+ def initialize
41
+ @atoms = {}
42
+ @bonds = []
43
+ end
44
+
45
+ def construct
46
+ @atoms.each_value do |a|
47
+ a.connection.each do |c|
48
+ raise "unknown atom number %s" % @atoms.inspect if !@atoms.has_key?(c)
49
+ bond = TinkerBond.new(a, @atoms[c])
50
+ @bonds.push(bond)
51
+ end
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+ class TinkerReader
58
+
59
+ attr_reader :mol
60
+
61
+ def initialize input
62
+ puts input.readline
63
+ @mol = TinkerMol.new
64
+ input.each_line do |line|
65
+ number, ff, x, y, z, unknown, ary = line.split
66
+ atom = TinkerAtom.new(ff, x, y, z, ary)
67
+ @mol.atoms[number] = atom
68
+ end
69
+
70
+ @mol.construct
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+
77
+ end
@@ -0,0 +1,9 @@
1
+
2
+ module Chem
3
+ module Molecule
4
+ def to_cansmi
5
+ require 'chem/db/cansmi.rb'
6
+ self.to_cansmi
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+
2
+ module Chem
3
+
4
+ module Type
5
+ module CdxType
6
+
7
+ def self.detect_file file
8
+ File.extname(file) == '.cdx'
9
+ end
10
+
11
+ def self.parse file
12
+ # require 'chem/db/cdx.rb'
13
+ mol = CDX::CDX.new
14
+ mol.open file
15
+ end
16
+
17
+ def self.detect_type type
18
+ type == :cdx
19
+ end
20
+ end
21
+ end
22
+
23
+ ChemTypeRegistry << Type::CdxType
24
+ end
@@ -0,0 +1,31 @@
1
+
2
+
3
+ module Chem
4
+
5
+ module Type
6
+ module GSpanType
7
+
8
+ def self.detect_file file
9
+ File.extname(file) == '.fp'
10
+ end
11
+
12
+ def self.parse file
13
+ # autoloaded
14
+ # require 'chem/db/gspan.rb'
15
+ Chem.parse_gspan(file)
16
+ end
17
+
18
+ def self.detect_type type
19
+ type == :gspan
20
+ end
21
+
22
+ def self.save mol, filename
23
+ # require 'chem/db/gspan.rb'
24
+ Chem::GSpan.save(mol, filename)
25
+ end
26
+ end
27
+ end
28
+
29
+ ChemTypeRegistry << Type::GSpanType
30
+
31
+ end
@@ -0,0 +1,28 @@
1
+
2
+ module Chem
3
+
4
+ module Type
5
+ module KCFType
6
+
7
+ # Returns true if extension of file is .kcf and
8
+ # file name starts C-number
9
+ def self.detect_file file
10
+ File.extname(file) == '.kcf' && /C\d+/.match(file)
11
+ end
12
+
13
+ # Parse file as KCF
14
+ def self.parse file
15
+ require 'chem/db/kcf'
16
+ Chem::KEGG::KCF.new(File.open(file))
17
+ end
18
+
19
+ def self.detect_type type
20
+ type == :kcf
21
+ end
22
+
23
+ end
24
+ end
25
+
26
+ ChemTypeRegistry << Type::KCFType
27
+
28
+ end
@@ -0,0 +1,26 @@
1
+ module Chem
2
+
3
+ module Type
4
+
5
+ module KCFGlycanType
6
+
7
+ def self.detect_file file
8
+ File.extname(file) == '.kcf' && /G\d+/.match(file)
9
+ end
10
+
11
+ def self.parse file
12
+ require 'chem/db/kcf_glycan'
13
+ mol = Chem::KEGG::KCFGlycan.new File.open(file)
14
+ end
15
+
16
+ def self.detect_type type
17
+ type == :kcf_glycan
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ ChemTypeRegistry << Type::KCFGlycanType
25
+
26
+ end
@@ -0,0 +1,92 @@
1
+
2
+ module Chem
3
+
4
+ module Type
5
+
6
+ module KeggReactionType
7
+
8
+ def self.detect_file filename
9
+ if File.basename(filename) == "reaction"
10
+ File.open(filename) do |file|
11
+ return true if /ENTRY /.match(file.readline)
12
+ end
13
+ end
14
+ end
15
+
16
+ def self.parse file
17
+ Chem::KEGG::KeggReactionParser.new file
18
+ end
19
+
20
+ def self.detect_type type
21
+ type == :kegg_reaction
22
+ end
23
+
24
+ end
25
+ end
26
+
27
+ ChemTypeRegistry << Type::KeggReactionType
28
+
29
+ module Type
30
+
31
+ module KeggReactionMapType
32
+
33
+ def self.detect_file filename
34
+ return true if File.basename(filename) == 'reaction_mapformula.lst'
35
+ end
36
+
37
+ def self.parse file
38
+ Chem::KEGG::KeggReactionMapParser.new file
39
+ end
40
+
41
+ def self.detect_type type
42
+ type == :kegg_rxn_map
43
+ end
44
+
45
+ end
46
+ end
47
+
48
+ ChemTypeRegistry << Type::KeggReactionMapType
49
+
50
+ module Type
51
+ module KeggReactionLstType
52
+
53
+ def self.detect_file filename
54
+ return true if File.basename(filename) == 'reaction.lst'
55
+ end
56
+
57
+ def self.parse file
58
+ require 'chem/db/kegg.rb'
59
+ Chem::KEGG::KeggReactionLstParser.new file
60
+ end
61
+
62
+ def self.detect_type type
63
+ type == :kegg_rxn_lst
64
+ end
65
+
66
+ end
67
+ end
68
+
69
+ ChemTypeRegistry << Type::KeggReactionLstType
70
+
71
+ module Type
72
+ module KeggGlycanType
73
+
74
+ def self.detect_file filename
75
+ return true if File.basename(filename) == "glycan"
76
+ end
77
+
78
+ def self.parse file
79
+ require 'chem/db/kegg.rb'
80
+ Chem::KEGG::KeggGlycanParser.new file
81
+ end
82
+
83
+ def self.detect_type type
84
+ type == :kegg_glycan
85
+ end
86
+
87
+ end
88
+ end
89
+
90
+ ChemTypeRegistry << Type::KeggGlycanType
91
+
92
+ end
@@ -0,0 +1,31 @@
1
+
2
+ module Chem
3
+
4
+ module Type
5
+ module MdlMolType
6
+
7
+ def self.detect_file file
8
+ File.extname(file) == '.mol'
9
+ end
10
+
11
+ def self.parse file
12
+ # autloaded
13
+ require 'chem/db/mdl.rb'
14
+ mol = Chem::MDL::MdlMolecule.new
15
+ mol.open file
16
+ end
17
+
18
+ def self.detect_type type
19
+ type == :mdl
20
+ end
21
+
22
+ def self.save mol, filename, params = {}
23
+ # require 'chem/db/mdl.rb'
24
+ mol.save_as_mdl(filename)
25
+ end
26
+ end
27
+ end
28
+
29
+ ChemTypeRegistry << Type::MdlMolType
30
+
31
+ end
@@ -0,0 +1,33 @@
1
+
2
+ module Chem
3
+
4
+ module Type
5
+
6
+ module PDFType
7
+
8
+ def self.detect_file file
9
+ File.extname(file) == '.pdf'
10
+ end
11
+
12
+ # ChemRuby will never parse PDF ;)
13
+ def self.parse file
14
+ raise NotImplementedError
15
+ end
16
+
17
+ def self.detect_type type
18
+ type == :pdf
19
+ end
20
+
21
+ def self.save mol, filename, params = {}
22
+ require 'chem/db/pdf.rb'
23
+ open(filename, "w") do |out|
24
+ mol.save_as_pdf(out, params)
25
+ end
26
+ end
27
+
28
+ end
29
+ end
30
+
31
+ ChemTypeRegistry << Type::PDFType
32
+
33
+ end
@@ -0,0 +1,31 @@
1
+
2
+ module Chem
3
+
4
+ module Type
5
+ module PNGType
6
+
7
+ def self.detect_file file
8
+ ['.png', '.gif', '.jpg', '.jpeg', '.tiff'].include?(File.extname(file))
9
+ end
10
+
11
+ # ChemRuby will never parse PNG ;)
12
+ def self.parse file
13
+ raise NotImplementedError
14
+ end
15
+
16
+ def self.detect_type type
17
+ type == :png
18
+ end
19
+
20
+ def self.save mol, filename, params = {}
21
+ require 'RMagick'
22
+ require 'chem/db/rmagick.rb'
23
+ RMagickWriter.save(mol, filename, params)
24
+ end
25
+
26
+ end
27
+ end
28
+
29
+ ChemTypeRegistry << Type::PNGType
30
+
31
+ end
@@ -0,0 +1,25 @@
1
+
2
+ module Chem
3
+
4
+ module Type
5
+ module MdlRxnType
6
+
7
+ def self.detect_file file
8
+ File.extname(file) == '.rxn'
9
+ end
10
+
11
+ def self.parse file
12
+ mol = MdlReaction.new
13
+ mol.open_rxn file
14
+ end
15
+
16
+ def self.detect_type type
17
+ type == :rxn
18
+ end
19
+
20
+ end
21
+ end
22
+
23
+ ChemTypeRegistry << Type::MdlRxnType
24
+
25
+ end
@@ -0,0 +1,25 @@
1
+
2
+ module Chem
3
+
4
+ module Type
5
+ module SdfType
6
+
7
+ def self.detect_file file
8
+ File.extname(file) == '.sdf'
9
+ end
10
+
11
+ def self.parse file
12
+ require 'chem/db/sdf.rb'
13
+ MDL::SdfParser.parse file
14
+ end
15
+
16
+ def self.detect_type type
17
+ type == :sdf
18
+ end
19
+
20
+ end
21
+ end
22
+
23
+ ChemTypeRegistry << Type::SdfType
24
+
25
+ end