Documentation‎ > ‎

API Libraries



PHP


Example usage:
Download S3QLgoodies.php (at the bottom of this page) and under the same directory, create a script: example.php

Inside example.php add the following lines:

example.php

<?php

include_once('S3QLgoodies.php');
$s3ql = array('url'=>'http://ibl.mdanderson.org/s3dbdemo3','key'=>'6OhmdK6M5KNVScq','select'=>'*','from'=>'projects','format'=>'php');
list($url, $data) = S3DBcall($s3ql);
echo '<pre>';print_r($data);

?>

You can now refer to you s3db project (to build new queries, for example) by their indexes in the array:
$s3ql = array('url'=>'http://ibl.mdanderson.org/s3dbdemo3','key'=>'6OhmdK6M5KNVScq','select'=>'*','from'=>'rules','where'=>array('project_id'=>$data[0]['project_id']),'format'=>'php');

list($url,$rules) = S3DBcall($s3ql);

echo '<pre>';print_r($rules);echo '</pre>';

The library also includes uploading and inserting files on s3db

move2s3db

<?php

include_once('S3QLgoodies.php');
#Specify the path to the file you wish to upload
$file ='/home/mhdeus/.public_html/welkinRDF.png';

#specify the Url and Key where you want your file to be uploaded, along with an item_id and a rule_id from your deployment
$url='http://ibl.mdanderson.org/s3dbdemo3';
$key='6OhmdK6M5KNVScq';
$rule_id='12140';
$item_id='12141';

#In case you want to know how much time the upload took
$time=date('His');

$results=move2s3db($file, $url,$key,$rule_id,$item_id);
if($results[0]['error_code']=='0')
{
echo "File ".basename($file)." was uploaded in ".(date('His')-$time)." seconds";
echo '<br />You can see what you\'ve uploaded by using the link:
<a href="'.$url.'/item.php?item_id='.$item_id.'&key='.$key.'">http://ibl.mdanderson.org/s3dbdemo3/item.php?item_id='.$item_id.'&key='.$key.'</a>';

}
else {
echo  $results[0]['message'];
}


?>

Javascript


METHOD 1
Download s3ql_js.txt
Download jsonpp_js.txt from JSON, JSONP, JSONPP? and in the same directory create a script: example.html

example.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">
 <head>   
 
  <script type="text/javascript" src="jsonpp_js.txt"></script>
  <script type="text/javascript" src="s3ql_js.txt"></script>
   <script type="text/javascript">
   var s3ql = new Array;
   s3ql['url']='http://ibl.mdanderson.org/s3dbdemo3';
   s3ql['key'] = '6OhmdK6M5KNVScq';
   s3ql['select'] = '*';
   s3ql['from'] = 'projects';
   s3ql['format'] = 'json';
   var url = S3QLquery(s3ql);
   window.open(url);
   </script>
 
 
 </head>

 <body>
 
 </body>
</html>

See JSON, JSONPP, JSONPPP library for examples on handling JSON variables and JSONP callbacks.

METHOD 2
This method makes use of a library that translates the S3QL compact notation into the XML S3QL notation. 
First, you will need the library that makes the translation, available here.
Second, you will need the jquery library for quick Ajax calls, available here


S3QL Js Example 2

<HTML>
 <HEAD>
  <TITLE> S3QL jquery</TITLE>
  <script type="text/javascript" src="jquery-1.4.4.min.js"></script>
  <script type="text/javascript" src="s3ql_translator.js"></script>
  
<SCRIPT LANGUAGE="JavaScript">

var q = 'select(C|P56285)';
var s3ql = S3QLtranslator(q);
var fullQuery = "http://ibl.mdanderson.org/s3dbdemo3/S3QL.php?key=oqatHYDy1VTbbNi&query="+s3ql+"&format=json";
var returnedData = {};

$.getJSON(fullQuery+'&callback=?',
function (data) {
returnedData = data;
}
)


</SCRIPT>
 </HEAD>

 <BODY>

If you open you JavaScript console, the data will be available at the "returnedData" variable.

Matlab



Usage example:
Download S3QLSyntax.m, html2cell.m and s3db_read.m (at the bottom of this page) and create a new script in the same directory (example.m)

example.m

s3ql = struct('url','http://ibl.mdanderson.org/s3dbdemo3', 'key','6OhmdK6M5KNVScq', 'select', '*','from','projects','format','html')

url = S3QLSyntax(s3ql);

data = html2cell(urlread(url));

data = cell2struct(data(2:end,:), data(1,:), 2)

%You can now call you projects using their index

 s3ql = struct('url','http://ibl.mdanderson.org/s3dbdemo3', 'key','6OhmdK6M5KNVScq', 'select', '*','from','rules', ...
'where',struct('project_id', data(1).project_id),...
'format','html')

rules  = html2cell(urlread(S3QLSyntax(s3ql)))

rules  = cell2struct(rules(2:end,:), rules(1,:), 2)


%As an alternative, s3db_read.m performs these steps for you:
s3ql = struct('url','http://ibl.mdanderson.org/s3dbdemo3', 'key','6OhmdK6M5KNVScq', 'select', '*','from','projects','format','html')

projects = s3db_read(s3ql)

You may also want to use matlab to upload large file into S3DB, for that purpose download the function move2s3db.m and base64encode.m (in case your version of Matlab does not have it yet)

move2s3db.m

Create a structure with fields:

url
key
item_id
rule_id
file

Item_id and Rule_id correspond to the ids of the statement where you want to insert your file

Run the function:
x = struct('url','http://ibl.mdanderson.org/s3dbdemo3','key','6OhmdK6M5KNVScq','item_id','12551','rule_id','2080','file','test.CEL')

[rep,url,filekey] = move2s3db(x)



ċ
S3QLSyntax.m
(2k)
Lena Deus,
Aug 13, 2008, 12:21 PM
ċ
S3QLgoodies.php
(5k)
Lena Deus,
Aug 27, 2008, 7:34 PM
ċ
base64encode.m
(5k)
Lena Deus,
Sep 24, 2008, 10:44 AM
ċ
example.m
(0k)
Lena Deus,
Aug 13, 2008, 12:33 PM
ċ
example.php
(1k)
Lena Deus,
Aug 13, 2008, 12:34 PM
ċ
html2cell.m
(1k)
Lena Deus,
Aug 13, 2008, 12:21 PM
ċ
move2s3db.m
(4k)
Lena Deus,
Sep 24, 2008, 10:40 AM
ċ
s3db_read.m
(0k)
Lena Deus,
Aug 13, 2008, 12:32 PM
ċ
s3ql_js.txt
(2k)
Lena Deus,
Sep 4, 2008, 2:50 PM
ċ
s3ql_translator.js
(2k)
Lena Deus,
Jan 8, 2011, 9:59 AM
ċ
shortData.mat
(2k)
Helena Deus,
Oct 12, 2010, 10:51 AM
Comments