Class: Unipept::Commands::Uniprot

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/uniprot.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#root_commandObject (readonly)

Returns the value of attribute root_command.



5
6
7
# File 'lib/commands/uniprot.rb', line 5

def root_command
  @root_command
end

#valid_formatsObject (readonly)

Returns the value of attribute valid_formats.



5
6
7
# File 'lib/commands/uniprot.rb', line 5

def valid_formats
  @valid_formats
end

Class Method Details

.get_uniprot_entry(accession, format) ⇒ String

Fetches a UniProt entry from the UniProt website with the given accession number in the requested format.

Parameters:

  • accession (String)

    The accession number of the record to fetch

  • format (String)

    The format of of the record. If the format is ‘sequence’, the sequence will be returned in as a single line

Returns:

  • (String)

    The requested UniProt entry in the requested format



58
59
60
61
62
63
64
65
66
# File 'lib/commands/uniprot.rb', line 58

def self.get_uniprot_entry(accession, format)
  if format == 'sequence'
    get_uniprot_entry(accession, 'fasta').lines.map(&:chomp)[1..].join
  else
    # other format has been specified, just download and output
    resp = Typhoeus.get("https://rest.uniprot.org/uniprotkb/#{accession}.#{format}")
    resp.response_body if resp.success?
  end
end

.run(args) ⇒ void

This method returns an undefined value.

Invokes the uniprot command-line tool with the given arguments.

Parameters:

  • args (Array<String>)

    An array of command-line arguments



46
47
48
# File 'lib/commands/uniprot.rb', line 46

def self.run(args)
  @root_command.run(args)
end