Class: Rafflesia::Molecules

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Molecules

Returns a new instance of Molecules.



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

def initialize(client)
  @client = client
end

Instance Method Details

#describe(smiles:, backend: nil, request_options: {}) ⇒ Rafflesia::EnvelopeMoleculeDescribeData

POST /v1/molecules/describe

Parameters:

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

    Descriptor backend; defaults to rdkit.

  • smiles (String)

    Input molecule as a SMILES string.

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

    (see Rafflesia::Types::RequestOptions)

Returns:



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

def describe(
  smiles:,
  backend: nil,
  request_options: {}
)
  body = {
    'backend' => backend,
    'smiles' => smiles
  }.compact
  response = @client.request(
    method: :post,
    path: '/v1/molecules/describe',
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeMoleculeDescribeData.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

#fingerprintsCompute(backend: nil, molecule_id: nil, smiles: nil, request_options: {}) ⇒ Rafflesia::EnvelopeMoleculeFingerprintsData

POST /v1/molecules/fingerprints/compute

Parameters:

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

    Fingerprint backend; defaults to rdkit.

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

    Stored molecule id to fingerprint. Provide exactly one of molecule_id or smiles; molecule_id takes precedence.

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

    Inline SMILES to fingerprint directly, without importing a stored molecule. Mirrors molecules describe.

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

    (see Rafflesia::Types::RequestOptions)

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rafflesia/molecules.rb', line 45

def fingerprintsCompute(
  backend: nil,
  molecule_id: nil,
  smiles: nil,
  request_options: {}
)
  body = {
    'backend' => backend,
    'molecule_id' => molecule_id,
    'smiles' => smiles
  }.compact
  response = @client.request(
    method: :post,
    path: '/v1/molecules/fingerprints/compute',
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeMoleculeFingerprintsData.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

#import(path:, source_id: nil, request_options: {}) ⇒ Rafflesia::EnvelopeMoleculeImportData

POST /v1/molecules/import

Parameters:

  • path (String)

    Local SDF/MOL file path to import.

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

    Optional caller-supplied source identifier.

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

    (see Rafflesia::Types::RequestOptions)

Returns:



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/rafflesia/molecules.rb', line 73

def import(
  path:,
  source_id: nil,
  request_options: {}
)
  body = {
    'path' => path,
    'source_id' => source_id
  }.compact
  response = @client.request(
    method: :post,
    path: '/v1/molecules/import',
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeMoleculeImportData.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

#inspect(molecule_id:, request_options: {}) ⇒ Rafflesia::EnvelopeMoleculeInspectData

POST /v1/molecules/inspect

Parameters:

  • molecule_id (String)

    Molecule id (molecule: or sha256:) to inspect.

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

    (see Rafflesia::Types::RequestOptions)

Returns:



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/rafflesia/molecules.rb', line 98

def inspect(
  molecule_id:,
  request_options: {}
)
  body = {
    'molecule_id' => molecule_id
  }
  response = @client.request(
    method: :post,
    path: '/v1/molecules/inspect',
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeMoleculeInspectData.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

#normalize(backend: nil, molecule_id: nil, smiles: nil, request_options: {}) ⇒ Rafflesia::EnvelopeMoleculeNormalizeData

POST /v1/molecules/normalize

Parameters:

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

    Normalization backend; defaults to rdkit.

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

    Stored molecule id to canonicalize. Provide exactly one of molecule_id or smiles; molecule_id takes precedence.

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

    Inline SMILES to canonicalize directly, without importing a stored molecule. Mirrors molecules describe.

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

    (see Rafflesia::Types::RequestOptions)

Returns:



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/rafflesia/molecules.rb', line 123

def normalize(
  backend: nil,
  molecule_id: nil,
  smiles: nil,
  request_options: {}
)
  body = {
    'backend' => backend,
    'molecule_id' => molecule_id,
    'smiles' => smiles
  }.compact
  response = @client.request(
    method: :post,
    path: '/v1/molecules/normalize',
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeMoleculeNormalizeData.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

#search(query:, backend: nil, db: nil, max_hits: nil, request_options: {}) ⇒ Rafflesia::EnvelopeMoleculeSearchData

POST /v1/molecules/search

Parameters:

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

    Search backend; defaults to rdkit.

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

    Database identifier to search, e.g. pdb_ligands.

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

    Maximum number of hits to return.

  • query (String)

    Molecule id or molblock path for the query molecule.

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

    (see Rafflesia::Types::RequestOptions)

Returns:



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/rafflesia/molecules.rb', line 153

def search(
  query:,
  backend: nil,
  db: nil,
  max_hits: nil,
  request_options: {}
)
  body = {
    'backend' => backend,
    'db' => db,
    'max_hits' => max_hits,
    'query' => query
  }.compact
  response = @client.request(
    method: :post,
    path: '/v1/molecules/search',
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Rafflesia::EnvelopeMoleculeSearchData.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