Sha256: f279b0cc6232e282cb1a0921d2c5d200a3da849448e45236634ddb024a5c6759

Contents?: true

Size: 1.12 KB

Versions: 33

Compression:

Stored size: 1.12 KB

Contents

require 'mspire/cv/param'
require 'mspire/cv/obo'

module Mspire
  module CV

    # a mass spec related CVParam.  
    module Param

      # Takes one of these invocations:
      #
      #     acc_num[, unit_acc_num]
      #     acc_num, value[, unit_acc_num]
      #
      # Where acc_num and unit_acc_num are strings containing valid accession
      # numbers (e.g., 'MS:1000514' or 'UO:0000108').  Note that sometimes units are
      # from obo's other than UO.
      #
      # returns a CV::Param object
      def self.[](*args)
        #puts "param args #{args.inspect}"
        unit = 
          case args.size
          when 1
            nil
          when 2
            Mspire::CV::Param[args.pop] if args.last.is_a?(String) && args.last =~ /^[A-Za-z]+:/
          when 3
            Mspire::CV::Param[args.pop]
          end
        acc = args[0]
        obo_type = acc[/([A-Za-z]+):/,1]
        val = args[1]
        if val
          cast = Mspire::CV::Obo::CAST[acc]
          (val = val.send(cast)) if cast
        end
        ::CV::Param.new(obo_type, args[0], Mspire::CV::Obo::NAME[acc], val, unit)
      end
    end
  end

end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
mspire-0.10.8.0 lib/mspire/cv/param.rb
mspire-0.10.7.3 lib/mspire/cv/param.rb
mspire-0.10.7.2 lib/mspire/cv/param.rb
mspire-0.10.7.1 lib/mspire/cv/param.rb
mspire-0.10.7 lib/mspire/cv/param.rb
mspire-0.10.6 lib/mspire/cv/param.rb
mspire-0.10.5 lib/mspire/cv/param.rb
mspire-0.10.4 lib/mspire/cv/param.rb
mspire-0.10.3 lib/mspire/cv/param.rb
mspire-0.10.2 lib/mspire/cv/param.rb
mspire-0.10.1 lib/mspire/cv/param.rb
mspire-0.10.0 lib/mspire/cv/param.rb
mspire-0.9.2 lib/mspire/cv/param.rb
mspire-0.9.1 lib/mspire/cv/param.rb
mspire-0.9.0 lib/mspire/cv/param.rb
mspire-0.8.7 lib/mspire/cv/param.rb
mspire-0.8.6.2 lib/mspire/cv/param.rb
mspire-0.8.6.1 lib/mspire/cv/param.rb
mspire-0.8.6 lib/mspire/cv/param.rb
mspire-0.8.5 lib/mspire/cv/param.rb