diff --git a/.yardoc/checksums b/.yardoc/checksums index 1e48c8a..2868505 100644 --- a/.yardoc/checksums +++ b/.yardoc/checksums @@ -1,3 +1,4 @@ -lib/classyfire_api.rb ed7783c1c688d4ee2a91044082a5ac80c3cd3c3e +lib/classyfire_api.rb 4e5cc4102771d77c67759b9298ae685f0cb612cd lib/query_resource.rb 645cfb1688a5c44e67e5227fc0e9a77589731f24 lib/entity_resource.rb 6c50b4be6a5eb13b44d7080b19c7033b7a37c7cf +lib/sequence_resource.rb d8c5007781d50d0bc13cbe360b617e2937a19428 diff --git a/.yardoc/object_types b/.yardoc/object_types index 8cb81af..467fb84 100644 Binary files a/.yardoc/object_types and b/.yardoc/object_types differ diff --git a/.yardoc/objects/root.dat b/.yardoc/objects/root.dat index fc0d560..cf147b6 100644 Binary files a/.yardoc/objects/root.dat and b/.yardoc/objects/root.dat differ diff --git a/README.md b/README.md index b44622d..f4a5603 100644 --- a/README.md +++ b/README.md @@ -41,13 +41,31 @@ > > > > > >The output format is "json" (JSON). +> ##2. Sequence## +> +> >Sequences are represented by the Sequence model, through which one can access the compound's structure-based classification. +> > +> >###GET### +> > +> >**/sequence/{fingerprint}** +> > +> >A (FASTA) sequence's classification can be retrieved in the JSON. In this example, the sequence has the fingerprint = "8bf70c23ac100cd2c3955081d8613325" +> > > +> > >ClassyFireAPI.get_sequence_classification("8bf70c23ac100cd2c3955081d8613325","json") +> > +> > Where: +> > +> > >The sequence's fingerprint is "8bf70c23ac100cd2c3955081d8613325", +> > > > The fingerprint is generate by Digest::MD5 from the peptide sequence "APDVQDCPECTLQENPFFSQPGAPILQCMGCCFSRAYPTPLRSKKTMLVQKNVTSESTCCVAKSYNRVTVMGGFKVENHTACHCSTCYYHKS" +> > >The output format is "json" (JSON). -> ##2. Query## + +> ##3. Query## > > >The Query model represents the chemical structure to be classified. Its attributes are the query label and the query input. > > >The query label is an identifier > > > -> > >The query input contains the compound's identifier (optional) and its structural representation, separated by a comma. The chemical structure is represented either in the [Daylight SMILES](http://www.daylight.com/dayhtml/doc/theory/theory.smiles.html) or the [InChI](http://www.iupac.org/home/publications/e-resources/inchi.html) format. +> > >The query input contains the compound's identifier (optional) and its structural representation, separated by a tab. The chemical structure is represented either in the [Daylight SMILES](http://www.daylight.com/dayhtml/doc/theory/theory.smiles.html) format, the [InChI](http://www.iupac.org/home/publications/e-resources/inchi.html) format. Moreover, the compound can be represented with its [IUPAC name](http://www.chem.qmul.ac.uk/iupac/). > > > >###POST### > >A query can be submitted using the POST method as demonstrated in the following example. diff --git a/doc/ClassyFireAPI.html b/doc/ClassyFireAPI.html index 6a7c99c..e05c6fe 100644 --- a/doc/ClassyFireAPI.html +++ b/doc/ClassyFireAPI.html @@ -156,6 +156,30 @@

Retrieves the classification results for a given query.

