File: canonical_smiles.rb

package info (click to toggle)
openbabel 3.1.1%2Bdfsg-14
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 259,740 kB
  • sloc: cpp: 361,956; python: 11,640; ansic: 6,470; perl: 6,010; pascal: 793; php: 529; sh: 226; xml: 97; ruby: 64; makefile: 45; java: 23
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)}"