Module: Bio::Protparam::Remote
- Defined in:
- lib/bio/util/protparam.rb
Constant Summary collapse
- PROTPARAM_URL =
'http://web.expasy.org/cgi-bin/protparam/protparam'
Instance Attribute Summary collapse
-
#result ⇒ Object
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
376 377 378 |
# File 'lib/bio/util/protparam.rb', line 376 def result @result end |
Class Method Details
.cast_method(type) ⇒ Object
378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/bio/util/protparam.rb', line 378 def self.cast_method(type) case type.to_s when "Fixnum" ".to_i" when "Float" ".to_f" when "String" "" else "" end end |
.extract_options(*args) ⇒ Object
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/bio/util/protparam.rb', line 391 def self.(*args) # label, class, regex # label, class, regex, lambda # label, lambda label, type, regex, block = [nil, nil, nil, nil] if args.size > 2 label = args.shift type = args.shift if args.size > 1 regex, block = args elsif args.size > 0 regex, block = if args.first.kind_of?(Regexp) [args.first, nil] elsif args.first.respond_to?(:call) [nil, args.first] end end end [label, type, regex, block] end |
.rule(*args) ⇒ Object
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
# File 'lib/bio/util/protparam.rb', line 412 def self.rule(*args) (label, type, regex, block) = (*args) if regex && block self.class_eval <<-METHOD METHOD elsif regex && !block self.class_eval <<-METHOD def #{label} response = self.request matched = %r/#{regex}/.match(response) if matched.size > 1 matched[1]#{cast_method(type)} else nil end end METHOD elsif !regex && block wrapped_block = Proc.new {|*method_args| response = self.request method_args.unshift response block.call(method_args) } self.send(:define_method, label, &wrapped_block) else raise ArgumentError, "Invalid arguments.rule(:label, :type, :regex) or rule(:label, :type, :lambda)" end end |
Instance Method Details
#fallback! ⇒ Object
500 501 502 503 504 |
# File 'lib/bio/util/protparam.rb', line 500 def fallback! self.class.class_eval do include Local end end |
#request ⇒ Object
492 493 494 495 496 497 498 |
# File 'lib/bio/util/protparam.rb', line 492 def request @result ||= begin res = Net::HTTP.post_form(URI(PROTPARAM_URL), {'sequence' => @seq.to_s}) res.body end end |
#stable? ⇒ Boolean
488 489 490 |
# File 'lib/bio/util/protparam.rb', line 488 def stable? (stablity == 'stable') end |