how to get run id

541 views
Skip to first unread message

Sungsam Gong

unread,
Jun 14, 2013, 9:09:23 AM6/14/13
to basespace-...@googlegroups.com

Hi,

I am wondering how I can get a run id an app session.

Basically I want to get some basic run meta information (i.e. run_name) from the project where my app was triggered.

Based on the api doc, it looks like 'appsession' is the starting point.

I could manage to get a project name and id from my app session, but don't know how to get a run id.

Is it possible to get the run id from a project id at the API level?

The only workaround I could think of is to retrieve a list of runs accessible by the current user as explained from the following doc: https://developer.basespace.illumina.com/docs/content/documentation/rest-api/api-reference#GET%3a_users%2fcurrent%2fruns

Then, maybe I could get the run id having the same ExperimentName with the current Project name.

However this plan did not go well as my php script returns nothing as shown below:

$ch = curl_init(BASESPACE_API_URL.'/'.USER_RUN_REF); curl_setopt($ch, CURLOPT_HTTPHEADER, array('x-access-token: '.ACCESS_TOKEN)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); curl_exec($ch);

{"Response":{"Items":[],"DisplayedCount":0,"TotalCount":0,"Offset":0,"Limit":10,"SortDir":"Asc","SortBy":"Id"},"ResponseStatus":{},"Notifications":[]}


Strangely, If I copy the URL (BASESPACE_API_URL.'/'.USER_RUN_REF) and paste it into a browser, I could see it.

What went wrong?

Any thoughts?

Thanks,

Sung

Message has been deleted

Mayank Tyagi

unread,
Jun 17, 2013, 3:29:13 AM6/17/13
to basespace-...@googlegroups.com
Hi Sung,

