Module: Bio::Protparam::Remote
- Defined in:
- lib/bio/util/protparam.rb
Constant Summary
- PROTPARAM_URL =
'http://web.expasy.org/cgi-bin/protparam/protparam'
Instance Attribute Summary (collapse)
-
- (Object) result
Returns the value of attribute result.
Class Method Summary (collapse)
Instance Method Summary (collapse)
Instance Attribute Details
- (Object) result
Returns the value of attribute result
381 382 383 |
# File 'lib/bio/util/protparam.rb', line 381 def result @result end |
Class Method Details
+ (Object) cast_method(type)
383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/bio/util/protparam.rb', line 383 def self.cast_method(type) case type.to_s when "Fixnum" ".to_i" when "Float" ".to_f" when "String" "" else "" end end |
+ (Object) extract_options(*args)
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'lib/bio/util/protparam.rb', line 396 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 |
+ (Object) rule(*args)
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/bio/util/protparam.rb', line 417 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
- (Object) fallback!
505 506 507 508 509 |
# File 'lib/bio/util/protparam.rb', line 505 def fallback! self.class.class_eval do include Local end end |
- (Object) request
497 498 499 500 501 502 503 |
# File 'lib/bio/util/protparam.rb', line 497 def request @result ||= begin res = Net::HTTP.post_form(URI(PROTPARAM_URL), {'sequence' => @seq.to_s}) res.body end end |
- (Boolean) stable?
493 494 495 |
# File 'lib/bio/util/protparam.rb', line 493 def stable? (stablity == 'stable') end |