Hi Anders,
yes that
query_terms = dt3:organism id << get values;
is basically the key to use it for getting all those values.
And you are right, there is a limitation with Sequoia here, therefore if you need to do it with 1000< rows i would suggest to use a different solution that would query the data from the datalake, when it becomes available.
The reply that Sequoia gives you has similar limitations as the web view, it only shows so much and then you need to query for the next "page" of results. A work around for now would be that you add some more code which counts the number of items in your query_items list and then you loop the query to retrieve subsets of that data in each round of the loop.
Something along the lines of loops = N items(query_terms)/(number_of_max_results_from_Sequoia) and then a loop For i=1, i
Hope that helps,
Alex
Thanks Alexander,
I got it to work with smaller data tables, but I don't get any response when using larger lists (>1000 entries). Is this a limitation in Sequoia perhaps?
Otherwise I think the script recalls data very fast.
Here is a small modification I did to call ~10 Organism ID entries from a data table.
dt3 = Open("N:\Projects\High pH Amylase\ADW_GODperid\Summary data\Joined_data_Screening to FSW.xlsx",
0,
0,
0,
0);
Namespace("JSON") << show contents;
base_url = "http://nzdb.nzcorp.net/organism/all/large" || "?accept=application%2Fjson";
query_columns = {"identifier", "code", "synonym", "from"};
cols = "&cols=" || Concat Items(query_columns, "%2C" );
query_terms = dt3:organism id << get values;
query = "&q=" || Concat Items(query_terms, " OR " );;
url = base_url ||cols || query;
show(url);
dt = JSON:Make Table( open(url, HTML Table(2)) );
close (dt3, nosave);
Hi,
it is possible, but you have to script it yourself as there is not a preconfigured script ready. However i just spend some time to put a little example together. You can probably figure out how to use this to get the information that you would like from SEQUOIA. Don't expect this to be running very fast, for that there is a different way but it requires some more pre-configuration (in short:add the data lake as a datasource in JMP and then use SQL querys to get the information you would like to get).
The script that i have included consist of a big chunk of code that parses the JSON formatted response coming from SEQUOIA, you dont have to do anything with that. Under that are a few lines of code that show you how to query and get the information into a JMP table, that you can then further maninpulate in JMP to join it with your data.
Note that you will need to change purifiedsample depending on where/what in SEQUOIA you are searching.
This is the part of the code that you would need to manipulate to get the data that you are interested in into JMP:
base_url = "http://nzdb.nzcorp.net/purifiedsample/all/large" || "?accept=application%2Fjson";
query_columns = {"organism_code","identifier", "a280"};
cols = "&cols=" || Concat Items(query_columns, "%2C" );
query_terms = {"U6ESJ","U8GF4"};
query = "&q=" || Concat Items(query_terms, " OR " );;
url = base_url ||cols || query;
show(url);
dt = JSON:Make Table( open(url, HTML Table(2)) ); (the above code needs some additional functions which are included in the jsl script that is attached to this post, please download the *.jsl file to run the example)
For reference this is the full script:
New Namespace("JSON",
{
Char Escape = Function({c},
Match(c,
"\!"", "\!"",
"b", "\!u0008",
"f", "\!u000C",
"n", "\!u000A",
"r", "\!u000D",
"t", "\!u0009",
c
)
);
,
Unicode Escape = Function( {u},
u = "\!"\!\!u" || u || "\!"";
Parse( u );
);
,
Pattern Name =
"\!"" // leading quotation mark
+ pattest( value = ""; 1) // init string accumulator
+ patrepeat(
(Pat break( "\!\\!"" ) >> temp + Pat Test( value ||= temp; 1; )) // run of characters that are not \ or "
|
("\u"+patlen(4)>>temp+pattest(value ||= JSON:Unicode Escape(temp);1)) // \uXXXX
|
("\"+patlen(1)>>temp+pattest(value ||= JSON:Char Escape(temp);1)) // \", for example...embedded quotation mark
)
+ "\!""; // trailing quotation mark
,
Pattern Number = patspan("0123456789-+eE.") >> temp + pattest(value=num(temp);1);
,
starttime=0;
,
progressTable=0;
,
progress = Function( {p},
If( Is Empty( JSON:progressTable ),
JSON:progressTable = New Table( "JSON Parsing Progress Log", New Column( "Time" ), New Column( "Percent" ) );
JSON:progressTable << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :Time ), Y( :Percent ) ),
Elements(
Points( X, Y, Legend( 1 ), Jitter( 1 ) ),
Line Of Fit(
X,
Y,
Legend( 3 ),
Confidence of Fit( 1 ),
Confidence of Prediction( 0 ),
Degree( "Linear" ),
Equation( 0 ),
Root Mean Square Error( 0 ),
R²( 0 )
)
)
);
);
JSON:progressTable << addrows( 1 );
JSON:progressTable:time = Tick Seconds() - JSON:starttime;
JSON:progressTable:percent = 100 * p;
);
,
PatternParse = patpos(0) + patrepeat(patpos(/* remember how far we parsed for error message */)>>failpos
/* comment out this line for a little more speed */+pattest(if(tickseconds()-lasttime>1,JSON:progress(failpos/totalLen);lasttime=tickseconds();wait(0));1)
+patfence(/* fence off previously parsed text...ain't no going back */)
+( patregex("\s*") // ignore whitespace
| JSON:Pattern Name
| ( ":" + pattest(key=value;1) )
| JSON:Pattern Number
| ("true" + pattest(value = 1;1))
| ("false" + pattest(value = 0;1))
| ("null" + pattest(value = .;1))
| ("[" + pattest(Insert Into( stack, {{}}, 1 );value = Empty();1))
| ("{" + pattest(Insert Into( stack, Associative Array(), 1 );value = Empty();Insert Into( keys, key, 1 );1))
| ("]" + pattest(If( !Is Empty( value ),Insert Into( stack[1], value, 1 /*needs reverse later*/ ));value = stack[1];value=reverse(value);Remove From( stack, 1 );1))
| ("}" + pattest(If( !Is Empty( value ),stack[1][key] = value);value = stack[1];Remove From( stack, 1 );key = keys[1];Remove From( keys, 1 );1))
| ("," + pattest(If( Is List( stack[1] ),Insert Into( stack[1], value, 1 /*needs reverse later*/ ),stack[1][key] = value);value = Empty();1))
)) + patrpos(0);
,
Parse = Function( {json},
{stack = {}, keys = {}, key = "", value = Empty(), temp=0,totalLen = length(json),lasttime = tickseconds(),failpos=0},
JSON:starttime = tickseconds();
JSON:progressTable=empty();
if( !try(patmatch(json,JSON:PatternParse),0), Throw( "unrecognized JSON at " || Char( failpos ) ));
value;
);
,
Append Rows = Function( {dt, start, prefix, a},
{key, value, dc, c, nc, r, delta, added = 0},
If(
Is List( a ),
For( r = 1, r <= Length( a ), r++,
delta = JSON:Append Rows( dt, start + added, prefix, a[r] );
added += delta;
);
// fill empty cells
nc = N Col( dt );
For( c = 1, c <= nc, c++,
dc = Column( dt, c );
value = dc[start];
For( r = start + 1, r <= N Row( dt ), r++,
If( dc[r] == "",
dc[r] = value
)
);
);,
Is Associative Array( a ),
key = a << First;
While( !Is Empty( key ),
value = a[key];
delta = JSON:Append Rows( dt, start, If( prefix == "", key, prefix || "." || key ), value );
added = Max( added, delta );
key = a << Next( key );
);,
// else a literal
If( prefix == "",
prefix = "v"
); // can only happen in a top array of literals
dc = Try( Column( dt, prefix ), dt << New Column( prefix, "Character" ) );
added = 1; // don't count padding
If( N Rows( dt ) < start,
dt << Add Rows( start - N Rows( dt ) )
);
// fill to end in case a previous column was a JSON array
For( r = start, r <= N Rows( dt ), r++,
dc[r] = Char( a )
);
);
added;
);
,
Make Table = Function( {json},
{dt},
If( Is String( json ),
json = JSON:Parse( json )
);
dt = New Table();
dt << Begin Data Update();
JSON:Append Rows( dt, N Rows( dt ) + 1, "", json );
dt << End Data Update();
dt;
);
}); // end namespace
Delete Globals();
Namespace("JSON") << show contents;
base_url = "http://nzdb.nzcorp.net/purifiedsample/all/large" || "?accept=application%2Fjson";
query_columns = {"organism_code","identifier", "a280"};
cols = "&cols=" || Concat Items(query_columns, "%2C" );
query_terms = {"U6ESJ","U8GF4"};
query = "&q=" || Concat Items(query_terms, " OR " );;
url = base_url ||cols || query;
show(url);
dt = JSON:Make Table( open(url, HTML Table(2)) );