A Project may contain Samples from multiple Runs.  To find how a Project relates to a Run, you will need to look at the Sample metadata within that Project (https://developer.basespace.illumina.com/docs/content/documentation/rest-api/api-reference#Samples.)  This request will return the ExperimentName of the Run that created it, and you can then match on those names.  In some cases, the user may not have access to the original Run, this is because Projects and Runs are separate resources and are permissioned separately.  In that case, the user may not have a Run with that ExperimentName because they were only shared the Project in BaseSpace.  

Projects are a container for Samples (.fastq) and AppResults (.bam, .vcf, and other result files.)  You can find more information about this in the BaseSpace Data Model Overview.  

Please do not hesitate to post more information should you need further assistance.  Hope this helps!

Sincerely,
The BaseSpace Platform Team

Sungsam Gong

unread,
Jun 24, 2013, 8:07:44 AM6/24/13
to basespace-developers on behalf of Mayank T
Dear Mayank,

Thanks for your reply.
No problem accessing Samples info from my script using the API, but still no luck retrieving a list of runs for the current user (e..g users/{ID}/runs).
As I said previously, it shows:
{"Response":{"Items":[],"DisplayedCount":0,"TotalCount":0,"Offset":0,"Limit":10,"SortDir":"Asc","SortBy":"Id"},"ResponseStatus":{},"Notifications":[]}

However, using exactly same URL, my web browser displays what I expected to see from the php script.
Why it returns nothing from the script?
Again, the script works well with Samples (e.g. v1pre3/projects/1/samples).

Kind regards,
Sung


On 17 June 2013 08:27, Mayank T via basespace-developers <basespace-developers+noreply-APn...@googlegroups.com> wrote:
Hi Sung,

A Project may contain Samples from multiple Runs.  To find how a Project relates to a Run, you will need to look at the Sample metadata within that Project (https://developer.basespace.illumina.com/docs/content/documentation/rest-api/api-reference#Samples.)  This request will return the ExperimentName of the Run that created it, and you can then match on those names.  In some cases, the user may not have access to the original Run, this is because Projects and Runs are separate resources and are permissioned separately.  In that case, the user may not have a Run with that ExperimentName because they were only shared the Project in BaseSpace.  

Projects are a container for Samples (.fastq) and AppResults (.bam, .vcf, and other result files.)  You can find more information about this in the BaseSpace Data Model Overview.  

Please do not hesitate to post more information should you need further assistance.  Hope this helps!

Sincerely,
The BaseSpace Platform Team

On Friday, June 14, 2013 6:09:23 AM UTC-7, Sungsam Gong wrote:

--
You received this message because you are subscribed to a topic in the Google Groups "basespace-developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/basespace-developers/ZbRDpwRNXL0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to basespace-develo...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mayank Tyagi

unread,
Jun 27, 2013, 8:53:14 PM6/27/13
to basespace-...@googlegroups.com
Hi Sung,

That is very strange, when you copy the URL (BASESPACE_API_URL.'/'.USER_RUN_REF) and paste it in your browser, are you passing the access token in the header (or as a url parameter)? If you are not passing an access token, are you logged into BaseSpace in the browser?

If you are able to list the Samples for a Project, you should be able to list the user's Runs with the same token, there are no different permissions. There is nothing obvious in your script, it looks like you are passing an access token with the request, and if you are able to get the response via the browser you should be able to use exactly what you have above. We may need more information from you in order to triage this issue if you are still encountering it.  

Please let us know if you are still encountering this issue and we can get in contact with you to provide direct support on this issue.  

Sincerely,
The BaseSpace Platform Team

On Monday, June 24, 2013 5:07:44 AM UTC-7, Sungsam Gong wrote:
Dear Mayank,

Thanks for your reply.
No problem accessing Samples info from my script using the API, but still no luck retrieving a list of runs for the current user (e..g users/{ID}/runs).
As I said previously, it shows:
{"Response":{"Items":[],"DisplayedCount":0,"TotalCount":0,"Offset":0,"Limit":10,"SortDir":"Asc","SortBy":"Id"},"ResponseStatus":{},"Notifications":[]}

However, using exactly same URL, my web browser displays what I expected to see from the php script.
Why it returns nothing from the script?
Again, the script works well with Samples (e.g. v1pre3/projects/1/samples).

Kind regards,
Sung
To unsubscribe from this group and all its topics, send an email to basespace-developers+unsub...@googlegroups.com.

Sungsam Gong

unread,
Jun 28, 2013, 5:44:44 AM6/28/13
to basespace-developers on behalf of Mayank Tyagi
Dear Team,

Thanks for your reply.
1. When the URL was pasted in my browser, I was already logged in without passing the access token in the header. Then I could see the list of runs which I am authorised to browse (my runs together with shared ones).
2. Still don't know why my script failed to fetch the run list. Below is two different ways I tried to get access:
2-1. 
$command="curl --header 'x-access-token: ".ACCESS_TOKEN."' -v -L -o /data/results/MiSeq/user_run.txt ".BASESPACE_API_URL.'/'.USER_RUN_REF;
echo $command,'<br/>';
$process = new BackgroundProcess($command);
$process->run();
echoProcess($process);

2-2. 
$ch = curl_init(BASESPACE_API_URL.'/'.USER_RUN_REF);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('x-access-token: '.ACCESS_TOKEN)); //from the include/get_access_token
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); 
curl_exec($ch);

Both with no lucks to me.

However, for Samples:
// get samples for now
/*
curl -v -H "x-access-token: {access_token}" \
*/

$ch = curl_init(BASESPACE_API_URL.'/'.PROJECT_URI.'/samples?SortBy=Id&SortDir=Desc&Limit=1000');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('x-access-token: '.ACCESS_TOKEN));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$project_res=json_decode(curl_exec($ch))->{'Response'};
curl_close($ch);

no problem at all above.

Any thoughts?

Kind regards,
Sung




To unsubscribe from this group and all its topics, send an email to basespace-develo...@googlegroups.com.

Mayank Tyagi

unread,
Jul 8, 2013, 12:34:20 PM7/8/13
to basespace-...@googlegroups.com
Hi Sung,

We will look into this and help you to resolve it.  Regarding the access token that you are using, are you using "Your Access Token" from the "Credentials" tab in your application in the developer portal or are you using the regular access token that you get from OAuth?  

Depending on the method you are using, we should be able to investigate this issue in more detail.  The same access token should be able to show all of the user's Runs.  Was there an error or an exception that was thrown at all?

Let us know, thanks.

Sincerely,
The BaseSpace Platform Team

Dear Team,

To unsubscribe from this group and all its topics, send an email to basespace-developers+unsubscrib...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages