chemruby 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +120 -0
- data/Rakefile +195 -0
- data/ext/extconf.rb +4 -0
- data/ext/subcomp.c +416 -0
- data/lib/chem.rb +130 -0
- data/lib/chem/appl.rb +1 -0
- data/lib/chem/appl/chem3dole.rb +36 -0
- data/lib/chem/appl/tinker/nucleic.rb +40 -0
- data/lib/chem/appl/tinker/tinker_reader.rb +43 -0
- data/lib/chem/data.rb +4 -0
- data/lib/chem/data/atomic_weight.rb +124 -0
- data/lib/chem/data/character.rb +2 -0
- data/lib/chem/data/electronegativity.rb +14 -0
- data/lib/chem/data/periodic_table.rb +6 -0
- data/lib/chem/data/prime_numbers.rb +1 -0
- data/lib/chem/data/vdw_radii.rb +1 -0
- data/lib/chem/db.rb +64 -0
- data/lib/chem/db/cansmi.rb +234 -0
- data/lib/chem/db/cdx.rb +1525 -0
- data/lib/chem/db/eps.rb +164 -0
- data/lib/chem/db/g98.rb +909 -0
- data/lib/chem/db/gspan.rb +130 -0
- data/lib/chem/db/iupac.rb +5 -0
- data/lib/chem/db/iupac/a_1.rb +46 -0
- data/lib/chem/db/iupac/iuparser.rb +226 -0
- data/lib/chem/db/iupac/iuparser.ry +97 -0
- data/lib/chem/db/iupac/postfix.rb +2 -0
- data/lib/chem/db/kcf.rb +390 -0
- data/lib/chem/db/kcf_glycan.rb +19 -0
- data/lib/chem/db/kegg.rb +516 -0
- data/lib/chem/db/linucs/linparser.rb +144 -0
- data/lib/chem/db/linucs/linucs.ry +53 -0
- data/lib/chem/db/mdl.rb +379 -0
- data/lib/chem/db/molconnz.rb +12 -0
- data/lib/chem/db/mopac.rb +88 -0
- data/lib/chem/db/msi.rb +107 -0
- data/lib/chem/db/pdb_dic.rb +115 -0
- data/lib/chem/db/pdf.rb +131 -0
- data/lib/chem/db/pubchem.rb +113 -0
- data/lib/chem/db/rmagick.rb +70 -0
- data/lib/chem/db/sdf.rb +37 -0
- data/lib/chem/db/smbl.rb +88 -0
- data/lib/chem/db/smiles.rb +2 -0
- data/lib/chem/db/smiles/smiles.ry +203 -0
- data/lib/chem/db/smiles/smiparser.rb +375 -0
- data/lib/chem/db/swf.rb +74 -0
- data/lib/chem/db/sybyl.rb +150 -0
- data/lib/chem/db/tinker.rb +77 -0
- data/lib/chem/db/types/type_cansmi.rb +9 -0
- data/lib/chem/db/types/type_cdx.rb +24 -0
- data/lib/chem/db/types/type_gspan.rb +31 -0
- data/lib/chem/db/types/type_kcf.rb +28 -0
- data/lib/chem/db/types/type_kcf_glycan.rb +26 -0
- data/lib/chem/db/types/type_kegg.rb +92 -0
- data/lib/chem/db/types/type_mdl.rb +31 -0
- data/lib/chem/db/types/type_pdf.rb +33 -0
- data/lib/chem/db/types/type_png.rb +31 -0
- data/lib/chem/db/types/type_rxn.rb +25 -0
- data/lib/chem/db/types/type_sdf.rb +25 -0
- data/lib/chem/db/types/type_sybyl.rb +30 -0
- data/lib/chem/db/types/type_xyz.rb +26 -0
- data/lib/chem/db/vector.rb +128 -0
- data/lib/chem/db/xyz.rb +39 -0
- data/lib/chem/model.rb +119 -0
- data/lib/chem/model/skeleton.rb +37 -0
- data/lib/chem/utils.rb +11 -0
- data/lib/chem/utils/geometry.rb +27 -0
- data/lib/chem/utils/graph_db.rb +146 -0
- data/lib/chem/utils/math.rb +17 -0
- data/lib/chem/utils/prop.rb +123 -0
- data/lib/chem/utils/sssr.rb +101 -0
- data/lib/chem/utils/sub.rb +78 -0
- data/lib/chem/utils/transform.rb +110 -0
- data/lib/chem/utils/traverse.rb +37 -0
- data/lib/chem/utils/ullmann.rb +134 -0
- data/lib/graph.rb +41 -0
- data/lib/graph/cluster.rb +20 -0
- data/lib/graph/morgan.rb +38 -0
- data/sample/frequent_subgraph.rb +46 -0
- data/sample/images/ex1.rb +11 -0
- data/sample/images/ex2.rb +4 -0
- data/sample/images/ex3.rb +5 -0
- data/sample/images/ex4.rb +17 -0
- data/sample/images/ex5.rb +10 -0
- data/sample/images/mol/adenine.mol +26 -0
- data/sample/images/mol/atp.mol +69 -0
- data/sample/images/temp/ex5.mol +344 -0
- data/sample/kegg_db.rb +116 -0
- data/setup.rb +1551 -0
- data/test/all.rb +6 -0
- data/test/coord_test.rb +17 -0
- data/test/ctab_test.rb +31 -0
- data/test/data/A_21.tar.gz +0 -0
- data/test/data/A_21/aceanthrylene.cdx +0 -0
- data/test/data/A_21/aceanthrylene.mol +40 -0
- data/test/data/A_21/acenaphthylene.cdx +0 -0
- data/test/data/A_21/acenaphthylene.mol +31 -0
- data/test/data/A_21/acephenanthrylene.cdx +0 -0
- data/test/data/A_21/acephenanthrylene.mol +40 -0
- data/test/data/A_21/anthracene.cdx +0 -0
- data/test/data/A_21/anthracene.mol +35 -0
- data/test/data/A_21/as-indacene.cdx +0 -0
- data/test/data/A_21/as-indacene.mol +31 -0
- data/test/data/A_21/azulene.cdx +0 -0
- data/test/data/A_21/azulene.mol +26 -0
- data/test/data/A_21/biphenylene.cdx +0 -0
- data/test/data/A_21/biphenylene.mol +31 -0
- data/test/data/A_21/chrysene.cdx +0 -0
- data/test/data/A_21/chrysene.mol +44 -0
- data/test/data/A_21/coronen.cdx +0 -0
- data/test/data/A_21/coronen.mol +59 -0
- data/test/data/A_21/fluoranthene.cdx +0 -0
- data/test/data/A_21/fluoranthene.mol +40 -0
- data/test/data/A_21/fluorene.cdx +0 -0
- data/test/data/A_21/fluorene.mol +33 -0
- data/test/data/A_21/heptacene.cdx +0 -0
- data/test/data/A_21/heptacene.mol +71 -0
- data/test/data/A_21/heptalene.cdx +0 -0
- data/test/data/A_21/heptalene.mol +30 -0
- data/test/data/A_21/heptaphene.cdx +0 -0
- data/test/data/A_21/heptaphene.mol +71 -0
- data/test/data/A_21/hexacene.cdx +0 -0
- data/test/data/A_21/hexacene.mol +62 -0
- data/test/data/A_21/hexaphene.cdx +0 -0
- data/test/data/A_21/hexaphene.mol +62 -0
- data/test/data/A_21/indene.cdx +0 -0
- data/test/data/A_21/indene.mol +24 -0
- data/test/data/A_21/iupac.txt +41 -0
- data/test/data/A_21/naphthacene.cdx +0 -0
- data/test/data/A_21/naphthacene.mol +44 -0
- data/test/data/A_21/naphthalene.cdx +0 -0
- data/test/data/A_21/naphthalene.mol +26 -0
- data/test/data/A_21/ovalene.cdx +0 -0
- data/test/data/A_21/ovalene.mol +78 -0
- data/test/data/A_21/pentacene.cdx +0 -0
- data/test/data/A_21/pentacene.mol +53 -0
- data/test/data/A_21/pentalene.cdx +0 -0
- data/test/data/A_21/pentalene.mol +22 -0
- data/test/data/A_21/pentaphene.cdx +0 -0
- data/test/data/A_21/pentaphene.mol +53 -0
- data/test/data/A_21/perylene.cdx +0 -0
- data/test/data/A_21/perylene.mol +49 -0
- data/test/data/A_21/phenalene.cdx +0 -0
- data/test/data/A_21/phenalene.mol +33 -0
- data/test/data/A_21/phenanthrene.cdx +0 -0
- data/test/data/A_21/phenanthrene.mol +35 -0
- data/test/data/A_21/picene.cdx +0 -0
- data/test/data/A_21/picene.mol +53 -0
- data/test/data/A_21/pleiadene.cdx +0 -0
- data/test/data/A_21/pleiadene.mol +44 -0
- data/test/data/A_21/pyranthrene.cdx +0 -0
- data/test/data/A_21/pyranthrene.mol +72 -0
- data/test/data/A_21/pyrene.cdx +0 -0
- data/test/data/A_21/pyrene.mol +40 -0
- data/test/data/A_21/rubicene.cdx +0 -0
- data/test/data/A_21/rubicene.mol +63 -0
- data/test/data/A_21/s-indacene.cdx +0 -0
- data/test/data/A_21/s-indacene.mol +31 -0
- data/test/data/A_21/tetraphenylene.cdx +0 -0
- data/test/data/A_21/tetraphenylene.mol +57 -0
- data/test/data/A_21/trinaphthylene.cdx +0 -0
- data/test/data/A_21/trinaphthylene.mol +71 -0
- data/test/data/A_21/triphenylene.cdx +0 -0
- data/test/data/A_21/triphenylene.mol +44 -0
- data/test/data/C00147.kcf +25 -0
- data/test/data/G00147.kcf +13 -0
- data/test/data/atp.mol +69 -0
- data/test/data/cyclohexane.mol +17 -0
- data/test/data/cyclohexane.ps +485 -0
- data/test/data/fullerene.mol +155 -0
- data/test/data/glycan +33 -0
- data/test/data/hypericin.cdx +0 -0
- data/test/data/hypericin.cdxml +596 -0
- data/test/data/hypericin.chm +0 -0
- data/test/data/hypericin.ct +85 -0
- data/test/data/hypericin.f1d +0 -0
- data/test/data/hypericin.f1q +0 -0
- data/test/data/hypericin.gif +0 -0
- data/test/data/hypericin.mol +88 -0
- data/test/data/hypericin.mol2 +159 -0
- data/test/data/hypericin.msm +123 -0
- data/test/data/hypericin.pdf +359 -0
- data/test/data/hypericin.png +0 -0
- data/test/data/hypericin.ps +0 -0
- data/test/data/hypericin.skc +0 -0
- data/test/data/hypericin2.gif +0 -0
- data/test/data/hypericin2.ps +0 -0
- data/test/data/kegg/genomes/hsa/hsa_enzyme.list +4 -0
- data/test/data/kegg/genomes/hsa/hsa_pfam.list +4 -0
- data/test/data/kegg/ligand/mol/C00147.mol +26 -0
- data/test/data/kegg/ligand/reaction +14 -0
- data/test/data/kegg/ligand/reaction.lst +1 -0
- data/test/data/kegg/ligand/reaction_mapformula.lst +3 -0
- data/test/data/reaction +14 -0
- data/test/data/reaction.lst +1 -0
- data/test/data/reaction_mapformula.lst +3 -0
- data/test/data/rxn/C00001.mol +6 -0
- data/test/data/rxn/C00011.mol +10 -0
- data/test/data/rxn/C00014.mol +6 -0
- data/test/data/rxn/C01010.mol +18 -0
- data/test/data/rxn/sample.rxn +50 -0
- data/test/data/rxn/substitution.rxn +45 -0
- data/test/data/test.eps +0 -0
- data/test/data/test.mol +28 -0
- data/test/data/test.sdf +143 -0
- data/test/data/test.skc +0 -0
- data/test/data/test.xyz +4 -0
- data/test/data/test_lf.sdf +143 -0
- data/test/heavy_test_pubchem.rb +16 -0
- data/test/multiple_test.rb +22 -0
- data/test/test_adj.rb +54 -0
- data/test/test_canonical_smiles.rb +46 -0
- data/test/test_cdx.rb +32 -0
- data/test/test_chem.rb +18 -0
- data/test/test_cluster.rb +19 -0
- data/test/test_db.rb +11 -0
- data/test/test_eps.rb +24 -0
- data/test/test_geometry.rb +11 -0
- data/test/test_gspan.rb +28 -0
- data/test/test_iupac.rb +36 -0
- data/test/test_kcf.rb +24 -0
- data/test/test_kcf_glycan.rb +10 -0
- data/test/test_kegg.rb +118 -0
- data/test/test_linucs.rb +21 -0
- data/test/test_mdl.rb +45 -0
- data/test/test_mol2.rb +62 -0
- data/test/test_morgan.rb +21 -0
- data/test/test_pdf.rb +12 -0
- data/test/test_prop.rb +86 -0
- data/test/test_rmagick.rb +15 -0
- data/test/test_sbdb.rb +23 -0
- data/test/test_sdf.rb +30 -0
- data/test/test_smiles.rb +84 -0
- data/test/test_sssr.rb +18 -0
- data/test/test_sub.rb +47 -0
- data/test/test_subcomp.rb +37 -0
- data/test/test_traverse.rb +29 -0
- data/test/test_writer.rb +13 -0
- data/test/test_xyz.rb +15 -0
- data/test/type_test.rb +25 -0
- 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,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
|