Easily Calculate TPSA Descriptors from SMILES Strings Using Ruby CDK 3

Posted by Rich Apodaca Wed, 19 Sep 2007 13:27:00 GMT

A D-F reader wrote in to ask how to calculate Topological Polar Surface Area (TPSA) using Ruby CDK. TPSA is one of the most widely-used descriptors for predicting membrane permeability and from it other important ADME properties. This article shows how to calculate TPSA with Ruby using Ruby CDK.

The Library

Our library consists of nothing more than a few method calls to manipulate the underlying CDK library. The tpsa_for method accepts any SMILES string and returns the calculated TPSA:

require 'rubygems'
require_gem 'rcdk'
require 'rcdk/util'

jrequire 'org.openscience.cdk.qsar.descriptors.molecular.TPSADescriptor'

module TPSA
  @@calc = Org::Openscience::Cdk::Qsar::Descriptors::Molecular::TPSADescriptor.new

  def tpsa_for smiles
    mol = RCDK::Util::Lang.read_smiles smiles

    @@calc.calculate(mol).getValue.doubleValue
  end
end

An Interactive Test

Saving the library to a file called tpsa.rb lets us test it through interactive Ruby (irb):

$ irb
irb(main):001:0> require 'tpsa'
./tpsa.rb:2:Warning: require_gem is obsolete.  Use gem instead.
/usr/local/lib/ruby/gems/1.8/gems/rcdk-0.3.0/lib/rcdk/java.rb:26:Warning: require_gem is obsolete.  Use gem instead.
=> true
irb(main):002:0> include TPSA
=> Object
irb(main):003:0> tpsa_for 'COCCc1ccc(OCC(O)CNC(C)C)cc1' # metoprolol
=> 50.72
irb(main):004:0> tpsa_for 'O=C3Nc1ccc(Cl)cc1C(c2ccccc2)=NC3O' # oxazepam
=> 61.69

The results we obtain for metoprolol and oxazepam are 50.72 and 61.69, respectively. These values compare well with those reported by Ertl et al. in the definitive paper on TPSA (50.7 and 61.7, respectively).

Conclusions

It doesn't take much Ruby to command a wide range of cheminformatics functionality - in this case TPSA calculations. But the fun doesn't stop there. The CDK, and by extension Ruby CDK, offer access to a wide array of descriptor calculations, each of which follow the same basic pattern outlined here. All of it can be prototyped, debugged, and deployed through one of the most flexible programming languages currently available.

Comments

Leave a response

  1. Egon Willighagen Wed, 19 Sep 2007 20:30:45 GMT

    You compiled a very nice list of Ruby-CDK blog items. Care to put them together as a CDK News article?

    Very, very nice clean piece of code, BTW !

  2. Rich Apodaca Thu, 20 Sep 2007 18:06:28 GMT

    Thanks, Egon. It might be very useful to compile links to all of these Ruby CDK examples. Sometimes, even I'm not sure about what I have and haven't already written on the subject.

    Either way, Ruby CDK needs a landing page containing instructions for downloading and installing on Windows/Linux.

  3. Egon Willighagen Fri, 21 Sep 2007 07:41:35 GMT

    You are more than welcome to start a wiki page on that. Maybe: http://wiki.cubic.uni-koeln.de/cdkwiki/doku.php?id=ruby_cdk ?

Comments