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,16 @@
|
|
1
|
+
# $Id: heavy_test_pubchem.rb 65 2005-10-25 17:17:36Z tanaka $
|
2
|
+
|
3
|
+
require 'test/all'
|
4
|
+
|
5
|
+
class PubChemTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_fetch
|
8
|
+
mol = Chem.parse_smiles("CCCCC")
|
9
|
+
entries = mol.search_pubchem
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_false
|
13
|
+
assert(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# $Id: multiple_test.rb 88 2005-12-27 11:52:43Z tanaka $
|
2
|
+
|
3
|
+
# Parsers that parse files with multiple molecule should conform
|
4
|
+
# MultipleTest.
|
5
|
+
|
6
|
+
module Chem
|
7
|
+
module MultipleTest
|
8
|
+
|
9
|
+
def test_prerequisite
|
10
|
+
assert_not_nil(@entries)
|
11
|
+
assert_not_nil(@file_type)
|
12
|
+
|
13
|
+
assert_kind_of(Enumerable, @entries)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_respond
|
17
|
+
assert_respond_to(@entries, :each)
|
18
|
+
assert(@entries.all?{|entry| entry.respond_to?(:entry)}, "all entries responds to 'entry' method")
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/test/test_adj.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#
|
2
|
+
# test_adj.rb - Test for adjacency
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# $Id: test_adj.rb 127 2006-02-03 02:47:57Z tanaka $
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'test/all'
|
9
|
+
|
10
|
+
require 'chem'
|
11
|
+
|
12
|
+
class AdjTest < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup
|
15
|
+
@cyclohexane = Chem.open_mol($data_dir + "cyclohexane.mol")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_adjacent_to
|
19
|
+
@cyclohexane.each do |node|
|
20
|
+
assert_equal(@cyclohexane.adjacent_to(node).length, 2)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_dup
|
25
|
+
cyclo = @cyclohexane.deep_dup
|
26
|
+
cyclo.delete(cyclo.nodes[0])
|
27
|
+
assert_equal(5, cyclo.nodes.length)
|
28
|
+
assert_equal(6, @cyclohexane.nodes.length)
|
29
|
+
end
|
30
|
+
|
31
|
+
def est_delete#!!!BUG
|
32
|
+
assert_equal(6, @cyclohexane.nodes.length)
|
33
|
+
adj = []
|
34
|
+
@cyclohexane.adjacent_to(@cyclohexane.nodes[0]).each do |bond, atom|
|
35
|
+
adj.push(atom)
|
36
|
+
end
|
37
|
+
|
38
|
+
@cyclohexane.delete(@cyclohexane.nodes[0])
|
39
|
+
|
40
|
+
adj.each do |atom|
|
41
|
+
assert_equal(1, @cyclohexane.adjacent_to(atom).length)
|
42
|
+
end
|
43
|
+
|
44
|
+
@cyclohexane.nodes.each do |atom|
|
45
|
+
if !adj.include?(atom)
|
46
|
+
assert_equal(2, @cyclohexane.adjacent_to(atom).length)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
assert_equal(@cyclohexane.nodes.length, 5)
|
51
|
+
assert_equal(@cyclohexane.edges.length, 4)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# test_adj.rb - Test for adjacency
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# $Id: test_canonical_smiles.rb 127 2006-02-03 02:47:57Z tanaka $
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'test/all'
|
9
|
+
|
10
|
+
class CanonicalSmilesTest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
# def test_ex1
|
13
|
+
# mol = Chem.parse_smiles("OCC(CC)CCC(CN)CN")
|
14
|
+
# assert_equal("CCC(CO)CCC(CN)CN", mol.to_cansmi)
|
15
|
+
# end
|
16
|
+
|
17
|
+
# def test_naphthalene
|
18
|
+
# mol = Chem.parse_smiles("C1=CC=C2C=CC=CC2=C1")
|
19
|
+
# cansmi = mol.to_cansmi
|
20
|
+
# assert_block do
|
21
|
+
# "C1=CC=C2C=CC=CC2=C1" == cansmi or
|
22
|
+
# "C1=CC2=CC=CC=C2C=C1" == cansmi
|
23
|
+
# end
|
24
|
+
# p cansmi
|
25
|
+
# end
|
26
|
+
|
27
|
+
# def test_cubane
|
28
|
+
# mol = Chem.parse_smiles("C12C3C4C1C5C4C3C25")
|
29
|
+
# assert_equal("C12C3C4C1C5C2C3C45", mol.to_cansmi)
|
30
|
+
# p mol.to_cansmi
|
31
|
+
# end
|
32
|
+
|
33
|
+
# def test_melphalan
|
34
|
+
# mol = Chem.parse_smiles("C1=CC(=CC=C1CC(C(=O)O)N)N(CCCl)CCCl")
|
35
|
+
# assert_equal("C1=CC(=CC=C1CC(C(=O)O)N)N(CCCl)CCCl", mol.to_cansmi)
|
36
|
+
# end
|
37
|
+
# def test_hypericin
|
38
|
+
# mol = Chem.open_mol(File.join($data_dir, "hypericin.mol"))
|
39
|
+
# assert_equal("CC1=CC(=O)C2=C(C3=C(C=C(C4=C3C5=C6C7=C(C1=C25)C(=CC(=O)C7=C(C8=C(C=C(C4=C86)O)O)O)C)O)O)O", mol.to_cansmi)
|
40
|
+
# end
|
41
|
+
|
42
|
+
def test_true
|
43
|
+
assert(true)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
data/test/test_cdx.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#
|
2
|
+
# test_adj.rb - Test for adjacency
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# $Id: test_cdx.rb 149 2006-02-08 08:02:33Z tanaka $
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'test/all'
|
9
|
+
|
10
|
+
require 'test/type_test'
|
11
|
+
require 'test/ctab_test'
|
12
|
+
require 'test/coord_test'
|
13
|
+
|
14
|
+
require 'chem'
|
15
|
+
|
16
|
+
class CDXTest < Test::Unit::TestCase
|
17
|
+
|
18
|
+
include Chem::TypeTest
|
19
|
+
include Chem::CtabTest
|
20
|
+
include Chem::CoordTest
|
21
|
+
|
22
|
+
def setup
|
23
|
+
@entries = Chem.open_mol($data_dir + "hypericin.cdx")
|
24
|
+
@parser = Chem::CDX
|
25
|
+
@file_type = Chem::Type::CdxType
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_false
|
29
|
+
assert(true)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/test/test_chem.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# test_adj.rb - Test for adjacency
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# $Id: test_chem.rb 127 2006-02-03 02:47:57Z tanaka $
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'test/all'
|
9
|
+
|
10
|
+
class ChemTest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
def test_auto_detection
|
13
|
+
Chem.open_mol($data_dir + "cyclohexane.mol")
|
14
|
+
# Chem.open_mol($data_dir + "cyclohexane.mol", :mol)
|
15
|
+
assert_raise(NotImplementedError){Chem.open_mol($data_dir + "cyclohexane.no_such_format")}
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# $Id: test_mdl.rb 37 2005-09-23 22:58:24Z tanaka $
|
2
|
+
|
3
|
+
# Tests to ensure functionality
|
4
|
+
|
5
|
+
require 'test/all'
|
6
|
+
|
7
|
+
class ClusterTest < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_morgan
|
10
|
+
# mol = Chem.open_mol(File.join($data_dir, "hypericin.mol"))
|
11
|
+
#mol = Chem.parse_smiles("C1CC1")
|
12
|
+
# require 'chem/db/smiles'
|
13
|
+
require 'chem/db/smiles/smiparser'
|
14
|
+
mol = SMILES("C1CC1")
|
15
|
+
assert_equal([2, 2, 2], mol.clustering_coefficient.values)
|
16
|
+
# ec, tec, priority = mol.morgan#_index
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/test/test_db.rb
ADDED
data/test/test_eps.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#
|
2
|
+
# test_adj.rb - Test for adjacency
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# $Id: test_eps.rb 132 2006-02-04 19:16:50Z tanaka $
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'test/unit'
|
9
|
+
|
10
|
+
require 'test/all'
|
11
|
+
|
12
|
+
require 'chem'
|
13
|
+
|
14
|
+
class EpsTest < Test::Unit::TestCase
|
15
|
+
|
16
|
+
def setup
|
17
|
+
@mol = Chem.open_mol($data_dir + 'test.mol')
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_eps
|
21
|
+
# assert_nothing_raised(Chem.save(mols, File.join(%w(temp temp.eps))))
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/test/test_gspan.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
require 'test/all'
|
3
|
+
|
4
|
+
require 'test/type_test'
|
5
|
+
require 'test/ctab_test'
|
6
|
+
require 'test/coord_test'
|
7
|
+
|
8
|
+
require 'chem'
|
9
|
+
|
10
|
+
class GSpanTest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
include Chem::CtabTest
|
13
|
+
|
14
|
+
def setup
|
15
|
+
(@entries = []).push(Chem::GSpan.parse("(6) 0 (0f6) 0 (1f6) 0 (2f6) 0 (3f6) 0 (4f8) 0 (1f6)"))
|
16
|
+
@entries.push Chem::GSpan.parse("(6) 0 (0f6) 0 (1f6) 0 (2f6) 0 (3f6) 0 (4f6) 0 (b0) 0 (5f6) 0 (6f8) 0 (4f6)")
|
17
|
+
@parser = Chem::GSpan
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_gspan
|
21
|
+
mols = []
|
22
|
+
mols.push(Chem.open_mol($data_dir + "hypericin.mol"))
|
23
|
+
mols.push(Chem.open_mol($data_dir + "cyclohexane.mol"))
|
24
|
+
Chem.save(mols, File.join(%w(temp temp.fp)))
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
data/test/test_iupac.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# test_adj.rb - Test for adjacency
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# $Id: test_iupac.rb 127 2006-02-03 02:47:57Z tanaka $
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'chem/db/iupac'
|
9
|
+
|
10
|
+
require 'test/all'
|
11
|
+
require 'test/ctab_test'
|
12
|
+
|
13
|
+
class IupacTest < Test::Unit::TestCase
|
14
|
+
|
15
|
+
def setup
|
16
|
+
@parser = IupacParser.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_a_1
|
20
|
+
["3-Methylpentane",
|
21
|
+
"2,3,5-Trimethylhexane",
|
22
|
+
"Isopropyl",
|
23
|
+
"7-(1,2-Dimethylpentyl)-5-ethyltridecane",
|
24
|
+
"7,7-Bis(2,4-dimethylhexyl)-3-ethyl-5,9,11-trimethyltridecane",
|
25
|
+
]
|
26
|
+
["hexane",
|
27
|
+
"hexylhexane", # Invalid IUPAC name
|
28
|
+
"1,2-dihexylhexane", # Invalid IUPAC name
|
29
|
+
"5-Methyl-6-propylnonane",
|
30
|
+
# "6-(1-methylbutyl)-8-(2-methylbutyl)tridecane",
|
31
|
+
].each do |name|
|
32
|
+
@parser.parse(name)
|
33
|
+
end
|
34
|
+
assert(true)
|
35
|
+
end
|
36
|
+
end
|
data/test/test_kcf.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'test/all'
|
4
|
+
|
5
|
+
require 'test/type_test'
|
6
|
+
require 'test/ctab_test'
|
7
|
+
require 'test/coord_test'
|
8
|
+
|
9
|
+
require 'chem'
|
10
|
+
|
11
|
+
class KCFTest < Test::Unit::TestCase
|
12
|
+
|
13
|
+
include Chem::TypeTest
|
14
|
+
include Chem::CtabTest
|
15
|
+
include Chem::CoordTest
|
16
|
+
|
17
|
+
def setup
|
18
|
+
(@entries = []).push(Chem.open_mol($data_dir + "C00147.kcf"))
|
19
|
+
require 'chem/db/kcf'
|
20
|
+
@parser = Chem::KEGG::KCF
|
21
|
+
@file_type = Chem::Type::KCFType
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/test/test_kegg.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
#
|
2
|
+
# test_kegg.rb - Test for KEGG
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# $Id: test_kegg.rb 151 2006-02-08 08:21:08Z tanaka $
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'test/all'
|
9
|
+
require 'test/multiple_test'
|
10
|
+
require 'test/type_test'
|
11
|
+
|
12
|
+
require 'chem/db/kegg'
|
13
|
+
|
14
|
+
class KeggOpenTest < Test::Unit::TestCase
|
15
|
+
|
16
|
+
def test_open
|
17
|
+
# environment dependent test!
|
18
|
+
#dir = "/home/tanaka/share/data/kegg"
|
19
|
+
kegg = Chem.open_kegg(File.join($data_dir, "kegg"))
|
20
|
+
|
21
|
+
compound = kegg["C00147"]
|
22
|
+
assert(10, compound.nodes.length)
|
23
|
+
assert(11, compound.edges.length)
|
24
|
+
|
25
|
+
reaction = kegg["R00001"]
|
26
|
+
assert_not_nil(reaction)
|
27
|
+
assert_equal([[["C00147", 1]], [["C00009", 1]]], reaction.map_formula)
|
28
|
+
|
29
|
+
m_formula = reaction.map_formula
|
30
|
+
compound = kegg[m_formula[0][0][0]]
|
31
|
+
assert_not_nil(compound)
|
32
|
+
assert_equal(10, compound.nodes.length)
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
__END__
|
40
|
+
#obsolete
|
41
|
+
Chem::Kegg.kegg_compound_folder = $data_dir
|
42
|
+
|
43
|
+
class KeggReactionTest < Test::Unit::TestCase
|
44
|
+
|
45
|
+
include Chem::MultipleTest
|
46
|
+
include Chem::TypeTest
|
47
|
+
|
48
|
+
def setup
|
49
|
+
@entries = Chem.parse_file(File.join($data_dir, "kegg", "ligand", "reaction"))
|
50
|
+
@parser = Chem::Kegg::KeggReactionParser
|
51
|
+
@file_type = Chem::KeggReactionType
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_entry
|
55
|
+
@entries.each do |entry|
|
56
|
+
assert_respond_to(entry, :entry)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
class KeggReactionLstTest < Test::Unit::TestCase
|
63
|
+
|
64
|
+
include Chem::MultipleTest
|
65
|
+
include Chem::TypeTest
|
66
|
+
|
67
|
+
def setup
|
68
|
+
@entries = Chem.open_mol(File.join($data_dir, "kegg", "ligand", "reaction.lst"))
|
69
|
+
@parser = Chem::Kegg::KeggReactionLstParser
|
70
|
+
@file_type = Chem::KeggReactionLstType
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_entry
|
74
|
+
@entries.each do |rxn|
|
75
|
+
assert_equal("2 C00890", rxn.compounds[0][0][0])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
class KeggReactionMapTest < Test::Unit::TestCase
|
82
|
+
include Chem::MultipleTest
|
83
|
+
include Chem::TypeTest
|
84
|
+
|
85
|
+
def setup
|
86
|
+
@entries = Chem.open_mol(File.join($data_dir, "kegg", "ligand", "reaction_mapformula.lst"))
|
87
|
+
@parser = Chem::Kegg::KeggReactionMapParser
|
88
|
+
@file_type = Chem::KeggReactionMapType
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
class KeggGlycanTest < Test::Unit::TestCase
|
94
|
+
|
95
|
+
include Chem::MultipleTest
|
96
|
+
include Chem::TypeTest
|
97
|
+
|
98
|
+
def setup
|
99
|
+
@entries = Chem.open_mol(File.join($data_dir, "glycan"))
|
100
|
+
@parser = Chem::Kegg::KeggGlycanParser
|
101
|
+
@file_type = Chem::KeggGlycanType
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
class KeggPfamTest < Test::Unit::TestCase
|
107
|
+
|
108
|
+
def test_false
|
109
|
+
kegg = Chem.open_kegg(File.join($data_dir, "kegg"))
|
110
|
+
cadherin = kegg["pf:Cadherin"]
|
111
|
+
assert_not_nil(cadherin)
|
112
|
+
gene = cadherin["hsa"]
|
113
|
+
human = kegg["hsa"]
|
114
|
+
assert_not_nil(gene)
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|