classyfire_api/doc/ClassyFireAPI.html

2016 lines
116 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
Module: ClassyFireAPI
&mdash; Documentation by YARD 0.8.7.6
</title>
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
hasFrames = window.top.frames.main ? true : false;
relpath = '';
framesUrl = "frames.html#!ClassyFireAPI.html";
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
</head>
<body>
<div id="header">
<div id="menu">
<a href="_index.html">Index (C)</a> &raquo;
<span class="title">ClassyFireAPI</span>
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="class_list.html">
Class List
</a>
<a class="full_list_link" id="method_list_link"
href="method_list.html">
Method List
</a>
<a class="full_list_link" id="file_list_link"
href="file_list.html">
File List
</a>
</div>
<div class="clear"></div>
</div>
<iframe id="search_frame"></iframe>
<div id="content"><h1>Module: ClassyFireAPI
</h1>
<dl class="box">
<dt class="r1 last">Defined in:</dt>
<dd class="r1 last">lib/classyfire_api.rb</dd>
</dl>
<div class="clear"></div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>require &#39;node_resource.rb&#39;</p>
</div>
</div>
<div class="tags">
</div>
<h2>Constant Summary</h2>
<dl class="constants">
<dt id="URL-constant" class="">URL =
</dt>
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://classyfire.wishartlab.com</span><span class='tstring_end'>&#39;</span></span></pre></dd>
</dl>
<h2>
Class Method Summary
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#get_chemont_node-class_method" title="get_chemont_node (class method)">+ (Text) <strong>get_chemont_node</strong>(chemontid) </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Return data for the TaxNode with ID chemontid.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#get_entity_classification-class_method" title="get_entity_classification (class method)">+ (Text) <strong>get_entity_classification</strong>(inchikey, format = &quot;json&quot;) </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Retrieves the classification results for a given chemical entity.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#get_query-class_method" title="get_query (class method)">+ (Text) <strong>get_query</strong>(query_id, format = &quot;json&quot;) </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Retrieves the classification results for a given query.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#get_sequence_classification-class_method" title="get_sequence_classification (class method)">+ (Text) <strong>get_sequence_classification</strong>(fingerprint, format = &quot;json&quot;) </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Retrieves the classification results for a given sequence.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#query_status-class_method" title="query_status (class method)">+ (String) <strong>query_status</strong>(query_id) </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Retrieves the status of a query.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#retrieve_classification-class_method" title="retrieve_classification (class method)">+ (String) <strong>retrieve_classification</strong>(input, output) </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Reads a tab separated file, and use the structure representation to
retrieve the strutcure&#39;s classification from ClassyFire.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#retrieve_entities_json-class_method" title="retrieve_entities_json (class method)">+ (String) <strong>retrieve_entities_json</strong>(input, output) </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Reads a tab separated file, and use the structure representation to
retrieve the strutcure&#39;s classification from ClassyFire in a JSON
format.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#retrieve_entities_sdf-class_method" title="retrieve_entities_sdf (class method)">+ (String) <strong>retrieve_entities_sdf</strong>(input, output) </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Reads a tab separated file, and use the structure representation to
retrieve the strutcure&#39;s classification from ClassyFire in a SDF
format.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#submit_queries_from_directory-class_method" title="submit_queries_from_directory (class method)">+ (Object) <strong>submit_queries_from_directory</strong>(folder, slice_length, type = &quot;STRUCTURE&quot;) </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Takes each file in a folder, and submit the contained structures in bluks
of a given size.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#submit_query-class_method" title="submit_query (class method)">+ (Hash) <strong>submit_query</strong>(label, input, type = &#39;STRUCTURE&#39;) </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Submits a ClassyFire query in a JSON format.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#submit_query_input_in_chunks-class_method" title="submit_query_input_in_chunks (class method)">+ (Object) <strong>submit_query_input_in_chunks</strong>(input_file, slice_length = 1000, start = 1, type = &#39;STRUCTURE&#39;) </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Takes a tab-separated file and submit the contained structures in bulks of
a given size.</p>
</div></span>
</li>
</ul>
<div id="class_method_details" class="method_details_list">
<h2>Class Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="get_chemont_node-class_method">
+ (<tt>Text</tt>) <strong>get_chemont_node</strong>(chemontid)
</h3><div class="docstring">
<div class="discussion">
<p>Return data for the TaxNode with ID chemontid.</p>
<p>Use JSON.parse to get a the json object.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>chemontid</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>the ChemOnt ID of the entity.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Text</tt>)</span>
&mdash;
<div class='inline'>
<p>A text displaying the classification results for the entity in the
specified format.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
63
64
65
66
67
68
69
70
71
72
73
74
75
76</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 63</span>
<span class='kw'>def</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_get_chemont_node'>get_chemont_node</span><span class='lparen'>(</span><span class='id identifier rubyid_chemontid'>chemontid</span><span class='rparen'>)</span>
<span class='id identifier rubyid_chemont_id'>chemont_id</span> <span class='op'>=</span> <span class='id identifier rubyid_chemontid'>chemontid</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>CHEMONTID:</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>C</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='const'>RestClient</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='const'>URL</span><span class='embexpr_end'>}</span><span class='tstring_content'>/tax_nodes/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_chemont_id'>chemont_id</span><span class='embexpr_end'>}</span><span class='tstring_content'>.json</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=&gt;</span> <span class='symbol'>:json</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>ResourceNotFound</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>InternalServerError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>GatewayTimeout</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>RequestTimeout</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="get_entity_classification-class_method">
+ (<tt>Text</tt>) <strong>get_entity_classification</strong>(inchikey, format = &quot;json&quot;)
</h3><div class="docstring">
<div class="discussion">
<p>Retrieves the classification results for a given chemical entity.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>the</span>
<span class='type'></span>
&mdash;
<div class='inline'>
<p>InChIKey [String] of the entity</p>
</div>
</li>
<li>
<span class='name'>The</span>
<span class='type'></span>
&mdash;
<div class='inline'>
<p>format [String] the format of the query (Only JSON)</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Text</tt>)</span>
&mdash;
<div class='inline'>
<p>A text file displaying the classification results for the entity in the
specified format.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 105</span>
<span class='kw'>def</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_get_entity_classification'>get_entity_classification</span><span class='lparen'>(</span><span class='id identifier rubyid_inchikey'>inchikey</span><span class='comma'>,</span><span class='id identifier rubyid_format'>format</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>json</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_inchikey_id'>inchikey_id</span> <span class='op'>=</span> <span class='id identifier rubyid_inchikey'>inchikey</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>InChIKey=</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='kw'>if</span> <span class='id identifier rubyid_format'>format</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>json</span><span class='tstring_end'>&quot;</span></span>
<span class='const'>RestClient</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='const'>URL</span><span class='embexpr_end'>}</span><span class='tstring_content'>/entities/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_inchikey_id'>inchikey_id</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_format'>format</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=&gt;</span> <span class='symbol'>:json</span>
<span class='kw'>elsif</span> <span class='id identifier rubyid_format'>format</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>sdf</span><span class='tstring_end'>&quot;</span></span>
<span class='const'>RestClient</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='const'>URL</span><span class='embexpr_end'>}</span><span class='tstring_content'>/entities/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_inchikey_id'>inchikey_id</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_format'>format</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=&gt;</span> <span class='symbol'>:sdf</span>
<span class='kw'>elsif</span> <span class='id identifier rubyid_format'>format</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>csv</span><span class='tstring_end'>&quot;</span></span>
<span class='const'>RestClient</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='const'>URL</span><span class='embexpr_end'>}</span><span class='tstring_content'>/entities/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_inchikey_id'>inchikey_id</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_format'>format</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=&gt;</span> <span class='symbol'>:csv</span>
<span class='kw'>end</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>ResourceNotFound</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>InternalServerError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>GatewayTimeout</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>RequestTimeout</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="get_query-class_method">
+ (<tt>Text</tt>) <strong>get_query</strong>(query_id, format = &quot;json&quot;)
</h3><div class="docstring">
<div class="discussion">
<p>Retrieves the classification results for a given query.</p>
<p>the query&#39;s entities in the specified format.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>query_id</span>
<span class='type'>(<tt>Integer</tt>)</span>
&mdash;
<div class='inline'>
<p>the ID of the query.</p>
</div>
</li>
<li>
<span class='name'>format</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>&quot;json&quot;</tt>)</em>
&mdash;
<div class='inline'>
<p>the format of the query (either JSON, CSV, or SDF)</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Text</tt>)</span>
&mdash;
<div class='inline'>
<p>A text file displaying the classification results for</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 38</span>
<span class='kw'>def</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_get_query'>get_query</span><span class='lparen'>(</span><span class='id identifier rubyid_query_id'>query_id</span><span class='comma'>,</span><span class='id identifier rubyid_format'>format</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>json</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='kw'>if</span> <span class='id identifier rubyid_format'>format</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>json</span><span class='tstring_end'>&quot;</span></span>
<span class='const'>RestClient</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='const'>URL</span><span class='embexpr_end'>}</span><span class='tstring_content'>/queries/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_query_id'>query_id</span><span class='embexpr_end'>}</span><span class='tstring_content'>.json</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=&gt;</span> <span class='symbol'>:json</span>
<span class='kw'>elsif</span> <span class='id identifier rubyid_format'>format</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>sdf</span><span class='tstring_end'>&quot;</span></span>
<span class='const'>RestClient</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='const'>URL</span><span class='embexpr_end'>}</span><span class='tstring_content'>/queries/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_query_id'>query_id</span><span class='embexpr_end'>}</span><span class='tstring_content'>.sdf</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=&gt;</span> <span class='symbol'>:sdf</span>
<span class='kw'>elsif</span> <span class='id identifier rubyid_format'>format</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>csv</span><span class='tstring_end'>&quot;</span></span>
<span class='const'>RestClient</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='const'>URL</span><span class='embexpr_end'>}</span><span class='tstring_content'>/queries/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_query_id'>query_id</span><span class='embexpr_end'>}</span><span class='tstring_content'>.csv</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=&gt;</span> <span class='symbol'>:csv</span>
<span class='kw'>end</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>ResourceNotFound</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>InternalServerError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>GatewayTimeout</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>RequestTimeout</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="get_sequence_classification-class_method">
+ (<tt>Text</tt>) <strong>get_sequence_classification</strong>(fingerprint, format = &quot;json&quot;)
</h3><div class="docstring">
<div class="discussion">
<p>Retrieves the classification results for a given sequence.</p>
<p>Use JSON.parse to get a the json object.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>fingerprint</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>the fingerprint (generated from the sequence using Digest::MD5).</p>
</div>
</li>
<li>
<span class='name'>format</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>&quot;json&quot;</tt>)</em>
&mdash;
<div class='inline'>
<p>the format of the query (Only JSON)</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Text</tt>)</span>
&mdash;
<div class='inline'>
<p>A text displaying the classification results for the entity in the
specified format.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 84</span>
<span class='kw'>def</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_get_sequence_classification'>get_sequence_classification</span><span class='lparen'>(</span><span class='id identifier rubyid_fingerprint'>fingerprint</span><span class='comma'>,</span><span class='id identifier rubyid_format'>format</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>json</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='kw'>if</span> <span class='id identifier rubyid_format'>format</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>json</span><span class='tstring_end'>&quot;</span></span>
<span class='const'>RestClient</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='const'>URL</span><span class='embexpr_end'>}</span><span class='tstring_content'>/entities/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_fingerprint'>fingerprint</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_format'>format</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=&gt;</span> <span class='symbol'>:json</span>
<span class='kw'>end</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>ResourceNotFound</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>InternalServerError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>GatewayTimeout</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>RequestTimeout</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="query_status-class_method">
+ (<tt>String</tt>) <strong>query_status</strong>(query_id)
</h3><div class="docstring">
<div class="discussion">
<p>Retrieves the status of a query</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>query_id</span>
<span class='type'>(<tt>Integer</tt>)</span>
&mdash;
<div class='inline'>
<p>the ID of the query</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>the query status, &#39;Done&#39; or &#39;In progress&#39;, &#39;string&#39;</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
130
131
132
133
134
135
136
137</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 130</span>
<span class='kw'>def</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_query_status'>query_status</span><span class='lparen'>(</span><span class='id identifier rubyid_query_id'>query_id</span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='const'>RestClient</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='const'>URL</span><span class='embexpr_end'>}</span><span class='tstring_content'>/queries/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_query_id'>query_id</span><span class='embexpr_end'>}</span><span class='tstring_content'>/status.json</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=&gt;</span> <span class='symbol'>:json</span>
<span class='kw'>rescue</span> <span class='const'>Exception</span><span class='op'>=&gt;</span><span class='id identifier rubyid_e'>e</span>
<span class='gvar'>$stderr</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span>
<span class='kw'>nil</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="retrieve_classification-class_method">
+ (<tt>String</tt>) <strong>retrieve_classification</strong>(input, output)
</h3><div class="docstring">
<div class="discussion">
<p>Reads a tab separated file, and use the structure representation to
retrieve the strutcure&#39;s classification from ClassyFire.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>input</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>path to the input file.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>path to the output file.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
256
257
258
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 256</span>
<span class='kw'>def</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_retrieve_classification'>retrieve_classification</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span><span class='id identifier rubyid_output'>output</span><span class='rparen'>)</span>
<span class='id identifier rubyid_absolute_path'>absolute_path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='rparen'>)</span>
<span class='id identifier rubyid_f_input'>f_input</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>r</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_h'>h</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
<span class='id identifier rubyid_directory'>directory</span> <span class='op'>=</span> <span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>...</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_f_output'>f_output</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_output'>output</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>w</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='const'>String</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>{</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&quot;id&quot;: 1,</span><span class='tstring_end'>&#39;</span></span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&quot;label&quot;:&quot;</span><span class='tstring_end'>&#39;</span></span> <span class='op'>+</span> <span class='id identifier rubyid_output'>output</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&quot;,</span><span class='tstring_end'>&#39;</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&quot;classification_status&quot;:&quot;Done&quot;,</span><span class='tstring_end'>&#39;</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&quot;entities&quot;:[</span><span class='tstring_end'>&#39;</span></span>
<span class='id identifier rubyid_f_input'>f_input</span><span class='period'>.</span><span class='id identifier rubyid_each_line'>each_line</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_line'>line</span><span class='op'>|</span>
<span class='id identifier rubyid_sline'>sline</span> <span class='op'>=</span> <span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\t</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_sline'>sline</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>1</span>
<span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_sline'>sline</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_sline'>sline</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
<span class='kw'>elsif</span> <span class='id identifier rubyid_sline'>sline</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span>
<span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_sline'>sline</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
<span class='kw'>if</span> <span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>&gt;</span> <span class='int'>0</span>
<span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='int'>1</span>
<span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>..</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_i'>i</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'> :: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_qs'>qs</span> <span class='op'>=</span> <span class='id identifier rubyid_submit_query'>submit_query</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span><span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='id identifier rubyid_qs_decoded'>qs_decoded</span> <span class='op'>=</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_qs'>qs</span><span class='rparen'>)</span>
<span class='id identifier rubyid_qr'>qr</span> <span class='op'>=</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_get_query'>get_query</span><span class='lparen'>(</span><span class='id identifier rubyid_qs_decoded'>qs_decoded</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>id</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span><span class='id identifier rubyid_format'>format</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>json</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='id identifier rubyid_qr'>qr</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>entities</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>,</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_i'>i</span> <span class='op'>+=</span> <span class='int'>1</span>
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='lbracket'>[</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'> :: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_qs'>qs</span> <span class='op'>=</span> <span class='id identifier rubyid_submit_query'>submit_query</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span><span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='id identifier rubyid_sleep'>sleep</span><span class='lparen'>(</span><span class='float'>0.2</span><span class='rparen'>)</span>
<span class='id identifier rubyid_qs_decoded'>qs_decoded</span> <span class='op'>=</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_qs'>qs</span><span class='rparen'>)</span>
<span class='id identifier rubyid_qr'>qr</span> <span class='op'>=</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_get_query'>get_query</span><span class='lparen'>(</span><span class='id identifier rubyid_qs_decoded'>qs_decoded</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>id</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span><span class='id identifier rubyid_format'>format</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>json</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='comment'># puts qr[&quot;entities&quot;]
</span> <span class='comment'># sleep(0.2)
</span> <span class='comment'># f_output.print qr[&quot;entities&quot;][0],&quot;\n&quot;
</span> <span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='id identifier rubyid_qr'>qr</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>entities</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span>
<span class='comment'># res += &quot;,&quot;
</span> <span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>]}</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_f_output'>f_output</span><span class='period'>.</span><span class='id identifier rubyid_print'>print</span> <span class='id identifier rubyid_res'>res</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="retrieve_entities_json-class_method">
+ (<tt>String</tt>) <strong>retrieve_entities_json</strong>(input, output)
</h3><div class="docstring">
<div class="discussion">
<p>Reads a tab separated file, and use the structure representation to
retrieve the strutcure&#39;s classification from ClassyFire in a JSON
format.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>input</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>path to the input file</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>path to the output file</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
324
325
326
327
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
372
373
374
375
376
377</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 324</span>
<span class='kw'>def</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_retrieve_entities_json'>retrieve_entities_json</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span><span class='id identifier rubyid_output'>output</span><span class='rparen'>)</span>
<span class='id identifier rubyid_absolute_path'>absolute_path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='rparen'>)</span>
<span class='id identifier rubyid_f_input'>f_input</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>r</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_h'>h</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
<span class='id identifier rubyid_directory'>directory</span> <span class='op'>=</span> <span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>...</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_f_output'>f_output</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_output'>output</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>w</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_puts'>puts</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='const'>String</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>{</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&quot;id&quot;: 1,</span><span class='tstring_end'>&#39;</span></span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&quot;label&quot;:&quot;</span><span class='tstring_end'>&#39;</span></span> <span class='op'>+</span> <span class='id identifier rubyid_output'>output</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&quot;,</span><span class='tstring_end'>&#39;</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&quot;classification_status&quot;:&quot;Done&quot;,</span><span class='tstring_end'>&#39;</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&quot;entities&quot;:[</span><span class='tstring_end'>&#39;</span></span>
<span class='id identifier rubyid_f_input'>f_input</span><span class='period'>.</span><span class='id identifier rubyid_each_line'>each_line</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_line'>line</span><span class='op'>|</span>
<span class='id identifier rubyid_sline'>sline</span> <span class='op'>=</span> <span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\t</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_sline'>sline</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_sline'>sline</span><span class='lbracket'>[</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
<span class='kw'>if</span> <span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>&gt;</span> <span class='int'>0</span>
<span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='int'>1</span>
<span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>...</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_i'>i</span>
<span class='comment'># puts &quot;#{key} :: #{h[key]}&quot;
</span> <span class='kw'>begin</span>
<span class='id identifier rubyid_inchikey'>inchikey</span> <span class='op'>=</span> <span class='backtick'>%x(</span><span class='tstring_content'>obabel -:&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>&quot; -oinchikey</span><span class='tstring_end'>)</span></span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\t</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
<span class='comment'># puts inchikey
</span> <span class='id identifier rubyid_qr'>qr</span> <span class='op'>=</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_get_entity_classification'>get_entity_classification</span><span class='lparen'>(</span><span class='id identifier rubyid_inchikey'>inchikey</span><span class='comma'>,</span><span class='id identifier rubyid_format'>format</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>json</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_qr'>qr</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>identifier</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='id identifier rubyid_qr'>qr</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>,</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'> :: RETURN NIL</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_qr'>qr</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_qr'>qr</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>direct_parent</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>name</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_i'>i</span> <span class='op'>+=</span> <span class='int'>1</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='lbracket'>[</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span>
<span class='comment'># puts &quot;#{key} :: #{h[key]}&quot;
</span> <span class='kw'>begin</span>
<span class='id identifier rubyid_inchikey'>inchikey</span> <span class='op'>=</span> <span class='backtick'>%x(</span><span class='tstring_content'>obabel -:&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>&quot; -oinchikey</span><span class='tstring_end'>)</span></span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\t</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
<span class='comment'># puts inchikey
</span> <span class='id identifier rubyid_qr'>qr</span> <span class='op'>=</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_get_entity_classification'>get_entity_classification</span><span class='lparen'>(</span><span class='id identifier rubyid_inchikey'>inchikey</span><span class='comma'>,</span><span class='id identifier rubyid_format'>format</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>json</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_qr'>qr</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>identifier</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='id identifier rubyid_qr'>qr</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'> :: RETURN NIL</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_qr'>qr</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_qr'>qr</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>direct_parent</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>name</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='comment'># res += &quot;,&quot;
</span> <span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>]}</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_f_output'>f_output</span><span class='period'>.</span><span class='id identifier rubyid_print'>print</span> <span class='id identifier rubyid_res'>res</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="retrieve_entities_sdf-class_method">
+ (<tt>String</tt>) <strong>retrieve_entities_sdf</strong>(input, output)
</h3><div class="docstring">
<div class="discussion">
<p>Reads a tab separated file, and use the structure representation to
retrieve the strutcure&#39;s classification from ClassyFire in a SDF
format.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>input</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>path to the input file</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>path to the output file</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
386
387
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
432
433
434
435
436
437
438
439
440
441
442
443</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 386</span>
<span class='kw'>def</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_retrieve_entities_sdf'>retrieve_entities_sdf</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span><span class='id identifier rubyid_output'>output</span><span class='rparen'>)</span>
<span class='id identifier rubyid_absolute_path'>absolute_path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='rparen'>)</span>
<span class='id identifier rubyid_f_input'>f_input</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>r</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_h'>h</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
<span class='id identifier rubyid_directory'>directory</span> <span class='op'>=</span> <span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>...</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_f_output'>f_output</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_output'>output</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>w</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='const'>String</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
<span class='id identifier rubyid_f_input'>f_input</span><span class='period'>.</span><span class='id identifier rubyid_each_line'>each_line</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_line'>line</span><span class='op'>|</span>
<span class='id identifier rubyid_sline'>sline</span> <span class='op'>=</span> <span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\t</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_sline'>sline</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_sline'>sline</span><span class='lbracket'>[</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
<span class='kw'>if</span> <span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>&gt;</span> <span class='int'>0</span>
<span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='int'>1</span>
<span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>...</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_i'>i</span>
<span class='comment'># puts &quot;#{key} :: #{h[key]}&quot;
</span> <span class='kw'>begin</span>
<span class='id identifier rubyid_inchikey'>inchikey</span> <span class='op'>=</span> <span class='backtick'>%x(</span><span class='tstring_content'>obabel -:&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>&quot; -oinchikey</span><span class='tstring_end'>)</span></span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\t</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
<span class='comment'># puts inchikey
</span> <span class='id identifier rubyid_qr'>qr</span> <span class='op'>=</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_get_entity_classification'>get_entity_classification</span><span class='lparen'>(</span><span class='id identifier rubyid_inchikey'>inchikey</span><span class='comma'>,</span><span class='id identifier rubyid_format'>format</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>sdf</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_qr'>qr</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>The page you were looking for doesn&#39;t exist</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>The page you were looking for doesn&#39;t exist</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>elsif</span> <span class='id identifier rubyid_qr'>qr</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_input'>input</span> <span class='op'>=</span> <span class='id identifier rubyid_qr'>qr</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='op'>..</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_input'>input</span>
<span class='id identifier rubyid_f_output'>f_output</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_f_output'>f_output</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_input'>input</span>
<span class='kw'>end</span>
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_i'>i</span> <span class='op'>+=</span> <span class='int'>1</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='lbracket'>[</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_inchikey'>inchikey</span> <span class='op'>=</span> <span class='backtick'>%x(</span><span class='tstring_content'>obabel -:&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>&quot; -oinchikey</span><span class='tstring_end'>)</span></span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\t</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
<span class='comment'># puts inchikey
</span> <span class='id identifier rubyid_qr'>qr</span> <span class='op'>=</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_get_entity_classification'>get_entity_classification</span><span class='lparen'>(</span><span class='id identifier rubyid_inchikey'>inchikey</span><span class='comma'>,</span><span class='id identifier rubyid_format'>format</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>sdf</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_qr'>qr</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>The page you were looking for doesn&#39;t exist</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>The page you were looking for doesn&#39;t exist</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>elsif</span> <span class='id identifier rubyid_qr'>qr</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_input'>input</span> <span class='op'>=</span> <span class='id identifier rubyid_qr'>qr</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='op'>..</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_input'>input</span>
<span class='id identifier rubyid_f_output'>f_output</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_f_output'>f_output</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_input'>input</span>
<span class='kw'>end</span>
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="submit_queries_from_directory-class_method">
+ (<tt>Object</tt>) <strong>submit_queries_from_directory</strong>(folder, slice_length, type = &quot;STRUCTURE&quot;)
</h3><div class="docstring">
<div class="discussion">
<p>Takes each file in a folder, and submit the contained structures in bluks
of a given size.</p>
<p>For &#39;STRUCTURE&#39; or &#39;IUPAC_NAME&#39;query types, each line must
contain either</p>
<pre class="code ruby"><code class="ruby">1) Only a structural represenation: SMILES, InChI for the &#39;STRUCTURE&#39; query_type or a IUPAC name
for the &#39;IUPAC NAME&#39; query type.
2) a tab-separated pair of an ID and the corresponding sructure representation: SMILES, InChI for the
&#39;STRUCTURE&#39; query_type or a IUPAC name for the &#39;IUPAC NAME&#39; query type.</code></pre>
<p>For &#39;FASTA&#39; query type, just submit the query as a standard FASTA
text. @param: input_file [String] The path to the folder. @param:
slice_length [Integer] The maximum number of entries for each query input
(each file is fragmented into n part of #slice_length entries each),
&#39;integer&#39;</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>type</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>&quot;STRUCTURE&quot;</tt>)</em>
&mdash;
<div class='inline'>
<p>the query_type &#39;STRUCTURE&#39; (default) or &#39;IUPAC_NAME&#39; or
&#39;FASTA&#39;</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
239
240
241
242
243
244
245
246
247
248</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 239</span>
<span class='kw'>def</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_submit_queries_from_directory'>submit_queries_from_directory</span><span class='lparen'>(</span><span class='id identifier rubyid_folder'>folder</span><span class='comma'>,</span><span class='id identifier rubyid_slice_length'>slice_length</span><span class='comma'>,</span><span class='id identifier rubyid_type'>type</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>STRUCTURE</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_directory?'>directory?</span><span class='lparen'>(</span><span class='id identifier rubyid_folder'>folder</span><span class='rparen'>)</span>
<span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_foreach'>foreach</span><span class='lparen'>(</span><span class='id identifier rubyid_folder'>folder</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_filename'>filename</span><span class='op'>|</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Filename: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_filename'>filename</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_submit_query_input_in_chunks'>submit_query_input_in_chunks</span><span class='lparen'>(</span><span class='id identifier rubyid_folder'>folder</span><span class='op'>+</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='op'>+</span><span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span><span class='id identifier rubyid_slice_length'>slice_length</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_filename'>filename</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>.</span><span class='tstring_end'>&quot;</span></span> <span class='op'>||</span> <span class='id identifier rubyid_filename'>filename</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>..</span><span class='tstring_end'>&quot;</span></span> <span class='op'>||</span> <span class='id identifier rubyid_filename'>filename</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>.DS_Store</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span>
<span class='kw'>else</span>
<span class='gvar'>$stderr</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_folder'>folder</span><span class='embexpr_end'>}</span><span class='tstring_content'> is not a folder.</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="submit_query-class_method">
+ (<tt>Hash</tt>) <strong>submit_query</strong>(label, input, type = &#39;STRUCTURE&#39;)
</h3><div class="docstring">
<div class="discussion">
<p>Submits a ClassyFire query in a JSON format.</p>
<p>if there is an error. Use JSON.parse to get a the json object.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>label</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>the label of the query.</p>
</div>
</li>
<li>
<span class='name'>input</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>the input of the query.</p>
</div>
</li>
<li>
<span class='name'>type</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>&#39;STRUCTURE&#39;</tt>)</em>
&mdash;
<div class='inline'>
<p>the type of the query.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Hash</tt>)</span>
&mdash;
<div class='inline'>
<p>A Ruby Hash with the id (and other attributes) of the Query or nil</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 15</span>
<span class='kw'>def</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_submit_query'>submit_query</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>STRUCTURE</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_q'>q</span> <span class='op'>=</span> <span class='const'>RestClient</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span> <span class='const'>URL</span><span class='op'>+</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/queries</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:label</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='symbol'>:query_input</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='symbol'>:query_type</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_type'>type</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=&gt;</span> <span class='symbol'>:json</span><span class='comma'>,</span> <span class='symbol'>:content_type</span> <span class='op'>=&gt;</span> <span class='symbol'>:json</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>BadRequest</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>InternalServerError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>GatewayTimeout</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>RequestTimeout</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>rescue</span> <span class='const'>RestClient</span><span class='op'>::</span><span class='const'>UnprocessableEntity</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_q'>q</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="submit_query_input_in_chunks-class_method">
+ (<tt>Object</tt>) <strong>submit_query_input_in_chunks</strong>(input_file, slice_length = 1000, start = 1, type = &#39;STRUCTURE&#39;)
</h3><div class="docstring">
<div class="discussion">
<p>Takes a tab-separated file and submit the contained structures in bulks of
a given size</p>
<p>For &#39;STRUCTURE&#39; or &#39;IUPAC_NAME&#39;query types, each line must
contain either</p>
<pre class="code ruby"><code class="ruby">1) Only a structural represenation: SMILES, InChI for the &#39;STRUCTURE&#39; query_type or a IUPAC name
for the &#39;IUPAC NAME&#39; query type.
2) a tab-separated pair of an ID and the corresponding sructure representation: SMILES, InChI for the
&#39;STRUCTURE&#39; query_type or a IUPAC name for the &#39;IUPAC NAME&#39; query type.</code></pre>
<p>For &#39;FASTA&#39; query type, just submit the query as a standard FASTA
text. @param: slice_length [Integer] The maximum number of entries for each
query input (the whole file is fragmented into n part of #slice_length
entries each). @param: start [Integer] The starting index. Submit
framgments from the index &#39;start&#39;.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>input_file</span>
<span class='type'>(<tt>Text</tt>)</span>
&mdash;
<div class='inline'>
<p>The path to the input file.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
152
153
154
155
156
157
158
159
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</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 152</span>
<span class='kw'>def</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_submit_query_input_in_chunks'>submit_query_input_in_chunks</span><span class='lparen'>(</span><span class='id identifier rubyid_input_file'>input_file</span><span class='comma'>,</span><span class='id identifier rubyid_slice_length'>slice_length</span><span class='op'>=</span><span class='int'>1000</span><span class='comma'>,</span> <span class='id identifier rubyid_start'>start</span><span class='op'>=</span><span class='int'>1</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>STRUCTURE</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='ivar'>@start_time</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span>
<span class='id identifier rubyid_absolute_path'>absolute_path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='id identifier rubyid_input_file'>input_file</span><span class='rparen'>)</span>
<span class='id identifier rubyid_f'>f</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>r</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_input'>input</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
<span class='id identifier rubyid_lines'>lines</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_readlines'>readlines</span><span class='lparen'>(</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='rparen'>)</span>
<span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='int'>0</span>
<span class='id identifier rubyid_lines'>lines</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_line'>line</span><span class='op'>|</span>
<span class='id identifier rubyid_i'>i</span> <span class='op'>+=</span> <span class='int'>1</span>
<span class='id identifier rubyid_sline'>sline</span> <span class='op'>=</span> <span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\t</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_sline'>sline</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>1</span>
<span class='id identifier rubyid_input'>input</span> <span class='op'>&lt;&lt;</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sline'>sline</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>elsif</span> <span class='id identifier rubyid_sline'>sline</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span>
<span class='comment'>#ID\tSMILES (OR INCHI, OR VALID IUPAC NAME)
</span> <span class='id identifier rubyid_input'>input</span> <span class='op'>&lt;&lt;</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sline'>sline</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>\t</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sline'>sline</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span>
<span class='id identifier rubyid_input'>input</span> <span class='op'>&lt;&lt;</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sline'>sline</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span>
<span class='id identifier rubyid_query_ids'>query_ids</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
<span class='id identifier rubyid_subdivised_groups'>subdivised_groups</span> <span class='op'>=</span> <span class='id identifier rubyid_input'>input</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_each_slice'>each_slice</span><span class='lparen'>(</span><span class='id identifier rubyid_slice_length'>slice_length</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>nr of subdivised_groups: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_subdivised_groups'>subdivised_groups</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='comment'># puts subdivised_groups[0]
</span> <span class='id identifier rubyid_sleeping_time'>sleeping_time</span> <span class='op'>=</span> <span class='int'>240</span>
<span class='id identifier rubyid_initial_nr_of_jobs'>initial_nr_of_jobs</span> <span class='op'>=</span> <span class='int'>30</span>
<span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='id identifier rubyid_start'>start</span>
<span class='kw'>while</span> <span class='id identifier rubyid_i'>i</span> <span class='op'>&lt;</span> <span class='id identifier rubyid_initial_nr_of_jobs'>initial_nr_of_jobs</span>
<span class='id identifier rubyid_title'>title</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_basename'>basename</span><span class='lparen'>(</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>_yannick</span><span class='tstring_end'>&quot;</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>_part_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_i'>i</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>if</span> <span class='id identifier rubyid_i'>i</span> <span class='op'>&lt;=</span> <span class='id identifier rubyid_subdivised_groups'>subdivised_groups</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n\n\n\n---------------------- -----------</span><span class='tstring_end'>&quot;</span></span>
<span class='comment'># begin
</span> <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>submitting </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_title'>title</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_subdivised_groups'>subdivised_groups</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_q'>q</span> <span class='op'>=</span> <span class='id identifier rubyid_submit_query'>submit_query</span><span class='lparen'>(</span><span class='id identifier rubyid_title'>title</span><span class='comma'>,</span><span class='id identifier rubyid_subdivised_groups'>subdivised_groups</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='comma'>,</span><span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span>
<span class='comment'># puts q
</span> <span class='id identifier rubyid_query_ids'>query_ids</span> <span class='op'>&lt;&lt;</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_q'>q</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>id</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
<span class='comment'># rescue Exception =&gt; e
</span> <span class='comment'># puts e.message
</span> <span class='comment'># puts e.backtrace.inspect
</span> <span class='comment'># end
</span> <span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='id identifier rubyid_i'>i</span> <span class='op'>+</span> <span class='int'>1</span>
<span class='kw'>else</span>
<span class='kw'>break</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Going to sleep at </span><span class='embexpr_beg'>#{</span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='ivar'>@start_time</span><span class='embexpr_end'>}</span><span class='tstring_content'> for </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sleeping_time'>sleeping_time</span><span class='embexpr_end'>}</span><span class='tstring_content'> s.</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_sleep'>sleep</span><span class='lparen'>(</span><span class='id identifier rubyid_sleeping_time'>sleeping_time</span><span class='rparen'>)</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Waking up at </span><span class='embexpr_beg'>#{</span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='ivar'>@start_time</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>while</span> <span class='id identifier rubyid_i'>i</span> <span class='op'>&gt;=</span> <span class='id identifier rubyid_initial_nr_of_jobs'>initial_nr_of_jobs</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_i'>i</span> <span class='op'>&lt;</span> <span class='id identifier rubyid_subdivised_groups'>subdivised_groups</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
<span class='id identifier rubyid_k'>k</span> <span class='op'>=</span> <span class='int'>0</span>
<span class='kw'>for</span> <span class='id identifier rubyid_k'>k</span> <span class='kw'>in</span> <span class='lparen'>(</span><span class='id identifier rubyid_i'>i</span><span class='op'>..</span><span class='lparen'>(</span><span class='id identifier rubyid_i'>i</span> <span class='op'>+</span> <span class='id identifier rubyid_initial_nr_of_jobs'>initial_nr_of_jobs</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_title'>title</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_basename'>basename</span><span class='lparen'>(</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>_yannick</span><span class='tstring_end'>&quot;</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>_part_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_k'>k</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='id identifier rubyid_i'>i</span> <span class='op'>+</span> <span class='int'>1</span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>submitting </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_title'>title</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_q'>q</span> <span class='op'>=</span> <span class='id identifier rubyid_submit_query'>submit_query</span><span class='lparen'>(</span><span class='id identifier rubyid_title'>title</span><span class='comma'>,</span><span class='id identifier rubyid_subdivised_groups'>subdivised_groups</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='comma'>,</span><span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span>
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_backtrace'>backtrace</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='id identifier rubyid_k'>k</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Going to sleep at </span><span class='embexpr_beg'>#{</span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='ivar'>@start_time</span><span class='embexpr_end'>}</span><span class='tstring_content'> for </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sleeping_time'>sleeping_time</span><span class='embexpr_end'>}</span><span class='tstring_content'> s.</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_sleep'>sleep</span><span class='lparen'>(</span><span class='id identifier rubyid_sleeping_time'>sleeping_time</span><span class='rparen'>)</span>
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Waking up at </span><span class='embexpr_beg'>#{</span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='ivar'>@start_time</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Tue Jun 28 15:46:59 2016 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.8.7.6 (ruby-2.4.0).
</div>
</body>
</html>