Sha256: 2a5b67676fd69a42260b603987e9d5c3029ced0ed58e0439f3d4f45120fce4f8

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

#!/usr/bin/env ruby

require 'trollop'
require 'rubabel'
require 'rubabel/molecule/fragmentable'


parser = Trollop::Parser.new do
  banner "usage: #{File.basename($0)} [OPTIONS|RULES] <SMARTS> ..."
  text "\noptions:"
  opt :ph, "the pH to use (experimental option)", :default => Rubabel::Molecule::Fragmentable::DEFAULT_OPTIONS[:ph]
  #opt :uniq, "no repeated fragments", :default => false
  text "\nrules:"
  Rubabel::Molecule::Fragmentable::RULES.each do |rule|
    opt rule, rule.to_s.gsub("_",' ')
  end
  text "\nexample:"
  text "fragmenter.rb -aecsoxn 'CCC(=O)OCCC' 'CCC(=O)OCCC(=O)O'"
end

rules = parser.parse(ARGV)
options = {rules: []}
options[:ph] = rules.delete(:ph)
options[:uniq] = rules.delete(:uniq)
rules.each do |k,v|
  options[:rules] << k if v && k.to_s !~ /_given/
end

if ARGV.size == 0
  parser.educate && exit
end

ARGV.each do |mol|
  mol = Rubabel[mol]
  puts "\nmolecule: #{mol.csmiles}"
  fragment_sets = mol.fragment(options)
  fragment_sets.each do |frag_set|
    puts ""
    frag_set.each do |frag|
      puts "#{frag.mass.round(5)} #{frag.csmiles}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubabel-0.2.1 bin/fragmenter.rb
rubabel-0.2.0 bin/fragmenter.rb
rubabel-0.1.6 bin/fragmenter.rb
rubabel-0.1.5 bin/fragmenter.rb