+ + + +
  • + + + + (Text) get_sequence_classification(fingerprint, format = "json") + + + + + + + + + + + + + +
    +

    Retrieves the classification results for a given sequence.

    +
    +
  • @@ -400,7 +424,7 @@ of a given size.

    -

    the ID of the query.

    +

    the InChIKey of the entity.

    @@ -629,6 +653,129 @@ specified format.

    + + +
    +

    + + + (Text) get_sequence_classification(fingerprint, format = "json") + + + + + +

    +
    + +

    Retrieves the classification results for a given sequence.

    + + +
    +
    +
    +

    Parameters:

    + + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +98
    +99
    +100
    +101
    +
    +
    # File 'lib/classyfire_api.rb', line 87
    +
    +def ClassyFireAPI.get_sequence_classification(fingerprint,format="json")
    +  begin
    +    if format == "json"
    +      RestClient.get "#{URL}/entities/#{fingerprint}.#{format}", :accept => :json
    +    end 
    +  rescue RestClient::ResourceNotFound => e
    +    e.response
    +  rescue  RestClient::InternalServerError => e
    +    e.response
    +  rescue RestClient::GatewayTimeout => e
    +    e.response
    +  rescue RestClient::RequestTimeout => e
    +    e.response
    +  end
    +end
    +
    @@ -695,17 +842,17 @@ specified format.

     
     
    -85
    -86
    -87
    -88
    -89
    -90
    -91
    -92
    +128 +129 +130 +131 +132 +133 +134 +135 -
    # File 'lib/classyfire_api.rb', line 85
    +      
    # File 'lib/classyfire_api.rb', line 128
     
     def ClassyFireAPI.query_status(query_id)
       begin
    @@ -785,49 +932,6 @@ retrieve the strutcure's classification from ClassyFire.

     
     
    -266
    -267
    -268
    -269
    -270
    -271
    -272
    -273
    -274
    -275
    -276
    -277
    -278
    -279
    -280
    -281
    -282
    -283
    -284
    -285
    -286
    -287
    -288
    -289
    -290
    -291
    -292
    -293
    -294
    -295
    -296
    -297
    -298
    -299
    -300
    -301
    -302
    -303
    -304
    -305
    -306
    -307
    -308
     309
     310
     311
    @@ -847,10 +951,53 @@ retrieve the strutcure's classification from ClassyFire.

    325 326 327 -328
    +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371
    -
    # File 'lib/classyfire_api.rb', line 266
    +      
    # File 'lib/classyfire_api.rb', line 309
     
     def ClassyFireAPI.retrieve_classification(input,output)
       absolute_path = File.expand_path(input)
    @@ -986,49 +1133,6 @@ format.

     
     
    -335
    -336
    -337
    -338
    -339
    -340
    -341
    -342
    -343
    -344
    -345
    -346
    -347
    -348
    -349
    -350
    -351
    -352
    -353
    -354
    -355
    -356
    -357
    -358
    -359
    -360
    -361
    -362
    -363
    -364
    -365
    -366
    -367
    -368
    -369
    -370
    -371
    -372
    -373
    -374
    -375
    -376
    -377
     378
     379
     380
    @@ -1039,10 +1143,53 @@ format.

    385 386 387 -388
    +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431
    -
    # File 'lib/classyfire_api.rb', line 335
    +      
    # File 'lib/classyfire_api.rb', line 378
     
     def ClassyFireAPI.retrieve_entities_json(input,output)
       absolute_path = File.expand_path(input)
    @@ -1169,49 +1316,6 @@ format.

     
     
    -397
    -398
    -399
    -400
    -401
    -402
    -403
    -404
    -405
    -406
    -407
    -408
    -409
    -410
    -411
    -412
    -413
    -414
    -415
    -416
    -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
    @@ -1228,10 +1332,53 @@ format.

    453 454 455 -456
    +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499
    -
    # File 'lib/classyfire_api.rb', line 397
    +      
    # File 'lib/classyfire_api.rb', line 440
     
     def ClassyFireAPI.retrieve_entities_sdf(input,output)
       absolute_path = File.expand_path(input)
    @@ -1362,19 +1509,19 @@ slice_length [Integer] The maximum number of entries for each query input
           
     
     
    -184
    -185
    -186
    -187
    -188
    -189
    -190
    -191
    -192
    -193
    +227 +228 +229 +230 +231 +232 +233 +234 +235 +236
    -
    # File 'lib/classyfire_api.rb', line 184
    +      
    # File 'lib/classyfire_api.rb', line 227
     
     def ClassyFireAPI.submit_queries_from_directory(folder,slice_length,type="STRUCTURE")
       if File.directory?(folder)
    @@ -1575,49 +1722,6 @@ framgments from the index 'start'.

     
     
    -107
    -108
    -109
    -110
    -111
    -112
    -113
    -114
    -115
    -116
    -117
    -118
    -119
    -120
    -121
    -122
    -123
    -124
    -125
    -126
    -127
    -128
    -129
    -130
    -131
    -132
    -133
    -134
    -135
    -136
    -137
    -138
    -139
    -140
    -141
    -142
    -143
    -144
    -145
    -146
    -147
    -148
    -149
     150
     151
     152
    @@ -1637,10 +1741,53 @@ framgments from the index 'start'.

    166 167 168 -169
    +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
    -
    # File 'lib/classyfire_api.rb', line 107
    +      
    # File 'lib/classyfire_api.rb', line 150
     
     def ClassyFireAPI.submit_query_input_in_chunks(input_file,slice_length, start, type='STRUCTURE')
       @start_time = Time.now
    @@ -1803,49 +1950,6 @@ text. is fragmented into n part of #slice_length entries each).

     
     
    -209
    -210
    -211
    -212
    -213
    -214
    -215
    -216
    -217
    -218
    -219
    -220
    -221
    -222
    -223
    -224
    -225
    -226
    -227
    -228
    -229
    -230
    -231
    -232
    -233
    -234
    -235
    -236
    -237
    -238
    -239
    -240
    -241
    -242
    -243
    -244
    -245
    -246
    -247
    -248
    -249
    -250
    -251
     252
     253
     254
    @@ -1853,10 +1957,53 @@ text. is fragmented into n part of #slice_length entries each).

    256 257 258 -259
    +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302
    -
    # File 'lib/classyfire_api.rb', line 209
    +      
    # File 'lib/classyfire_api.rb', line 252
     
     def ClassyFireAPI.submit_random_subset_of_query_input_in_chunks(tab_separated_input_file,size, type='STRUCTURE')
       @start_time = Time.now
    @@ -1919,7 +2066,7 @@ text. is fragmented into n part of #slice_length entries each).

    diff --git a/doc/EntityResource.html b/doc/EntityResource.html index 5fe5906..e6521d8 100644 --- a/doc/EntityResource.html +++ b/doc/EntityResource.html @@ -114,7 +114,7 @@ diff --git a/doc/QueryResource.html b/doc/QueryResource.html index 2611f26..87f20f1 100644 --- a/doc/QueryResource.html +++ b/doc/QueryResource.html @@ -183,7 +183,7 @@ diff --git a/doc/SequenceResource.html b/doc/SequenceResource.html new file mode 100644 index 0000000..4bffc57 --- /dev/null +++ b/doc/SequenceResource.html @@ -0,0 +1,123 @@ + + + + + + Class: SequenceResource + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

    Class: SequenceResource + + + +

    + +
    + +
    Inherits:
    +
    + ActiveResource::Base + +
      +
    • Object
    • + + + + + +
    + show all + +
    + + + + + + + + + +
    Defined in:
    +
    lib/sequence_resource.rb
    + +
    +
    + + + + + + + + + + + +
    + + + + + \ No newline at end of file diff --git a/doc/_index.html b/doc/_index.html index f8f7858..19d7247 100644 --- a/doc/_index.html +++ b/doc/_index.html @@ -118,6 +118,19 @@ + + + @@ -127,7 +140,7 @@ diff --git a/doc/class_list.html b/doc/class_list.html index 2a62e5e..f7d10fd 100644 --- a/doc/class_list.html +++ b/doc/class_list.html @@ -50,7 +50,7 @@ diff --git a/doc/file.README.html b/doc/file.README.html index 0deac3a..5b8643f 100644 --- a/doc/file.README.html +++ b/doc/file.README.html @@ -131,7 +131,34 @@ InChIKey=LABTWGUMFABVFG-ONEGZZNKSA-N.

    -

    2. Query

    +

    2. Sequence

    + +
    +

    Sequences are represented by the Sequence model, through which one can +access the compound's structure-based classification.

    + +

    GET

    + +

    /sequence/fingerprint

    + +

    A (FASTA) sequence's classification can be retrieved in the JSON. In +this example, the sequence has the fingerprint = +“8bf70c23ac100cd2c3955081d8613325”

    + +
    +

    ClassyFireAPI.get_sequence_classification(“8bf70c23ac100cd2c3955081d8613325”,“json”)

    +
    + +

    Where:

    + +
    +

    The sequence's fingerprint is “8bf70c23ac100cd2c3955081d8613325”,

    + +

    The output format is “json” (JSON).

    +
    +
    + +

    3. Query

    The Query model represents the chemical structure to be classified. Its @@ -141,12 +168,13 @@ attributes are the query label and the query input.

    The query label is an identifier

    The query input contains the compound's identifier (optional) and its -structural representation, separated by a comma. The chemical structure is +structural representation, separated by a tab. The chemical structure is represented either in the Daylight -SMILES or the format, the InChI -format.

    +format. Moreover, the compound can be represented with its IUPAC name.

    POST

    @@ -155,12 +183,9 @@ format.

    following example.

    -

    ClassyFireAPI.submit_query(“curl_test”,“MOL1tCCCOCCnMOL2tCOCC=CCCC”,“STRUCTURE”)

    -
    +

    ClassyFireAPI.submit_query(“curl_test”,“MOL1tCCCOCCnMOL2tCOCC=CCCC”,“STRUCTURE”) +where the parameters are:

    -

    where the parameters are:

    - -

    The query label: curl_test,

    The entity identifiers: MOL1,MOL2

    @@ -197,14 +222,14 @@ XML format.

    Who do I talk to?

    diff --git a/doc/index.html b/doc/index.html index 30215ef..5b8643f 100644 --- a/doc/index.html +++ b/doc/index.html @@ -131,7 +131,34 @@ InChIKey=LABTWGUMFABVFG-ONEGZZNKSA-N.

    -

    2. Query

    +

    2. Sequence

    + +
    +

    Sequences are represented by the Sequence model, through which one can +access the compound's structure-based classification.

    + +

    GET

    + +

    /sequence/fingerprint

    + +

    A (FASTA) sequence's classification can be retrieved in the JSON. In +this example, the sequence has the fingerprint = +“8bf70c23ac100cd2c3955081d8613325”

    + +
    +

    ClassyFireAPI.get_sequence_classification(“8bf70c23ac100cd2c3955081d8613325”,“json”)

    +
    + +

    Where:

    + +
    +

    The sequence's fingerprint is “8bf70c23ac100cd2c3955081d8613325”,

    + +

    The output format is “json” (JSON).

    +
    +
    + +

    3. Query

    The Query model represents the chemical structure to be classified. Its @@ -141,12 +168,13 @@ attributes are the query label and the query input.

    The query label is an identifier

    The query input contains the compound's identifier (optional) and its -structural representation, separated by a comma. The chemical structure is +structural representation, separated by a tab. The chemical structure is represented either in the Daylight -SMILES or the format, the InChI -format.

    +format. Moreover, the compound can be represented with its IUPAC name.

    POST

    @@ -155,12 +183,9 @@ format.

    following example.

    -

    ClassyFireAPI.submit_query(“curl_test”,“MOL1tCCCOCCnMOL2tCOCC=CCCC”,“STRUCTURE”)

    -
    +

    ClassyFireAPI.submit_query(“curl_test”,“MOL1tCCCOCCnMOL2tCOCC=CCCC”,“STRUCTURE”) +where the parameters are:

    -

    where the parameters are:

    - -

    The query label: curl_test,

    The entity identifiers: MOL1,MOL2

    @@ -197,14 +222,14 @@ XML format.

    Who do I talk to?

    diff --git a/doc/method_list.html b/doc/method_list.html index 324e0cb..8a94711 100644 --- a/doc/method_list.html +++ b/doc/method_list.html @@ -64,54 +64,60 @@
  • + get_sequence_classification + ClassyFireAPI +
  • + + +
  • query_status ClassyFireAPI
  • -
  • +
  • retrieve_classification ClassyFireAPI
  • -
  • +
  • retrieve_entities_json ClassyFireAPI
  • -
  • +
  • retrieve_entities_sdf ClassyFireAPI
  • -
  • +
  • submit_queries_from_directory ClassyFireAPI
  • -
  • +
  • submit_query ClassyFireAPI
  • -
  • +
  • submit_query_input_in_chunks ClassyFireAPI
  • -
  • +
  • submit_random_subset_of_query_input_in_chunks ClassyFireAPI
  • -
  • +
  • #to_param QueryResource
  • diff --git a/doc/top-level-namespace.html b/doc/top-level-namespace.html index 5c5e989..e36a234 100644 --- a/doc/top-level-namespace.html +++ b/doc/top-level-namespace.html @@ -89,7 +89,7 @@ - Classes: EntityResource, QueryResource + Classes: EntityResource, QueryResource, SequenceResource

    @@ -105,7 +105,7 @@ diff --git a/lib/classyfire_api.rb b/lib/classyfire_api.rb index 82bf645..dffe982 100644 --- a/lib/classyfire_api.rb +++ b/lib/classyfire_api.rb @@ -55,7 +55,7 @@ module ClassyFireAPI # Retrieves the classification results for a given entity. # - # @param inchikey [String] the ID of the query. + # @param inchikey [String] the InChIKey of the entity. # @param format [String] the format of the query, 'text' (either JSON, CSV, or SDF) # @return [Text] A text file displaying the classification results for the entity in the specified format. def ClassyFireAPI.get_entity_classification(inchikey,format="json") @@ -79,6 +79,49 @@ module ClassyFireAPI end end + # Retrieves the classification results for a given sequence. + # + # @param the fingerprint [String] the fingerprint (generated from the sequence using Digest::MD5). + # @param format [String] the format of the query (Only JSON) + # @return [Text] A text file displaying the classification results for the entity in the specified format. + def ClassyFireAPI.get_sequence_classification(fingerprint,format="json") + begin + if format == "json" + RestClient.get "#{URL}/entities/#{fingerprint}.#{format}", :accept => :json + end + rescue RestClient::ResourceNotFound => e + e.response + rescue RestClient::InternalServerError => e + e.response + rescue RestClient::GatewayTimeout => e + e.response + rescue RestClient::RequestTimeout => e + e.response + end + end + + def ClassyFireAPI.get_entity_classification(inchikey,format="json") + inchikey_id = inchikey.to_s.gsub('InChIKey=','') + begin + if format == "json" + RestClient.get "#{URL}/entities/#{inchikey_id}.#{format}", :accept => :json + elsif format == "sdf" + RestClient.get "#{URL}/entities/#{inchikey_id}.#{format}", :accept => :sdf + elsif format == "csv" + RestClient.get "#{URL}/entities/#{inchikey_id}.#{format}", :accept => :csv + end + rescue RestClient::ResourceNotFound => e + e.response + rescue RestClient::InternalServerError => e + e.response + rescue RestClient::GatewayTimeout => e + e.response + rescue RestClient::RequestTimeout => e + e.response + end + end + + # Retrieves the status of a query # @param query_id [Integer] the ID of the query # @return [String] the query status, 'Done' or 'In progress', 'string' diff --git a/lib/sequence_resource.rb b/lib/sequence_resource.rb new file mode 100644 index 0000000..8473d75 --- /dev/null +++ b/lib/sequence_resource.rb @@ -0,0 +1,6 @@ +require 'active_resource' + +class SequenceResource < ActiveResource::Base + self.site ='http://classyfire.wishartlab.com' + self.element_name = "sequence" +end \ No newline at end of file