Hola Anders,
Si, eso
query_terms = dt3:organism id << get values;
es básicamente la clave para usarlo para obtener todos esos valores.
Y tiene razón, hay una limitación con Sequoia aquí, por lo tanto, si necesita hacerlo con 1000
La respuesta que te da Sequoia tiene limitaciones similares a las de la vista web, solo muestra una cantidad limitada y luego debes consultar la siguiente "página" de resultados. Una solución alternativa por ahora sería que agregue más código que cuente el número de elementos en su lista query_items y luego realice un ciclo de la consulta para recuperar subconjuntos de esos datos en cada ronda del ciclo.
Algo como loops = N elementos (query_terms) / (number_of_max_results_from_Sequoia) y luego un bucle For i = 1, i
Espero que ayude,
Alex
Gracias Alexander,
Lo hice funcionar con tablas de datos más pequeñas, pero no obtengo ninguna respuesta cuando uso listas más grandes (> 1000 entradas). ¿Es esto quizás una limitación en Sequoia?
De lo contrario, creo que el guión recuerda los datos muy rápido.
Aquí hay una pequeña modificación que hice para llamar a ~ 10 entradas de ID de organismo de una tabla de datos.
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);
Hola,
es posible, pero debe escribirlo usted mismo, ya que no hay un script preconfigurado listo. Sin embargo, solo dedico un tiempo a poner un pequeño ejemplo. Probablemente pueda descubrir cómo usar esto para obtener la información que le gustaría de SEQUOIA. No espere que esto se ejecute muy rápido, para eso hay una forma diferente pero requiere más preconfiguración (en resumen: agregue el lago de datos como una fuente de datos en JMP y luego use consultas SQL para obtener la información que desea me gusta conseguir).
El script que he incluido consta de una gran parte de código que analiza la respuesta formateada JSON que proviene de SEQUOIA, no tiene que hacer nada con eso. Debajo hay algunas líneas de código que le muestran cómo consultar y obtener la información en una tabla JMP, que luego puede manipular en JMP para unirla con sus datos.
Tenga en cuenta que deberá cambiar muestra purificada dependiendo de dónde / qué en SEQUOIA esté buscando.
Esta es la parte del código que necesitaría manipular para obtener los datos que le interesan en 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)) ); (el código anterior necesita algunas funciones adicionales que se incluyen en el script jsl que se adjunta a esta publicación, descargue el archivo * .jsl para ejecutar el ejemplo)
Como referencia, este es el 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)) );