Class: Tigre::Analysis

Inherits:
Object
  • Object
show all
Extended by:
CommonGetters, CommonParams
Defined in:
lib/tigre-client/analysis.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CommonParams

before_after, before_after_page_per, common_params, get_klass, get_logic_param, package_array_list, page_per

Methods included from CommonGetters

count, index

Class Method Details

.add_file(analysis_id, file_location, file_type) ⇒ Object

required

analysis_id => String
file_location => String path to the file
file_type => String, the type of the file


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/tigre-client/analysis.rb', line 42

def self.add_file(analysis_id, file_location, file_type)
  if analysis_id == '' || file_location.empty? || file_type.empty?
    raise "Missing analysis_id, file_location, or file_type parameter"
  end
  
  if Tigre.s3_analysis_enabled?
    Tigre.logger.info 'Uploading file directly to S3' if Tigre.logger
    bucket = S3Bucket.new(Tigre.s3_analysis_bucket)
    bucket.send_file(file_location, "analysis/#{id.to_s}/#{file[:filename]}")
    
    f = File.new(file, 'r')
    update_data = {:file_hash => {'name' => File.basename(f), 
                                  'size' => File.size(f), 
                                  'file_type' => file_type}}
    Tigre.put_connection("/analyses/#{analysis_id}", update_data)
  else
    update_data = {:file => File.new(file_location), :file_type => file_type}
    Tigre.put_connection("/analyses/#{analysis_id}/upload", update_data)
  end
end

.get_samples_with_dbts(dbts_name_list) ⇒ Object

required

dbts_name_list => Hash => I.E {'key1' => 1, 'key2 => 0}


89
90
91
92
93
# File 'lib/tigre-client/analysis.rb', line 89

def self.get_samples_with_dbts(dbts_name_list)
  raise 'Missing dbts_name_list' if dbts_name_list == ''
  search = {:dbts_name_list => dbts_name_list}
  Tigre.put_connection("/analyses/samples/dbts_name", search)
end

.get_samples_with_mutex(mutex_name_list) ⇒ Object

required

mutex_name_list => String (comma seperated) => I.E 'foo,bar,baz'
mutex_name_list => Array => ['foo', 'bar', 'baz']


74
75
76
77
# File 'lib/tigre-client/analysis.rb', line 74

def self.get_samples_with_mutex(mutex_name_list)
  raise 'Missing mutex_name_list' if mutex_name_list == ''
  Tigre.get_connection("/analyses/samples/mutex_name?mutex_name_list=#{package_array_list(mutex_name_list)}")
end

.get_urls_with_dbts(dbts_name_list) ⇒ Object

required

dbts_name_list => Hash => I.E {'key1' => 1, 'key2 => 0}


81
82
83
84
85
# File 'lib/tigre-client/analysis.rb', line 81

def self.get_urls_with_dbts(dbts_name_list)
  raise 'Missing dbts_name_list' if dbts_name_list == ''
  search = {:dbts_name_list => dbts_name_list}
  Tigre.put_connection("/analyses/urls/dbts_name", search)
end

.get_urls_with_mutex(mutex_name_list) ⇒ Object

required

mutex_name_list => String (comma seperated) => I.E 'foo,bar,baz'
mutex_name_list => Array => ['foo', 'bar', 'baz']


66
67
68
69
# File 'lib/tigre-client/analysis.rb', line 66

def self.get_urls_with_mutex(mutex_name_list)
  raise 'Missing mutex_name_list' if mutex_name_list == ''
  Tigre.get_connection("/analyses/urls/mutex_name?mutex_name_list=#{package_array_list(mutex_name_list)}")
end

.update(analysis_id, params_hash) ⇒ Object

required

analysis_id => String
params_hash => Hash
  :dbts => Hash {:key1 => value, :key2 => value} where the key is what the name of the 
           attribute is and the value should be a boolean
  :mutex_name_list => String (comma seperated) => I.E 'foo,bar,baz'
  :mutex_name_list => Array => ['foo', 'bar', 'baz']


24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/tigre-client/analysis.rb', line 24

def self.update(analysis_id, params_hash)
  if analysis_id == '' || params_hash.empty?
    raise "Missing analysis_id parameter or params_hash is empty"
  end
  
  if params_hash[:mutex_name_list]
    params_hash[:mutex_name_list] = package_array_list(params_hash[:mutex_name_list])
  end
  
  update_data = {:metadatas => params_hash}
  
  Tigre.put_connection("/analyses/#{analysis_id}", update_data)
end

Instance Method Details

#get(analysis_id) ⇒ Object

required

analysis_id => String


9
10
11
12
13
14
15
# File 'lib/tigre-client/analysis.rb', line 9

def get(analysis_id)
  if analysis_id == '' 
    raise "Missing analysis_id parameter"
  end
  
  Tigre.get_connection("analyses/#{analysis_id}")
end