From 0fa92f18008696c6480b9503e7733c940957e09a Mon Sep 17 00:00:00 2001
From: djoumbou
Date: Wed, 9 Mar 2016 19:50:36 -0700
Subject: [PATCH] - added sequence resource and corresponding doc
---
.yardoc/checksums | 3 +-
.yardoc/object_types | Bin 607 -> 678 bytes
.yardoc/objects/root.dat | Bin 25815 -> 27730 bytes
README.md | 22 +-
doc/ClassyFireAPI.html | 641 +++++++++++++++++++++--------------
doc/EntityResource.html | 2 +-
doc/QueryResource.html | 2 +-
doc/SequenceResource.html | 123 +++++++
doc/_index.html | 15 +-
doc/class_list.html | 2 +-
doc/file.README.html | 47 ++-
doc/index.html | 47 ++-
doc/method_list.html | 22 +-
doc/top-level-namespace.html | 4 +-
lib/classyfire_api.rb | 45 ++-
lib/sequence_resource.rb | 6 +
16 files changed, 694 insertions(+), 287 deletions(-)
create mode 100644 doc/SequenceResource.html
create mode 100644 lib/sequence_resource.rb
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 8cb81af1474dd75b7005edf23d2be3d39c7fb793..467fb847c400eba5522b7fbfe0ca2dae80e2b9d6 100644
GIT binary patch
delta 80
zcmcc5vW#^?G>f38lKkWVM$w5S;nI4}If=!^m2R0usg41jdg-Yp@x`fyrKx$zsT;S|
fGcs~aHe=Eh_f!%MhKdHI7U!21C8x4kv%3KRC{G$T
delta 28
kcmZ3+dY@%NG>d?zlKkWbM$w5S;TwNvF*34GPGiyp0EPSr-~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Nk1#yDwwDFV=yl*RSl}x
zX_^ZUBv;J>1IrRyJI}xhJ|aWZ`h{$4sq6jgJ*_*#uMmT`hzY4Ae{Cg$pUtc^P)|U+
zAoqCwk8p?*=HkTzrP2@as|E!8=$T_+oj&NKe95mVY^vsAU2X=iv9NI%SDVgq8lY{M
zWXb2f$3iRqYFz?7F8WU~dQgh$+p2jzC`BL8>YqeD(8o0^MLy|5U>^sQI1^k1n^I)k
zETRE(XoDM9GAE?cjsXrFcr9$8_I|hoT(}x87F_WpmNXor2f4^YaN}a+JVekDH9;44
zM!oG0k?8{B^tuTjqN#si{dOo)=!$d1qTEVD;{NZ;1ms{mi5v6aNEV0N_VYiNm-71OQxgcdc
zNhHlf@LNwac+lB93??)g^E4ui*!SWTn}=(qI*Jl@E6&zbP;cHY(s-72Fc6=7e5kw{e > >
> > >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.
# File 'lib/classyfire_api.rb', line 87
+
+defClassyFireAPI.get_sequence_classification(fingerprint,format="json")
+ begin
+ ifformat=="json"
+ RestClient.get"#{URL}/entities/#{fingerprint}.#{format}",:accept=>:json
+ end
+ rescueRestClient::ResourceNotFound=>e
+ e.response
+ rescueRestClient::InternalServerError=>e
+ e.response
+ rescueRestClient::GatewayTimeout=>e
+ e.response
+ rescueRestClient::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 128defClassyFireAPI.query_status(query_id)begin
@@ -785,49 +932,6 @@ retrieve the strutcure's classification from ClassyFire.
# File 'lib/classyfire_api.rb', line 440defClassyFireAPI.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 227defClassyFireAPI.submit_queries_from_directory(folder,slice_length,type="STRUCTURE")ifFile.directory?(folder)
@@ -1575,49 +1722,6 @@ framgments from the index 'start'.
# File 'lib/classyfire_api.rb', line 150defClassyFireAPI.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).
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”
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.
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”
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.
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