File: canonical_smiles.rb

package info (click to toggle)
openbabel 2.3.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 76,164 kB
  • sloc: cpp: 316,390; ansic: 91,270; python: 6,971; perl: 6,591; pascal: 793; sh: 193; xml: 97; ruby: 55; makefile: 38; java: 23; cs: 14
file content (20 lines) | stat: -rw-r--r-- 514 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'openbabel'

class Convertor
  def initialize
    @conversion = OpenBabel::OBConversion.new
    @conversion.set_in_and_out_formats 'smi', 'can'
  end

  def convert smiles
    mol = OpenBabel::OBMol.new

    @conversion.read_string mol, smiles
    @conversion.write_string mol
  end
end
 
c=Convertor.new
aminopterin_smiles = "C1=CC(=CC=C1C(=O)N[C@@H](CCC(=O)O)C(=O)O)NCC2=CN=C3C(=N2)C(=NC(=N3)N)N" # from PubChem CID 2154

puts "The canonical SMILES for aminopterin is:\n#{c.convert(aminopterin_smiles)}"