1928 lines
118 KiB
HTML
1928 lines
118 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
|
||
|
|
||
|
— 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> »
|
||
|
|
||
|
|
||
|
<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>Constant Summary</h2>
|
||
|
|
||
|
<dl class="constants">
|
||
|
|
||
|
<dt id="URL-constant" class="">URL =
|
||
|
|
||
|
</dt>
|
||
|
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>http://classyfire.wishartlab.com</span><span class='tstring_end'>'</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_entity_classification-class_method" title="get_entity_classification (class method)">+ (Text) <strong>get_entity_classification</strong>(inchikey, format = "json") </a>
|
||
|
|
||
|
|
||
|
|
||
|
</span>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<span class="summary_desc"><div class='inline'>
|
||
|
<p>Retrieves the classification results for a given 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 = "json") </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="#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'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'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'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 = "STRUCTURE") </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 = 'STRUCTURE') </a>
|
||
|
|
||
|
|
||
|
|
||
|
</span>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<span class="summary_desc"><div class='inline'>
|
||
|
<p>Submits a ClassyFire query, which should be returned in a specific 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, start, type = 'STRUCTURE') </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>
|
||
|
|
||
|
|
||
|
<li class="public ">
|
||
|
<span class="summary_signature">
|
||
|
|
||
|
<a href="#submit_random_subset_of_query_input_in_chunks-class_method" title="submit_random_subset_of_query_input_in_chunks (class method)">+ (Object) <strong>submit_random_subset_of_query_input_in_chunks</strong>(tab_separated_input_file, size, type = 'STRUCTURE') </a>
|
||
|
|
||
|
|
||
|
|
||
|
</span>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<span class="summary_desc"><div class='inline'>
|
||
|
<p>Takes a tab-separated file and submit randomly selected 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_entity_classification-class_method">
|
||
|
|
||
|
+ (<tt>Text</tt>) <strong>get_entity_classification</strong>(inchikey, format = "json")
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><div class="docstring">
|
||
|
<div class="discussion">
|
||
|
|
||
|
<p>Retrieves the classification results for a given entity.</p>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="tags">
|
||
|
<p class="tag_title">Parameters:</p>
|
||
|
<ul class="param">
|
||
|
|
||
|
<li>
|
||
|
|
||
|
<span class='name'>inchikey</span>
|
||
|
|
||
|
|
||
|
<span class='type'>(<tt>String</tt>)</span>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<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>"json"</tt>)</em>
|
||
|
|
||
|
|
||
|
—
|
||
|
<div class='inline'>
|
||
|
<p>the format of the query, 'text' (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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<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">
|
||
|
|
||
|
|
||
|
61
|
||
|
62
|
||
|
63
|
||
|
64
|
||
|
65
|
||
|
66
|
||
|
67
|
||
|
68
|
||
|
69
|
||
|
70
|
||
|
71
|
||
|
72
|
||
|
73
|
||
|
74
|
||
|
75
|
||
|
76
|
||
|
77
|
||
|
78
|
||
|
79
|
||
|
80</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 61</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'>"</span><span class='tstring_content'>json</span><span class='tstring_end'>"</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'>'</span><span class='tstring_content'>InChIKey=</span><span class='tstring_end'>'</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</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'>"</span><span class='tstring_content'>json</span><span class='tstring_end'>"</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'>"</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'>"</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=></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'>"</span><span class='tstring_content'>sdf</span><span class='tstring_end'>"</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'>"</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'>"</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=></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'>"</span><span class='tstring_content'>csv</span><span class='tstring_end'>"</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'>"</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'>"</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=></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'>=></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'>=></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'>=></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'>=></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 = "json")
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><div class="docstring">
|
||
|
<div class="discussion">
|
||
|
|
||
|
<p>Retrieves the classification results for a given query.</p>
|
||
|
|
||
|
<p>the query'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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<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>"json"</tt>)</em>
|
||
|
|
||
|
|
||
|
—
|
||
|
<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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<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">
|
||
|
|
||
|
|
||
|
36
|
||
|
37
|
||
|
38
|
||
|
39
|
||
|
40
|
||
|
41
|
||
|
42
|
||
|
43
|
||
|
44
|
||
|
45
|
||
|
46
|
||
|
47
|
||
|
48
|
||
|
49
|
||
|
50
|
||
|
51
|
||
|
52
|
||
|
53
|
||
|
54</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 36</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'>"</span><span class='tstring_content'>json</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>json</span><span class='tstring_end'>"</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'>"</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'>"</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=></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'>"</span><span class='tstring_content'>sdf</span><span class='tstring_end'>"</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'>"</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'>"</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=></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'>"</span><span class='tstring_content'>csv</span><span class='tstring_end'>"</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'>"</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'>"</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=></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'>=></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'>=></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'>=></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'>=></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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<div class='inline'>
|
||
|
<p>the query status, 'Done' or 'In progress', 'string'</p>
|
||
|
</div>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
</div><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
85
|
||
|
86
|
||
|
87
|
||
|
88
|
||
|
89
|
||
|
90
|
||
|
91
|
||
|
92</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 85</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'>"</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'>"</span></span><span class='comma'>,</span> <span class='symbol'>:accept</span> <span class='op'>=></span> <span class='symbol'>:json</span>
|
||
|
<span class='kw'>rescue</span> <span class='const'>Exception</span><span class='op'>=></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'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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<div class='inline'>
|
||
|
<p>path to the output file.</p>
|
||
|
</div>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
</div><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
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
|
||
|
318
|
||
|
319
|
||
|
320
|
||
|
321
|
||
|
322
|
||
|
323
|
||
|
324
|
||
|
325
|
||
|
326
|
||
|
327
|
||
|
328</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 266</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'>'</span><span class='tstring_content'>r</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</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'>"</span><span class='tstring_content'>/</span><span class='tstring_end'>"</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'>'</span><span class='tstring_content'>w</span><span class='tstring_end'>'</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'>"</span><span class='tstring_content'>{</span><span class='tstring_end'>"</span></span>
|
||
|
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>"id": 1,</span><span class='tstring_end'>'</span></span>
|
||
|
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>"label":"</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>",</span><span class='tstring_end'>'</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>"classification_status":"Done",</span><span class='tstring_end'>'</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>"entities":[</span><span class='tstring_end'>'</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'>"</span><span class='tstring_content'>\t</span><span class='tstring_end'>"</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'>></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'>"</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'>"</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'>"</span><span class='tstring_content'>id</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>json</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>entities</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>,</span><span class='tstring_end'>"</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'>=></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'>"</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'>"</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'>"</span><span class='tstring_content'>id</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>json</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
|
||
|
<span class='comment'># puts qr["entities"]
|
||
|
</span> <span class='comment'># sleep(0.2)
|
||
|
</span> <span class='comment'># f_output.print qr["entities"][0],"\n"
|
||
|
</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'>"</span><span class='tstring_content'>entities</span><span class='tstring_end'>"</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 += ","
|
||
|
</span> <span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></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'>"</span><span class='tstring_content'>]}</span><span class='tstring_end'>"</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'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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<div class='inline'>
|
||
|
<p>path to the output file</p>
|
||
|
</div>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
</div><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
335
|
||
|
336
|
||
|
337
|
||
|
338
|
||
|
339
|
||
|
340
|
||
|
341
|
||
|
342
|
||
|
343
|
||
|
344
|
||
|
345
|
||
|
346
|
||
|
347
|
||
|
348
|
||
|
349
|
||
|
350
|
||
|
351
|
||
|
352
|
||
|
353
|
||
|
354
|
||
|
355
|
||
|
356
|
||
|
357
|
||
|
358
|
||
|
359
|
||
|
360
|
||
|
361
|
||
|
362
|
||
|
363
|
||
|
364
|
||
|
365
|
||
|
366
|
||
|
367
|
||
|
368
|
||
|
369
|
||
|
370
|
||
|
371
|
||
|
372
|
||
|
373
|
||
|
374
|
||
|
375
|
||
|
376
|
||
|
377
|
||
|
378
|
||
|
379
|
||
|
380
|
||
|
381
|
||
|
382
|
||
|
383
|
||
|
384
|
||
|
385
|
||
|
386
|
||
|
387
|
||
|
388</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 335</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'>'</span><span class='tstring_content'>r</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</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'>"</span><span class='tstring_content'>/</span><span class='tstring_end'>"</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'>'</span><span class='tstring_content'>w</span><span class='tstring_end'>'</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'>"</span><span class='tstring_content'>{</span><span class='tstring_end'>"</span></span>
|
||
|
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>"id": 1,</span><span class='tstring_end'>'</span></span>
|
||
|
<span class='id identifier rubyid_res'>res</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>"label":"</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>",</span><span class='tstring_end'>'</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>"classification_status":"Done",</span><span class='tstring_end'>'</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>"entities":[</span><span class='tstring_end'>'</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'>"</span><span class='tstring_content'>\t</span><span class='tstring_end'>"</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'>></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 "#{key} :: #{h[key]}"
|
||
|
</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'>/Applications/ChemAxon/JChem/bin/molconvert inchikey -s "</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'>"</span><span class='tstring_end'>)</span></span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</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'>"</span><span class='tstring_content'>json</span><span class='tstring_end'>"</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'>'</span><span class='tstring_content'>identifier</span><span class='tstring_end'>'</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'>"</span><span class='tstring_content'>,</span><span class='tstring_end'>"</span></span>
|
||
|
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</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'>"</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'>'</span><span class='tstring_content'>direct_parent</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>name</span><span class='tstring_end'>'</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'>=></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 "#{key} :: #{h[key]}"
|
||
|
</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'>/Applications/ChemAxon/JChem/bin/molconvert inchikey -s "</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'>"</span><span class='tstring_end'>)</span></span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</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'>"</span><span class='tstring_content'>json</span><span class='tstring_end'>"</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'>'</span><span class='tstring_content'>identifier</span><span class='tstring_end'>'</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'>"</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'>"</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'>'</span><span class='tstring_content'>direct_parent</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>name</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
||
|
<span class='comment'># res += ","
|
||
|
</span> <span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></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'>"</span><span class='tstring_content'>]}</span><span class='tstring_end'>"</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'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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<div class='inline'>
|
||
|
<p>path to the output file</p>
|
||
|
</div>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
</div><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
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
|
||
|
444
|
||
|
445
|
||
|
446
|
||
|
447
|
||
|
448
|
||
|
449
|
||
|
450
|
||
|
451
|
||
|
452
|
||
|
453
|
||
|
454
|
||
|
455
|
||
|
456</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 397</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'>'</span><span class='tstring_content'>r</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</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'>"</span><span class='tstring_content'>/</span><span class='tstring_end'>"</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'>'</span><span class='tstring_content'>w</span><span class='tstring_end'>'</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'>"</span><span class='tstring_content'>\t</span><span class='tstring_end'>"</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'>></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 "#{key} :: #{h[key]}"
|
||
|
</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'>/Applications/ChemAxon/JChem/bin/molconvert inchikey -s "</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'>"</span><span class='tstring_end'>)</span></span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</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'>"</span><span class='tstring_content'>sdf</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>The page you were looking for doesn't exist</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>The page you were looking for doesn't exist</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</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'>"</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'>"</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'>=></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 "#{key} :: #{h[key]}"
|
||
|
</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'>/Applications/ChemAxon/JChem/bin/molconvert inchikey -s "</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'>"</span><span class='tstring_end'>)</span></span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</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'>"</span><span class='tstring_content'>sdf</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>The page you were looking for doesn't exist</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>The page you were looking for doesn't exist</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</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'>"</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'>"</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'>=></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='comment'># f_output.print res
|
||
|
</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 = "STRUCTURE")
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</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 'STRUCTURE' or 'IUPAC_NAME'query types, each line must
|
||
|
contain either</p>
|
||
|
|
||
|
<pre class="code ruby"><code class="ruby">1) Only a structural represenation: SMILES, InChI for the 'STRUCTURE' query_type or a IUPAC name
|
||
|
for the 'IUPAC NAME' query type.
|
||
|
2) a tab-separated pair of an ID and the corresponding sructure representation: SMILES, InChI for the
|
||
|
'STRUCTURE' query_type or a IUPAC name for the 'IUPAC NAME' query type.</code></pre>
|
||
|
|
||
|
<p>For 'FASTA' 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),
|
||
|
'integer'</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>"STRUCTURE"</tt>)</em>
|
||
|
|
||
|
|
||
|
—
|
||
|
<div class='inline'>
|
||
|
<p>the query_type 'STRUCTURE' (default) or 'IUPAC_NAME' or
|
||
|
'FASTA'</p>
|
||
|
</div>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
|
||
|
</div><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
184
|
||
|
185
|
||
|
186
|
||
|
187
|
||
|
188
|
||
|
189
|
||
|
190
|
||
|
191
|
||
|
192
|
||
|
193</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 184</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'>"</span><span class='tstring_content'>STRUCTURE</span><span class='tstring_end'>"</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'>"</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'>"</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'>"</span><span class='tstring_content'>/</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>.</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>..</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>.DS_Store</span><span class='tstring_end'>"</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'>"</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'>"</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 = 'STRUCTURE')
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><div class="docstring">
|
||
|
<div class="discussion">
|
||
|
|
||
|
<p>Submits a ClassyFire query, which should be returned in a specific format.</p>
|
||
|
|
||
|
<p>if there is an error.</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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<div class='inline'>
|
||
|
<p>the input of the query.</p>
|
||
|
</div>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
<p class="tag_title">Returns:</p>
|
||
|
<ul class="return">
|
||
|
|
||
|
<li>
|
||
|
|
||
|
|
||
|
<span class='type'>(<tt>Hash</tt>)</span>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<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">
|
||
|
|
||
|
|
||
|
13
|
||
|
14
|
||
|
15
|
||
|
16
|
||
|
17
|
||
|
18
|
||
|
19
|
||
|
20
|
||
|
21
|
||
|
22
|
||
|
23
|
||
|
24
|
||
|
25
|
||
|
26
|
||
|
27
|
||
|
28</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 13</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'>'</span><span class='tstring_content'>STRUCTURE</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>/queries</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:label</span> <span class='op'>=></span> <span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='symbol'>:query_input</span> <span class='op'>=></span> <span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='symbol'>:query_type</span> <span class='op'>=></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'>=></span> <span class='symbol'>:json</span><span class='comma'>,</span> <span class='symbol'>:content_type</span> <span class='op'>=></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'>=></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'>=></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'>=></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'>=></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'>=></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, start, type = 'STRUCTURE')
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</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 'STRUCTURE' or 'IUPAC_NAME'query types, each line must
|
||
|
contain either</p>
|
||
|
|
||
|
<pre class="code ruby"><code class="ruby">1) Only a structural represenation: SMILES, InChI for the 'STRUCTURE' query_type or a IUPAC name
|
||
|
for the 'IUPAC NAME' query type.
|
||
|
2) a tab-separated pair of an ID and the corresponding sructure representation: SMILES, InChI for the
|
||
|
'STRUCTURE' query_type or a IUPAC name for the 'IUPAC NAME' query type.</code></pre>
|
||
|
|
||
|
<p>For 'FASTA' 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 'start'.</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>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<div class='inline'>
|
||
|
<p>The path to the input file.</p>
|
||
|
</div>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
|
||
|
</div><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
107
|
||
|
108
|
||
|
109
|
||
|
110
|
||
|
111
|
||
|
112
|
||
|
113
|
||
|
114
|
||
|
115
|
||
|
116
|
||
|
117
|
||
|
118
|
||
|
119
|
||
|
120
|
||
|
121
|
||
|
122
|
||
|
123
|
||
|
124
|
||
|
125
|
||
|
126
|
||
|
127
|
||
|
128
|
||
|
129
|
||
|
130
|
||
|
131
|
||
|
132
|
||
|
133
|
||
|
134
|
||
|
135
|
||
|
136
|
||
|
137
|
||
|
138
|
||
|
139
|
||
|
140
|
||
|
141
|
||
|
142
|
||
|
143
|
||
|
144
|
||
|
145
|
||
|
146
|
||
|
147
|
||
|
148
|
||
|
149
|
||
|
150
|
||
|
151
|
||
|
152
|
||
|
153
|
||
|
154
|
||
|
155
|
||
|
156
|
||
|
157
|
||
|
158
|
||
|
159
|
||
|
160
|
||
|
161
|
||
|
162
|
||
|
163
|
||
|
164
|
||
|
165
|
||
|
166
|
||
|
167
|
||
|
168
|
||
|
169</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 107</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='comma'>,</span> <span class='id identifier rubyid_start'>start</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>STRUCTURE</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>r</span><span class='tstring_end'>'</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_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_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'>"</span><span class='tstring_content'>\t</span><span class='tstring_end'>"</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'><<</span><span class='tstring'><span class='tstring_beg'>"</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'>"</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='id identifier rubyid_input'>input</span> <span class='op'><<</span><span class='tstring'><span class='tstring_beg'>"</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'>2</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
||
|
<span class='kw'>end</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'>"</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'>"</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='int'>0</span><span class='rbracket'>]</span>
|
||
|
<span class='id identifier rubyid_sleeping_time'>sleeping_time</span> <span class='op'>=</span> <span class='int'>120</span>
|
||
|
<span class='id identifier rubyid_initial_nr_of_jobs'>initial_nr_of_jobs</span> <span class='op'>=</span> <span class='int'>60</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'><</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'>"</span><span class='tstring_content'>.</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>_yannick</span><span class='tstring_end'>"</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</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'>"</span></span>
|
||
|
|
||
|
<span class='kw'>begin</span>
|
||
|
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</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'>"</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_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'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='comma'>,</span><span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_query_ids'>query_ids</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_q'>q</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>id</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
||
|
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></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='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'>end</span>
|
||
|
|
||
|
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</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'>"</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'>"</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'>"</span></span>
|
||
|
|
||
|
<span class='kw'>while</span> <span class='id identifier rubyid_i'>i</span> <span class='op'><</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='int'>80</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'>"</span><span class='tstring_content'>.</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>_yannick</span><span class='tstring_end'>"</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</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'>"</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'>"</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'>"</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'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</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'>=></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'>"</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'>"</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'>"</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'>"</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_random_subset_of_query_input_in_chunks-class_method">
|
||
|
|
||
|
+ (<tt>Object</tt>) <strong>submit_random_subset_of_query_input_in_chunks</strong>(tab_separated_input_file, size, type = 'STRUCTURE')
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><div class="docstring">
|
||
|
<div class="discussion">
|
||
|
|
||
|
<p>Takes a tab-separated file and submit randomly selected structures in bulks
|
||
|
of a given size.</p>
|
||
|
|
||
|
<p>For 'STRUCTURE' or 'IUPAC_NAME'query types, each line must
|
||
|
contain either</p>
|
||
|
|
||
|
<pre class="code ruby"><code class="ruby">1) Only a structural represenation: SMILES, InChI for the 'STRUCTURE' query_type or a IUPAC name
|
||
|
for the 'IUPAC NAME' query type.
|
||
|
2) a tab-separated pair of an ID and the corresponding sructure representation: SMILES, InChI for the
|
||
|
'STRUCTURE' query_type or a IUPAC name for the 'IUPAC NAME' query type.</code></pre>
|
||
|
|
||
|
<p>For 'FASTA' query type, just submit the query as a standard FASTA
|
||
|
text. is fragmented into n part of #slice_length entries each).</p>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="tags">
|
||
|
<p class="tag_title">Parameters:</p>
|
||
|
<ul class="param">
|
||
|
|
||
|
<li>
|
||
|
|
||
|
<span class='name'>tab_separated_input_file</span>
|
||
|
|
||
|
|
||
|
<span class='type'>(<tt>Text</tt>)</span>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<div class='inline'>
|
||
|
<p>The path to the input file.</p>
|
||
|
</div>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li>
|
||
|
|
||
|
<span class='name'>size</span>
|
||
|
|
||
|
|
||
|
<span class='type'>(<tt>Integer</tt>)</span>
|
||
|
|
||
|
|
||
|
|
||
|
—
|
||
|
<div class='inline'>
|
||
|
<p>The maximum number of entries for each query input (the whole file</p>
|
||
|
</div>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li>
|
||
|
|
||
|
<span class='name'>type</span>
|
||
|
|
||
|
|
||
|
<span class='type'>(<tt>String</tt>)</span>
|
||
|
|
||
|
|
||
|
<em class="default">(defaults to: <tt>'STRUCTURE'</tt>)</em>
|
||
|
|
||
|
|
||
|
—
|
||
|
<div class='inline'>
|
||
|
<p>The query_type, 'STRUCTURE' (default) or 'IUPAC_NAME' or
|
||
|
'FASTA'.</p>
|
||
|
</div>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
|
||
|
</div><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
209
|
||
|
210
|
||
|
211
|
||
|
212
|
||
|
213
|
||
|
214
|
||
|
215
|
||
|
216
|
||
|
217
|
||
|
218
|
||
|
219
|
||
|
220
|
||
|
221
|
||
|
222
|
||
|
223
|
||
|
224
|
||
|
225
|
||
|
226
|
||
|
227
|
||
|
228
|
||
|
229
|
||
|
230
|
||
|
231
|
||
|
232
|
||
|
233
|
||
|
234
|
||
|
235
|
||
|
236
|
||
|
237
|
||
|
238
|
||
|
239
|
||
|
240
|
||
|
241
|
||
|
242
|
||
|
243
|
||
|
244
|
||
|
245
|
||
|
246
|
||
|
247
|
||
|
248
|
||
|
249
|
||
|
250
|
||
|
251
|
||
|
252
|
||
|
253
|
||
|
254
|
||
|
255
|
||
|
256
|
||
|
257
|
||
|
258
|
||
|
259</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'lib/classyfire_api.rb', line 209</span>
|
||
|
|
||
|
<span class='kw'>def</span> <span class='const'>ClassyFireAPI</span><span class='period'>.</span><span class='id identifier rubyid_submit_random_subset_of_query_input_in_chunks'>submit_random_subset_of_query_input_in_chunks</span><span class='lparen'>(</span><span class='id identifier rubyid_tab_separated_input_file'>tab_separated_input_file</span><span class='comma'>,</span><span class='id identifier rubyid_size'>size</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>STRUCTURE</span><span class='tstring_end'>'</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_tab_separated_input_file'>tab_separated_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'>'</span><span class='tstring_content'>r</span><span class='tstring_end'>'</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_f'>f</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'>"</span><span class='tstring_content'>\t</span><span class='tstring_end'>"</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'><<</span><span class='tstring'><span class='tstring_beg'>"</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'>"</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='id identifier rubyid_input'>input</span> <span class='op'><<</span><span class='tstring'><span class='tstring_beg'>"</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'>"</span></span>
|
||
|
<span class='kw'>end</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_indexes'>indexes</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
||
|
<span class='id identifier rubyid_r'>r</span> <span class='op'>=</span> <span class='int'>1</span>
|
||
|
<span class='kw'>while</span> <span class='id identifier rubyid_r'>r</span> <span class='op'><=</span> <span class='lparen'>(</span><span class='id identifier rubyid_size'>size</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_s'>s</span> <span class='op'>=</span> <span class='id identifier rubyid_rand'>rand</span><span class='lparen'>(</span><span class='int'>0</span><span class='op'>..</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>-</span> <span class='int'>1</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>unless</span> <span class='id identifier rubyid_indexes'>indexes</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_indexes'>indexes</span><span class='op'><<</span><span class='id identifier rubyid_s'>s</span>
|
||
|
<span class='id identifier rubyid_r'>r</span> <span class='op'>+=</span> <span class='int'>1</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span>
|
||
|
|
||
|
<span class='id identifier rubyid_random_subset'>random_subset</span> <span class='op'>=</span> <span class='id identifier rubyid_indexes'>indexes</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_x'>x</span><span class='op'>|</span> <span class='id identifier rubyid_input'>input</span><span class='lbracket'>[</span><span class='id identifier rubyid_x'>x</span><span class='rbracket'>]</span><span class='rbrace'>}</span>
|
||
|
<span class='id identifier rubyid_subdivised_groups'>subdivised_groups</span> <span class='op'>=</span> <span class='id identifier rubyid_random_subset'>random_subset</span><span class='period'>.</span><span class='id identifier rubyid_each_slice'>each_slice</span><span class='lparen'>(</span><span class='int'>100</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
|
||
|
<span class='id identifier rubyid_sleeping_time'>sleeping_time</span> <span class='op'>=</span> <span class='int'>120</span>
|
||
|
|
||
|
<span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='int'>0</span>
|
||
|
<span class='kw'>while</span> <span class='id identifier rubyid_i'>i</span> <span class='op'><</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='int'>5</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'>"</span><span class='tstring_content'>.</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>_yannick</span><span class='tstring_end'>"</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>_part_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_k'>k</span><span class='op'>+</span><span class='int'>1</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</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'>"</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'>"</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='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'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</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'>=></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'>"</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'>"</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'>"</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'>"</span></span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span></pre>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div id="footer">
|
||
|
Generated on Wed Mar 9 19:25:39 2016 by
|
||
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
||
|
0.8.7.6 (ruby-2.3.0).
|
||
|
</div>
|
||
|
|
||
|
</body>
|
||
|
</html>
|