Ciao Anders,
sì, quello
query_terms = dt3:organism id << get values;
è fondamentalmente la chiave per usarlo per ottenere tutti quei valori.
E hai ragione, qui c'è una limitazione con Sequoia, quindi se hai bisogno di farlo con 1000
La risposta che Sequoia ti dà ha limitazioni simili alla visualizzazione web, mostra solo così tanto e quindi devi interrogare per la prossima "pagina" di risultati. Una soluzione per ora sarebbe aggiungere dell'altro codice che conta il numero di elementi nell'elenco query_items e quindi eseguire il ciclo della query per recuperare i sottoinsiemi di quei dati in ogni round del ciclo.
Qualcosa sulla falsariga di loop = N elementi (query_terms) / (number_of_max_results_from_Sequoia) e poi un ciclo For i = 1, i
Spero che aiuti,
Alex
Grazie Alexander,
Ho funzionato con tabelle di dati più piccole, ma non ottengo alcuna risposta quando si utilizzano elenchi più grandi (> 1000 voci). Forse questa è una limitazione in Sequoia?
Altrimenti penso che lo script richiami i dati molto velocemente.
Ecco una piccola modifica che ho fatto per chiamare ~ 10 voci ID organismo da una tabella dati.
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);
Ciao,
è possibile, ma devi crearlo da solo perché non c'è uno script preconfigurato pronto. Tuttavia passo un po 'di tempo per mettere insieme un piccolo esempio. Probabilmente puoi capire come usarlo per ottenere le informazioni che desideri da SEQUOIA. Non aspettarti che questo funzioni molto velocemente, perché c'è un modo diverso ma richiede un po 'di preconfigurazione (in breve: aggiungi il data lake come origine dati in JMP e quindi usa le query SQL per ottenere le informazioni che desideri piace ottenere).
Lo script che ho incluso consiste in una grossa porzione di codice che analizza la risposta formattata JSON proveniente da SEQUOIA, non devi fare nulla con quello. Sotto ci sono alcune righe di codice che mostrano come interrogare e ottenere le informazioni in una tabella JMP, che puoi quindi manipolare ulteriormente in JMP per unirla ai tuoi dati.
Nota che dovrai cambiare campione purificato a seconda di dove / cosa in SEQUOIA stai cercando.
Questa è la parte del codice che dovresti manipolare per ottenere i dati che ti interessano in 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)) ); (il codice sopra richiede alcune funzioni aggiuntive che sono incluse nello script jsl allegato a questo post, scarica il file * .jsl per eseguire l'esempio)
Per riferimento questo è lo script completo:
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)) );