-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A trial analysis API client stub #681
Conversation
thanks! In this case, it would be also good to have the option of having it as a .json file as output. I will feed some objects into a workflow I am developing. There is this Active model serialiser gem which to my understanding reduces the .json output. I think this would be good as some of the objects are not necessary. Have you used this before? |
I won't have time to do anything else until Monday. But be prepared for questions then (: |
Are you sure you haven't changed that file? Mine has 111 lines and yours, guessing from the error output, has at least 114. Anyway, please try with the trial name 'whri_2005_GE2_02' on the BIP public server - it should work (just run it right now and it worked fine). |
Re. JSON output - first you'd need to decide how to structure the output (by PSUs? by TDs?). Active Model is not available in the vanilla client script, unless you load it, but then again it can't be used as what you get are rather hashes and not the active models. But I think using JSON generator methods, as you do, is the way to go. |
You are right, I must have changed the script before running it. N80569:client_example hildegaa$ ruby trial_analysis.rb U.Nottm_2016_RIPRleafminerals_REMLmeans api-key
but I don't get an error when using your suggested trial. I will now use the rest of my day to add to the script and test it on your trial name. |
I am failing in adding more columns to the current csv-stout.. could you have a look and give me a hint? I was trying to add the Plant_Accession_name as a column between the Plant Scoring Unit and the Trait scores. Re. JSON output, I thought, I would start with plant_trials, then PSU, and within PSU, have PA and PL as well as TS and TD( and associated). does that make sense you think? |
Done - see the changes. One more thing about the PAs is that you probably don't get them all, as the API returns first 50 hits by default (you can max it out to 200, but not beyond - an anti-attack measure). So you need to implement a loop - see one for trait scores, try to do something similar for PAs. |
thanks, will have a look. |
I guess you can do that, but remember that it introduces an external dependency - it means, all script users will need to install at least rubygems and the activesupport gem, along its own dependencies. For their sake, I'd advise to try to stay with vanilla ruby. |
okay..... I don't manage to select multiple keys ( e.g. score_valyes and value_type).. Pleeeaase have a look for me, am at the banging my head stage (: see recent commit |
with regards to your commit "showing PAs in the CSV output" |
|
could you have a look at '5. -Finding Plant Accessions... ' |
@teatree1212 for demonstration I tried a different technique this time. Notable changes:
|
a few notes on the next commit: -data['plant_line_id'] doesn't exist or is empty or something in between (: -data is part of the ouputs - hash, and as no connection is established between PL and PSU, there is no plant_line information in the output hash in general. -I don't yet understand how to add the PLs to the outputs hash, as I find that that table is "too far away" ( via Plant_accessions) to do: to be able to generate a meaningful json output:
|
Notes: outputs.each do |scoring_unit_name, data| scoring_unit_name = hash Need to add plant_lines hashes to PSU.scoring_unit_name keys http://www.slideshare.net/harkamalsingh355/ruby-data-types-and-objects |
Problem 1: Problem 2: I was trying to build something in line 162/3, Where i want to put the content of the plant_accessions['plant_accession'] into outputs[plant_scoring_unit['scoring_unit_name']]['plant_accession_name'] |
Dear @teatree1212
|
@teatree1212 Annemarie - since @kammerer created #702 I am closing this pull request. I will, however, leave the git branch in case you'd like to use it further. |
When finished it fixes #680
@teatree1212 per your request I started that with a client stub. Currently it finds the PT (by name), gets all TDs, PSUs and TSes related to that PT, and outputs a CSV document which pretty much resembles the one available at https://bip.earlham.ac.uk/trial_scorings/5.
Please take it from here and add further data. When in doubt how to query an individual table, see the 'Q' marker in the docs, or the definition of
permitted_params
inside individual model classes in the sources, to see what field is available for filtering.