Class: Rafflesia::Foundry

Inherits:
Object
  • Object
show all
Defined in:
lib/rafflesia/foundry.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Foundry

Returns a new instance of Foundry.



9
10
11
# File 'lib/rafflesia/foundry.rb', line 9

def initialize(client)
  @client = client
end

Instance Method Details

#modelsDesigns(model_id:, structure_object_id:, chain_ids: nil, fixed_positions: nil, num_sequences: nil, output_format: nil, seed: nil, temperature: nil, request_options: {}) ⇒ Rafflesia::EnvelopeFoundryProteinDesignData

POST /v1/foundry/models/model_id/designs

Parameters:

  • model_id (String)
  • chain_ids (Array<String>, nil) (defaults to: nil)

    Optional chain ids to redesign; all protein chains are designed when omitted.

  • fixed_positions (Array<String>, nil) (defaults to: nil)

    Residues held fixed, written as chain id plus 1-based residue number, for example A42.

  • num_sequences (Integer, nil) (defaults to: nil)

    Number of sequences to sample; defaults to 1.

  • output_format (String, nil) (defaults to: nil)
  • seed (Integer, nil) (defaults to: nil)

    Explicit deterministic sampling seed; defaults to 0.

  • structure_object_id (String)

    Rafflesia structure object containing the backbone and any ligand context.

  • temperature (Float, nil) (defaults to: nil)

    Sampling temperature; defaults to 0.1.

  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/rafflesia/foundry.rb', line 66

