rcdk 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/README +46 -0
  2. data/Rakefile +100 -0
  3. data/java/cdk-20060714.jar +0 -0
  4. data/lib/java.rb +69 -0
  5. data/lib/rcdk.rb +34 -0
  6. data/test/test.rb +47 -0
  7. metadata +59 -0
data/README ADDED
@@ -0,0 +1,46 @@
1
+ =RCDK - The Ruby Interface for the Chemistry Development Kit (CDK)
2
+
3
+ RCDK makes it possible to use the CDK library, which is written in
4
+ Java, from Ruby.
5
+
6
+ ==Typical Usage
7
+
8
+ require 'rubygems'
9
+ require_gem 'rcdk'
10
+
11
+ SmilesParser = import('org.openscience.cdk.smiles.SmilesParser')
12
+
13
+ parser = SmilesParser.new
14
+ smiles = 'c1ccccc1'
15
+ mol = parser.parseSmiles(smiles)
16
+
17
+ puts mol.getAtomCount # =>6
18
+
19
+ ==Downloading
20
+
21
+ Both a RubyGems installation package and a full source package
22
+ can be obtained from:
23
+
24
+ http://rubyforge.org/projects/rcdk
25
+
26
+ ==Requirements
27
+
28
+ RCDK was developed with Ruby 1.8.4. Earlier versions of Ruby
29
+ may also be compatible.
30
+
31
+ ==Installing
32
+
33
+ The RubyGems package can be installed using the following command
34
+ (as root):
35
+
36
+ gem install rcdk
37
+
38
+ ==License
39
+ RCDK is distributed under the GNU LGPL version 2.1 (see 'LICENSE').
40
+ It contains bytecode from the Chemistry Development Kit (CDK) distribution,
41
+ which is itself licensed under the LGPL. The complete source code for
42
+ the CDK can be obtained from http://sf.net/projects/cdk.
43
+
44
+ ==Contact
45
+
46
+ More information can be found at http://rcdk.rubyforge.org.
data/Rakefile ADDED
@@ -0,0 +1,100 @@
1
+ # =============================================
2
+ # RCDK - The Chemistry Development Kit for Ruby
3
+ # =============================================
4
+ #
5
+ # Project Info: http://rcdk.rubyforge.org
6
+ #
7
+ # Copyright (C) 2006 Richard L. Apodaca
8
+ #
9
+ # This library is free software; you can redistribute it and/or
10
+ # modify it under the terms of the GNU Lesser General Public
11
+ # License version 2.1 as published by the Free Software
12
+ # Foundation.
13
+ #
14
+ # This library is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ # Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public
20
+ # License along with this library; if not, write to the Free
21
+ # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
22
+ # Boston, MA 02111-1301, USA.
23
+
24
+ require 'rake'
25
+ require 'rake/testtask'
26
+ require 'rake/rdoctask'
27
+ require 'rake/gempackagetask'
28
+
29
+ PKG_VERSION = "0.1.0"
30
+
31
+ PKG_FILES = FileList[
32
+ "Rakefile", "README",
33
+ "lib/**/*.rb",
34
+ "test/**/*",
35
+ "java/*.jar"
36
+ ]
37
+
38
+ desc "Default task"
39
+ task :default => [:test]
40
+
41
+ desc "Clean up"
42
+ task :clean do
43
+ rm_rf "dist"
44
+ rm_rf "doc"
45
+ rm_rf "pkg"
46
+ end
47
+
48
+ desc "Create the source distribution"
49
+ task :dist do
50
+ rm_rf "dist"
51
+
52
+ mkdir "dist"
53
+ mkdir "dist/lib"
54
+ mkdir "dist/java"
55
+ mkdir "dist/test"
56
+
57
+ cp_r Dir.glob('*.rb'), 'dist'
58
+ cp_r Dir.glob('lib/*.rb'), 'dist/lib'
59
+ cp_r Dir.glob('java/*.jar'), 'dist/java'
60
+ cp_r Dir.glob('test/*.rb'), 'dist/test'
61
+ cp 'Rakefile', 'dist'
62
+ cp 'README', 'dist'
63
+ cp 'LICENSE', 'dist'
64
+ end
65
+
66
+ Rake::TestTask.new do |t|
67
+ t.libs << "test"
68
+ t.test_files = FileList['test/test*.rb']
69
+ t.verbose = true
70
+ end
71
+
72
+ Rake::RDocTask.new do |rdoc|
73
+ rdoc.rdoc_dir = 'doc'
74
+ rdoc.title = "Ruby CDK"
75
+ rdoc.rdoc_files.include('README')
76
+ rdoc.options << '--line-numbers'
77
+ rdoc.options << '--inline-source'
78
+ rdoc.options << '--main' << 'README'
79
+ rdoc.rdoc_files.include('lib/**/*.rb')
80
+ end
81
+
82
+ spec = Gem::Specification.new do |s|
83
+ s.name = 'rcdk'
84
+ s.version = PKG_VERSION
85
+ s.author = "Richard Apodaca"
86
+ s.homepage = "http://rcdk.rubyforge.org"
87
+ s.platform = Gem::Platform::RUBY
88
+ s.require_path = 'lib'
89
+ s.autorequire = 'rcdk'
90
+ s.has_rdoc = true
91
+ s.files = PKG_FILES
92
+ s.summary = "A Ruby wrapper for the Chemistry Development Kit"
93
+ s.add_dependency("rjb", ">= 1.0.0")
94
+ end
95
+
96
+ Rake::GemPackageTask.new(spec) do |gem|
97
+ gem.need_tar = true
98
+ gem.need_tar_gz = true
99
+ gem.package_files += PKG_FILES
100
+ end
Binary file
data/lib/java.rb ADDED
@@ -0,0 +1,69 @@
1
+ # =============================================
2
+ # RCDK - The Chemistry Development Kit for Ruby
3
+ # =============================================
4
+ #
5
+ # Project Info: http://rcdk.rubyforge.org
6
+ #
7
+ # Copyright (C) 2006 Richard L. Apodaca
8
+ #
9
+ # This library is free software; you can redistribute it and/or
10
+ # modify it under the terms of the GNU Lesser General Public
11
+ # License version 2.1 as published by the Free Software
12
+ # Foundation.
13
+ #
14
+ # This library is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ # Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public
20
+ # License along with this library; if not, write to the Free
21
+ # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
22
+ # Boston, MA 02111-1301, USA.
23
+
24
+ require 'rubygems'
25
+ require_gem 'rjb'
26
+ require 'rjb'
27
+
28
+ # Returns the Java class represented by the fully qualified name
29
+ # <tt>klass</tt> via Ruby Java Bridge (RJB).
30
+ def import(klass)
31
+ Rjb::import(klass)
32
+ end
33
+
34
+ # Configuration and use of Java classes through Ruby Java Bridge (RJB).
35
+ module Java
36
+ # Configuration of classpath.
37
+ class Classpath
38
+ # Appends <tt>path</tt> to the <tt>CLASSPATH</tt> environment variable.
39
+ def self.add(path)
40
+ if set?
41
+ ENV['CLASSPATH'] = ENV['CLASSPATH'] + File::PATH_SEPARATOR + path
42
+ else
43
+ ENV['CLASSPATH'] = path
44
+ end
45
+ end
46
+
47
+ # Returns false if the <tt>CLASSPATH</tt> variable is either null or
48
+ # empty, or otherwise true.
49
+ def self.set?
50
+ if !ENV['CLASSPATH']
51
+ return false
52
+ elsif ''.eql?(ENV['CLASSPATH'])
53
+ return false
54
+ end
55
+
56
+ true
57
+ end
58
+
59
+ # Returns the value of the <tt>CLASSPATH</tt> variable.
60
+ def self.get
61
+ ENV['CLASSPATH']
62
+ end
63
+
64
+ # Sets the value of the <tt>CLASSPATH</tt> varible to <tt>nil</tt>.
65
+ def self.clear!
66
+ ENV['CLASSPATH'] = nil
67
+ end
68
+ end
69
+ end
data/lib/rcdk.rb ADDED
@@ -0,0 +1,34 @@
1
+ # =============================================
2
+ # RCDK - The Chemistry Development Kit for Ruby
3
+ # =============================================
4
+ #
5
+ # Project Info: http://rcdk.rubyforge.org
6
+ #
7
+ # Copyright (C) 2006 Richard L. Apodaca
8
+ #
9
+ # This library is free software; you can redistribute it and/or
10
+ # modify it under the terms of the GNU Lesser General Public
11
+ # License version 2.1 as published by the Free Software
12
+ # Foundation.
13
+ #
14
+ # This library is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ # Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public
20
+ # License along with this library; if not, write to the Free
21
+ # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
22
+ # Boston, MA 02111-1301, USA.
23
+
24
+ require 'java'
25
+
26
+ RCDK_VERSION = '0.1.0'
27
+ CDK_VERSION = '20060714'
28
+
29
+ Java::Classpath.add(Gem.dir + File::SEPARATOR +
30
+ File.join('gems', 'rcdk-' + RCDK_VERSION, 'java', 'cdk-' +
31
+ CDK_VERSION + '.jar'))
32
+
33
+
34
+
data/test/test.rb ADDED
@@ -0,0 +1,47 @@
1
+ # =============================================
2
+ # RCDK - The Chemistry Development Kit for Ruby
3
+ # =============================================
4
+ #
5
+ # Project Info: http://rcdk.rubyforge.org
6
+ #
7
+ # Copyright (C) 2006 Richard L. Apodaca
8
+ #
9
+ # This library is free software; you can redistribute it and/or
10
+ # modify it under the terms of the GNU Lesser General Public
11
+ # License version 2.1 as published by the Free Software
12
+ # Foundation.
13
+ #
14
+ # This library is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ # Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public
20
+ # License along with this library; if not, write to the Free
21
+ # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
22
+ # Boston, MA 02111-1301, USA.
23
+
24
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
25
+
26
+ require 'rcdk'
27
+ require 'test/unit'
28
+
29
+ Java::Classpath.add(File.join('java', 'cdk-' + '20060714' + '.jar'))
30
+
31
+ SmilesParser = import('org.openscience.cdk.smiles.SmilesParser')
32
+
33
+ # A very simple test suite.
34
+ class BasicTest < Test::Unit::TestCase
35
+
36
+ # Loads the SMILES string for benzene and verifies that the resulting
37
+ # CDK molecule has six atoms.
38
+ def test_parse_smiles
39
+ parser = SmilesParser.new
40
+ smiles = 'c1ccccc1'
41
+
42
+ mol = parser.parseSmiles(smiles)
43
+
44
+ assert_equal(6, mol.getAtomCount)
45
+ end
46
+ end
47
+
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: rcdk
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2006-09-13 00:00:00 -07:00
8
+ summary: A Ruby wrapper for the Chemistry Development Kit
9
+ require_paths:
10
+ - lib
11
+ email:
12
+ homepage: http://rcdk.rubyforge.org
13
+ rubyforge_project:
14
+ description:
15
+ autorequire: rcdk
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Richard Apodaca
31
+ files:
32
+ - Rakefile
33
+ - README
34
+ - lib/rcdk.rb
35
+ - lib/java.rb
36
+ - test/test.rb
37
+ - java/cdk-20060714.jar
38
+ test_files: []
39
+
40
+ rdoc_options: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ executables: []
45
+
46
+ extensions: []
47
+
48
+ requirements: []
49
+
50
+ dependencies:
51
+ - !ruby/object:Gem::Dependency
52
+ name: rjb
53
+ version_requirement:
54
+ version_requirements: !ruby/object:Gem::Version::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 1.0.0
59
+ version: