wrapping open babel with ruby

Upload: lateecka-r-kulkarni

Post on 02-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 wrapping open babel with ruby

    1/22

    This Provisional PDF corresponds to the article as it appePDF and full text (HTML) versions will be

    Rubabel: Wrapping OpenBab

    Journal of Cheminformatics 2013, 5:35 do

    Rob Smith (2robsmith@gmRyan Williamson (rwilliamson88Dan Ventura ([email protected]

    John T Prince (jtprince@chem

    Journal of Cheminformatics

    mailto:[email protected]:[email protected]:[email protected]:[email protected]:[email protected]:[email protected]:[email protected]:[email protected]
  • 7/27/2019 wrapping open babel with ruby

    2/22

    Rubabel: wrapping open Babel

    Rob Smith1

    Corresponding author

    Email: [email protected]

    Ryan Williamson1

    Email: [email protected]

    Dan Ventura

    1

    Email: [email protected]

    J h T P i 2

  • 7/27/2019 wrapping open babel with ruby

    3/22

    Keywords

    Chemoinformatics, Open Babel, Ruby

    Background

    Despite the fact that chemoinformatics tools have been de

    field has yet to rally in support of a single library. The intri

    the low-level programming prowess required for these lang

    to adoption by less programming-oriented practitioners. W

    dont share complete coverage of implemented tasks, meabe struggling with the language barrier, has to shoulder

    versed in the differences between the libraries, including d

  • 7/27/2019 wrapping open babel with ruby

    4/22

    Ruby has penetrated the applied sciences where the need

    meets appreciation for an easy learning curve [15,16]. A m

    ing, and powerful language paradigm have made Ruby an

    matics tools, such as BioRuby [17].

    For those who are not comfortable enough with programm

    who prefer the Ruby way, and for those who want to do

    present Rubabel. Rubabel offers a convenient, intuitive m

    intra-molecular navigation with minimal lines of code per

    developed project with a substantial amount of implemen

    accessible extension mechanism for customization.

    Implementation

  • 7/27/2019 wrapping open babel with ruby

    5/22

    Listing 1 Creating a molecule from a SMILES string with

    bindings

    obmol = OpenBabel::OBMol.new

    obconv = OpenBabel::OBConversion.new

    obconv.set_in_format("smi")

    obconv.read_string(obmol, "CN2C(=O)N(C)C(=O)C1=

    Rubyists will notice that this code seems strikingly more l

    that despite the uncharacteristic simplicity of this exampl

    explicit details of the Open Babel architecture including th

    jects and modification methods for OBConversion. For msuch as highlighting a substructure within a molecule in a

    parable to C++. Adding Ruby-style objects and idioms to

  • 7/27/2019 wrapping open babel with ruby

    6/22

    Figure 2 Novel functionality in Rubabel. Besides pro

    functions, Rubabel provides a host of novel functionality.

    Rubabel: Ruby idioms for concise and convenient code

    Ruby is a language designed to be easy to use, intuitive

    embody as many of these admittedly subjective qualitie

    object behavior in ways consistent with established Ruby i

    Object orientation

    Rubabels object-oriented paradigm defines behaviors for

    For example, Open Babels Tanimoto coefficient logic w

  • 7/27/2019 wrapping open babel with ruby

    7/22

    Listing 3 Report how many SD file records are within a

    weight range

    require rubabel

    puts Rubabel.foreach("benzodiazepine.sdf.gz").

    String idiom

    To assist in convenience and minimize syntax lookup time

    neered for frequent exposure in Rubabel. For example, the

    treated as a string, allowing splitting and matching operatioexample, the user can collect all atoms with two bonds (e

    and append a carbon to the first atom in the filtered collect

  • 7/27/2019 wrapping open babel with ruby

    8/22

    Access methods

    Rubabel is designed to simplify common IO tasks to prov

    matics functionality. Rubabel allows creation of MolecuBabel accepts, including SMILES strings (see Listing 7).

    line where the SWIG code requires 4 (compare with Listin

    Listing 7 Creating a molecule from a SMILES string with

    mol = Rubabel["CN2C(=O)N(C)C(=O)C1=C2N=CN1C"]

    Efficiency in accessing objects is very important to redu

    Listing 8 gives some examples of object traversal in Ruba

    cessing that can be done with very few lines of code in R

  • 7/27/2019 wrapping open babel with ruby

    9/22

    Listing 9 Finding a certain molecule in an SDF file in Rub

    require "rubabel"

    mol = Rubabel.foreach("benzodiazepine.sdf.gz")

    Listing 10 Finding a certain molecule in an SDF file in RD

    from rdkit import Chem

    suppl = Chem.SDMolSupplier(benzodiazepine.sdf

    tgt=None

    for mol in suppl:

    if not mol: continueif mol.GetProp(_Name)==3016:

    tgt=mol

    break

  • 7/27/2019 wrapping open babel with ruby

    10/22

    Custom behavior

    We have provided explicit Molecule methods for commo

    calculation, substructure highlighting, and graph diameter musers need custom extended behavior in Rubabel, they can

    as Ruby open classes. Objects in Ruby are more accessib

    some other languages. Writing custom behavior into Rub

    Although Open Babel has a plugin mechanism which allow

    the toolkit, usage is not trivial. In contrast, Rubabel can

    using Rubys open classes. A class is open when it allows

    functionality in the local scope. For example, the authors a

    Rubabel that defines fragmentation behavior for lipid mo

    behavior defined by Rubabel and also need to add descript

    to accomplish their task With Rubabel this is as simple

  • 7/27/2019 wrapping open babel with ruby

    11/22

    Table 2 Ruby extensions accessible to Rubabel

    Extension Possible a

    Sinatra [20], a web application framework Quick and

    bel, allow

    chemoinfo

    Sciruby [16], a scientific library Plotting, s

    ming lang

    Rubyvis graphical library [22] Open end

    representa

    IRB, the interactive Ruby shell Quick acc

    a terminalRspec, an automated code testing library [21] Automate

    Rubabel (

  • 7/27/2019 wrapping open babel with ruby

    12/22

    The simplicity of this example readily extends to virtually

    The interactive Ruby shell (IRB)

    Though space will not permit an exhaustive consideratio

    used in conjunction with Rubabel, the interactive Ruby s

    with languages like Python, Rubys interactive shell allow

    experiments, test syntax, or debug their scripts. IRB can

    Rubygems) by typing gem install irb. Simply ent

    terminal) and type require rubabel and all of Ru

    an interactive terminal. This is particularly useful given th

    accomplish in just one line. Rubabel in IRB provides an i

    realtime with instant feedbacka refreshing alternative to

    d li t A ti d b f thi i l

  • 7/27/2019 wrapping open babel with ruby

    13/22

    Figure 4 Average lines of code per CTR task. On aver

    code than any other toolkit.

    Figure 5 Number of CTR tasks listed. Rubabel has mor

    Figure 6 Lines of code per CTR task. Rubabel has m

    toolkit, and also requires fewer lines of code than any oth

    9, where Pybel uses one fewer line of code, and task 10,

    concise.

    Rubabel has some features which users may find useful th

    include an explicit Bond object and the associated functi

  • 7/27/2019 wrapping open babel with ruby

    14/22

    Operating System(s): Platform independent

    Programming language: Ruby

    Other requirements: Open Babels Install Requirements

    License: MIT

    Any restrictions to use by non-academics: None

    Competing interests

    The authors declare that they have no competing interest.

  • 7/27/2019 wrapping open babel with ruby

    15/22

    9. OBoyle N, Banck M, James C, Morley C, Vanderme

    an open chemical toolbox. J Cheminformatics 2011,

    1758-2946-3-33] [10.1186/1758-2946-3-33]

    10. Rubygems. [http://www.rubygems.org]

    11. Pavlov D, Rybalkin M, Karulin B, Kozhevnikov M

    universal cheminformatics API. J Cheminformatics

    doi.org/10.1186/1758-2946-3- S1-P4] [10.1186/1758-

    12. RDKit. [http://www.rdkit.org]

    13. OEChem: OpenEye Scientific Software: Sante Fe,

    14. Ihlenfeldt WD, Takahashi Y, Abe H, Sasaki S: Comp

  • 7/27/2019 wrapping open babel with ruby

    16/22

  • 7/27/2019 wrapping open babel with ruby

    17/22

  • 7/27/2019 wrapping open babel with ruby

    18/22

  • 7/27/2019 wrapping open babel with ruby

    19/22

  • 7/27/2019 wrapping open babel with ruby

    20/22

  • 7/27/2019 wrapping open babel with ruby

    21/22

  • 7/27/2019 wrapping open babel with ruby

    22/22

    Figure 6