def modelsDesigns(
  model_id:,
  structure_object_id:,
  chain_ids: nil,
  fixed_positions: nil,
  num_sequences: nil,
  output_format: nil,
  seed: nil,
  temperature: nil,
  request_options: {}
)
  body = {
    'chain_ids' => chain_ids,
    'fixed_positions' => fixed_positions,
    'num_sequences' => num_sequences,
    'output_format' => output_format,
    'seed' => seed,
    'structure_object_id' => structure_object_id,
    'temperature' => temperature
  }.compact
  response = @client.request(
    method: :post,
    path: "/v1/foundry/models/#{Rafflesia::Util.encode_path(model_id)}/designs",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeFoundryProteinDesignData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#modelsEmbeddings(model_id:, inputs:, layer: nil, output_format: nil, pooling: nil, request_options: {}) ⇒ Rafflesia::EnvelopeFoundryEmbeddingData

POST /v1/foundry/models/model_id/embeddings

Parameters:

Returns:



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/rafflesia/foundry.rb', line 106

def modelsEmbeddings(
  model_id:,
  inputs:,
  layer: nil,
  output_format: nil,
  pooling: nil,
  request_options: {}
)
  body = {
    'inputs' => inputs,
    'layer' => layer,
    'output_format' => output_format,
    'pooling' => pooling
  }.compact
  response = @client.request(
    method: :post,
    path: "/v1/foundry/models/#{Rafflesia::Util.encode_path(model_id)}/embeddings",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeFoundryEmbeddingData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#modelsList(workload: nil, request_options: {}) ⇒ Rafflesia::EnvelopeFoundryModelListData

GET /v1/foundry/models

Parameters:

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rafflesia/foundry.rb', line 17

def modelsList(
  workload: nil,
  request_options: {}
)
  params = {
    'workload' => workload
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/foundry/models',
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeFoundryModelListData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#modelsPredictions(model_id:, entities:, affinity_binder_id: nil, constraints: nil, idempotency_key: nil, max_retries: nil, max_template_date: nil, metadata: nil, model: nil, model_type: nil, msa_inputs: nil, msa_mode: nil, msa_server_url: nil, num_diffusion_samples: nil, num_loops: nil, num_models: nil, num_recycles: nil, num_sampling_steps: nil, num_seeds: nil, pair_mode: nil, predict_affinity: nil, random_seed: nil, relax_top_n: nil, templates: nil, timeout_ms: nil, request_options: {}) ⇒ Rafflesia::EnvelopeStructurePredictionSubmitData

POST /v1/foundry/models/model_id/predictions

Parameters:

  • model_id (String)
  • affinity_binder_id (String, nil) (defaults to: nil)

    Ligand entity id used by an affinity-capable backend.

  • constraints (Object, nil) (defaults to: nil)

    Backend-native constraint object; unsupported mappings fail explicitly.

  • entities (Array<Rafflesia::StructurePredictionEntity>, nil)
  • idempotency_key (String, nil) (defaults to: nil)
  • max_retries (Integer, nil) (defaults to: nil)
  • max_template_date (String, nil) (defaults to: nil)

    Template cutoff in YYYY-MM-DD format.

  • metadata (Hash{String => String}, nil) (defaults to: nil)
  • model (String, nil) (defaults to: nil)

    Inference backend: esmfold2-fast, esmfold2, protenix-v2, boltz-2, alphafold2, rf3, or chai-1.

  • model_type (String, nil) (defaults to: nil)

    AlphaFold2 model type; auto chooses monomer or multimer.

  • msa_inputs (Array<Rafflesia::StructurePredictionMsaInput>, nil) (defaults to: nil)

    Per-protein Rafflesia alignment object references.

  • msa_mode (Rafflesia::Types::StructurePredictionRequestMsaMode, nil) (defaults to: nil)
  • msa_server_url (String, nil) (defaults to: nil)

    HTTPS ColabFold-compatible MSA service URL for explicit mmseqs2 modes.

  • num_diffusion_samples (Integer, nil) (defaults to: nil)
  • num_loops (Integer, nil) (defaults to: nil)
  • num_models (Integer, nil) (defaults to: nil)
  • num_recycles (Integer, nil) (defaults to: nil)
  • num_sampling_steps (Integer, nil) (defaults to: nil)
  • num_seeds (Integer, nil) (defaults to: nil)
  • pair_mode (Rafflesia::Types::StructurePredictionRequestPairMode, nil) (defaults to: nil)
  • predict_affinity (Boolean, nil) (defaults to: nil)
  • random_seed (Integer, nil) (defaults to: nil)
  • relax_top_n (Integer, nil) (defaults to: nil)
  • templates (Boolean, nil) (defaults to: nil)
  • timeout_ms (Integer, nil) (defaults to: nil)

    Durable worker deadline in milliseconds.

  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/rafflesia/foundry.rb', line 160

def modelsPredictions(
  model_id:,
  entities:,
  affinity_binder_id: nil,
  constraints: nil,
  idempotency_key: nil,
  max_retries: nil,
  max_template_date: nil,
  metadata: nil,
  model: nil,
  model_type: nil,
  msa_inputs: nil,
  msa_mode: nil,
  msa_server_url: nil,
  num_diffusion_samples: nil,
  num_loops: nil,
  num_models: nil,
  num_recycles: nil,
  num_sampling_steps: nil,
  num_seeds: nil,
  pair_mode: nil,
  predict_affinity: nil,
  random_seed: nil,
  relax_top_n: nil,
  templates: nil,
  timeout_ms: nil,
  request_options: {}
)
  body = {
    'affinity_binder_id' => affinity_binder_id,
    'constraints' => constraints,
    'entities' => entities,
    'idempotency_key' => idempotency_key,
    'max_retries' => max_retries,
    'max_template_date' => max_template_date,
    'metadata' => ,
    'model' => model,
    'model_type' => model_type,
    'msa_inputs' => msa_inputs,
    'msa_mode' => msa_mode,
    'msa_server_url' => msa_server_url,
    'num_diffusion_samples' => num_diffusion_samples,
    'num_loops' => num_loops,
    'num_models' => num_models,
    'num_recycles' => num_recycles,
    'num_sampling_steps' => num_sampling_steps,
    'num_seeds' => num_seeds,
    'pair_mode' => pair_mode,
    'predict_affinity' => predict_affinity,
    'random_seed' => random_seed,
    'relax_top_n' => relax_top_n,
    'templates' => templates,
    'timeout_ms' => timeout_ms
  }.compact
  response = @client.request(
    method: :post,
    path: "/v1/foundry/models/#{Rafflesia::Util.encode_path(model_id)}/predictions",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeStructurePredictionSubmitData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#modelsShow(model_id:, request_options: {}) ⇒ Rafflesia::EnvelopeFoundryModelDescriptor

GET /v1/foundry/models/model_id

Parameters:

  • model_id (String)
  • request_options (Hash) (defaults to: {})

    (see Rafflesia::Types::RequestOptions)

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rafflesia/foundry.rb', line 40

def modelsShow(
  model_id:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/v1/foundry/models/#{Rafflesia::Util.encode_path(model_id)}",
    auth: true,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeFoundryModelDescriptor.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#modelsVariantEffects(model_id:, sequence:, variants:, scoring_method: nil, request_options: {}) ⇒ Rafflesia::EnvelopeFoundryVariantEffectData

POST /v1/foundry/models/model_id/variant-effects

Parameters:

Returns:



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/rafflesia/foundry.rb', line 233

def modelsVariantEffects(
  model_id:,
  sequence:,
  variants:,
  scoring_method: nil,
  request_options: {}
)
  body = {
    'scoring_method' => scoring_method,
    'sequence' => sequence,
    'variants' => variants
  }.compact
  response = @client.request(
    method: :post,
    path: "/v1/foundry/models/#{Rafflesia::Util.encode_path(model_id)}/variant-effects",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeFoundryVariantEffectData.new(response.body)
  result.last_response = Rafflesia::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end