-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial
In the below examples, the 'curl' command line application is used to interact with the test iMits deployment which contains a copy of live data.
PLEASE NOTE:
- The users here are purely mythical, and the examples are only for illustrative purposes.
- Lines starting with '$' are the shell commands executed (excluding the '$' itself). The output of the shell command are shown below them.
- IDs of the created resources are going to be different - the ones in the examples are purely for illustrative purposes.
- The responses to the commands were edited for clarity and brevity, the real ones will be different - please run long lines of JSON through "JSONLint":http://jsonlint.com/ to help make them easier to read.
For a full set of attributes on a Plan that can be manipulated, please see the Reference.
Sue at WTSI registers interest in some genes:
$ curl --globoff --basic --user sue@sanger.ac.uk:password -X POST \
-H 'Content-Type: application/json' --data-binary \
'{"mi_plan": {"marker_symbol": "Shb", "consortium_name": "BaSH",
"production_centre_name": "WTSI", "priority_name": "High"}}' \
'https://www.i-dcc.org/staging/imits/mi_plans.json'
{
"id": 7767,
"status_name": "Assigned",
"marker_symbol": "Shb",
"consortium_name": "BaSH",
"production_centre_name": "WTSI"
}
$ curl --globoff --basic --user sue@sanger.ac.uk:password -X POST \
-H 'Content-Type: application/json' --data-binary \
'{"mi_plan": {"marker_symbol": "Lcn2", "consortium_name": "BaSH",
"production_centre_name": "WTSI", "priority_name": "High"}}' \
'https://www.i-dcc.org/staging/imits/mi_plans.json'
{
"id": 7768,
"status_name": "Assigned",
"marker_symbol": "Lcn2",
"consortium_name": "BaSH",
"production_centre_name": "WTSI"
}
Bob at UCD also registers interest in one of the same genes, but makes a mistake, and gets back an error:
$ curl --globoff --basic --user bob@ucdavis.edu:password -X POST \
-H 'Content-Type: application/json' --data-binary \
'{"mi_plan": {"marker_symbol": "Lcn2", "consortium_name": "DTCC",
"production_centre_name": "UCD"}}' \
'https://www.i-dcc.org/staging/imits/mi_plans.json'
{"priority_name":["cannot be blank"]}
Bob then corrects the problem and the request works:
$ curl --globoff --basic --user bob@ucdavis.edu:password -X POST \
-H 'Content-Type: application/json' --data-binary \
'{"mi_plan": {"marker_symbol": "Lcn2", "consortium_name": "DTCC",
"production_centre_name": "UCD", "priority_name": "High"}}' \
'https://www.i-dcc.org/staging/imits/mi_plans.json'
{
"id": 7769,
"status_name": "Inspect - Conflict",
"marker_symbol": "Lcn2",
"consortium_name": "DTCC",
"production_centre_name": "UCD"
}
Conflict resolution runs immediately. Bob wants to find out what the result of it was on some genes, and he did not have a chance to look at the return value of the previous update command:
$ curl --globoff --basic --user bob@ucdavis.edu:password -X GET \
'https://www.i-dcc.org/staging/imits/mi_plans.json?marker_symbol_in[]=Shb&marker_symbol_in[]=Lcn2'
[
{
"id": 7768,
"status_name": "Assigned",
"marker_symbol": "Lcn2",
"consortium_name": "BaSH",
"production_centre_name": "WTSI"
},
{
"id": 7769,
"status_name": "Inspect - Conflict",
"marker_symbol": "Lcn2",
"consortium_name": "DTCC",
"production_centre_name": "UCD"
},
{
"id": 7767,
"status_name": "Assigned",
"marker_symbol": "Shb",
"consortium_name": "BaSH",
"production_centre_name": "WTSI"
}
]
Sue and Bob then discuss Lcn2 and decide that it would be best if they did not duplicate effort on it, and that Bob's team should be the ones to work on the gene.
Sue withdraws her interest in the gene ( using the REST API instead of the website, for some reason):
$ curl --globoff --basic --user sue@sanger.ac.uk:password -X GET \
'https://www.i-dcc.org/staging/imits/mi_plans.json?marker_symbol_eq=Lcn2&production_centre_name_eq=WTSI'
[
{
"id": 7768,
"marker_symbol": "Lcn2",
"status_name": "Assigned"
}
]
$ curl --globoff --basic --user sue@sanger.ac.uk:password -X PUT \
-H 'Content-Type: application/json' --data-binary \
'{"mi_plan": {"withdrawn": true}}' \
'https://www.i-dcc.org/staging/imits/mi_plans/7768.json'
{
"id": 7768,
"marker_symbol": "Lcn2",
"status_name": "Withdrawn"
}
Conflict resolution runs immediately and assigns any gene plans that are the only active ones. Bob checks the status of his gene plan:
$ curl --globoff --basic --user bob@ucdavis.edu:password -X GET \
'https://www.i-dcc.org/staging/imits/mi_plans.json?marker_symbol_eq=Lcn2&production_centre_name_eq=UCD'
[
{
"id": 7769,
"status_name": "Assigned",
"marker_symbol": "Lcn2"
}
]
He now informs his team that they can start micro-injecting Lcn2 without any duplication of effort in the community.
MI attempts are manipulated via REST in exactly the same way as plans, except the URL is of course different and they have a different set of parameters, which can be found in the Reference.
Sue and Bob decide to create some micro-injection attempts for the genes they have been assigned:
$ curl --globoff --basic --user sue@sanger.ac.uk:password -X POST \
-H 'Content-Type: application/json' --data-binary \
'{"mi_attempt": {"es_cell_name": "HEPD0613_4_B05", "mi_plan_id": 7767,
"colony_name": "ZABC1", "mi_date": "2011-08-01",
"total_blasts_injected": 25, "comments": "Shb"}}' \
'https://www.i-dcc.org/staging/imits/mi_attempts.json'
{
"colony_name": "ZABC1",
"comments": "Shb",
"id": 5663,
"mi_date": "2011-08-01",
"mi_plan_id": 7767,
"total_blasts_injected": 25,
"status_name": "Micro-injection in progress",
"es_cell_name": "HEPD0613_4_B05",
"consortium_name": "BaSH",
"production_centre_name": "WTSI"
}
$ curl --globoff --basic --user bob@ucdavis.edu:password -X POST \
-H 'Content-Type: application/json' --data-binary \
'{"mi_attempt": {"es_cell_name": "EPD0889_5_D01", "mi_plan_id": 7769,
"colony_name": "YDEF2", "mi_date": "2011-08-05",
"total_blasts_injected": 30, "comments": "Lcn2"}}' \
'https://www.i-dcc.org/staging/imits/mi_attempts.json'
{
"colony_name": "YDEF2",
"comments": "Lcn2",
"id": 5664,
"mi_date": "2011-08-05",
"mi_plan_id": 7769,
"total_blasts_injected": 30,
"status_name": "Micro-injection in progress",
"es_cell_name": "EPD0889_5_D01",
"consortium_name": "DTCC",
"production_centre_name": "UCD"
}
Later, Bob wants to update his MI attempt to record that they have chimeras for it. He looks it up using its unique key, the colony name:
$ curl --globoff --basic --user bob@ucdavis.edu:password -X GET \
'https://www.i-dcc.org/staging/imits/mi_attempts.json?colony_name_eq=YDEF2'
[
{
"colony_name": "YDEF2",
"id": 5664,
"status_name": "Micro-injection in progress"
}
]
$ curl --globoff --basic --user bob@ucdavis.edu:password -X PUT \
-H 'Content-Type: application/json' --data-binary \
'{"mi_attempt": {"total_male_chimeras": 10}}' \
'https://www.i-dcc.org/staging/imits/mi_attempts/5664.json'
{
"colony_name": "YDEF2",
"id": 5664,
"total_male_chimeras": 10,
"status_name": "Chimeras obtained"
}
The line goes Genotype confirmed. Bob now wants to delete one of the existing distribution centres on it and set a start date on the other one:
$ curl --globoff --basic --user bob@ucdavis.edu:password -X GET \
'https://www.i-dcc.org/staging/imits/mi_attempts/5664.json'
{
"colony_name": "YDEF2",
"id": 5664,
"distribution_centres_attributes": [
{
"end_date": null,
"id": 1360,
"is_distributed_by_emma": true,
"start_date": null,
"deposited_material_name": "Frozen sperm",
"centre_name": "TCP",
"_destroy": false
},
{
"end_date": null,
"id": 1372,
"is_distributed_by_emma": true,
"start_date": null,
"deposited_material_name": "Frozen sperm",
"centre_name": "UCD",
"_destroy": false
}
]
}
He notes that the one he wants to destroy has the ID 1360 and the one he wants to edit has ID 1372.
$ curl --globoff --basic --user bob@ucdavis.edu:password -X PUT \
-H 'Content-Type: application/json' --data-binary \
'{"mi_attempt": {"distribution_centres_attributes": [ \
{"id": 1360, "_destroy": true},
{"id": 1372, "start_date": "2012-11-30"},
]}}' \
'https://www.i-dcc.org/staging/imits/mi_attempts/5664.json'
{
"colony_name": "YDEF2",
"id": 5664,
"distribution_centres_attributes": [
{
"end_date": null,
"id": 1372,
"is_distributed_by_emma": true,
"start_date": "2012-11-30",
"deposited_material_name": "Frozen sperm",
"centre_name": "UCD",
"_destroy": false
}
]
}
Later, he realises his mistake, and re-creates the deleted distribution centre. Note the lack of an ID in the new distribution centre's fields:
$ curl --globoff --basic --user bob@ucdavis.edu:password -X PUT \
-H 'Content-Type: application/json' --data-binary \
'{"mi_attempt": {"distribution_centres_attributes": [ \
{"is_distributed_by_emma": true, "deposited_material_name": "Frozen sperm", "centre_name": "TCP"}, \
]}}' \
'https://www.i-dcc.org/staging/imits/mi_attempts/5664.json'
{
"colony_name": "YDEF2",
"id": 5664,
"distribution_centres_attributes": [
{
"end_date": null,
"id": 1372,
"is_distributed_by_emma": true,
"start_date": null,
"deposited_material_name": "Frozen sperm",
"centre_name": "UCD",
"_destroy": false
},
{
"end_date": null,
"id":1406,
"is_distributed_by_emma": true,
"start_date": null,
"deposited_material_name": "Frozen sperm",
"centre_name": "TCP",
"_destroy": false
}
]
}
Phenotype attempts are manipulated via REST in exactly the same way as plans, except the URL is of course different and they have a different set of parameters, which can be found in the Reference.
Bob decides he wants to modify the allele of colony YDEF2 to produce a tm1b colony.
Bob looks up the mi_attempt for colony YDEF2 to check the status is "Genotype Confirmed"
{
"colony_name": "YDEF2",
"comments": "Lcn2",
"id": 5664,
"mi_date": "2011-08-05",
"mi_plan_id": 7769,
"total_blasts_injected": 30,
"status_name": "Genotype Confirmed",
"es_cell_name": "EPD0889_5_D01",
"consortium_name": "DTCC",
"production_centre_name": "UCD"
}
Bob then uses the mi_attempt's colony_name to register the intent to modify YDEF2 allele and phenotype the new tm1b colony.
{
$ curl --globoff --basic --user bob@ucdavis.edu:password -X POST \
-H 'Content-Type: application/json' --data-binary \
'{"phenotype_attempt": { "mi_attempt_colony_name": "YDEF2",
"colony_name": "YDEF2-cre", }}' \
'https://www.i-dcc.org/staging/imits/phenotype_attempts.json'
{
"id": 1021
"colony_name": "YDEF2-cre",
"mi_attempt_colony_name": "YDEF2",
"mi_plan_id": 7769,
"status_name":"Phenotype Attempt Registered",
"consortium_name": "DTCC",
"production_centre_name": "UCD"
"cre_excision_required":true
}
}
Bob then wants to indicate they have started cre excision on YDEF2-cre.
Bob looks up the phenotype_attempt
$ curl --globoff --basic --user bob@ucdavis.edu:password -X GET \
'https://www.i-dcc.org/staging/imits/phenotype_attempts.json?
colony_name_eq="YDEF2"'
[
{
"id": 1021
"colony_name": "YDEF2-cre",
"mi_attempt_colony_name": "YDEF2",
"mi_plan_id": 7769,
"status_name":"Phenotype Attempt Registered",
"consortium_name": "DTCC",
"production_centre_name": "UCD",
"cre_excision_required":true
}
]
and sets the deleter_strain_name and cre_excision_required
$ curl --globoff --basic --user bob@ucdavis.edu:password -X PUT \
-H 'Content-Type: application/json' --data-binary \
'{"phenotype_attempt": {"cre_excision_required":true, \
"deleter_strain_name":"MGI:3046308: Hprt<tm1(CMV-cre)Brd>"}}' \
'https://www.i-dcc.org/staging/imits/phenotype_attempts/1021.json'
{
"id": 1021
"colony_name": "YDEF2-cre",
"mi_attempt_colony_name": "YDEF2",
"mi_plan_id": 7769,
"status_name":"Cre Excision Started",
"consortium_name": "DTCC",
"production_centre_name": "UCD",
"cre_excision_required":true,
"deleter_strain_name":"MGI:3046308: Hprt<tm1(CMV-cre)Brd>"
}
Bob rejoices as he successful produces the tm1b colony and wants to communicated it to the world.
$ curl --globoff --basic --user bob@ucdavis.edu:password -X PUT \
-H 'Content-Type: application/json' --data-binary \
'{"phenotype_attempt": {"mouse_allele_type":"b", \
"colony_background_strain_name":"MGI:3046308: Hprt<tm1(CMV-cre)Brd>"}}' \
'https://www.i-dcc.org/staging/imits/phenotype_attempts/1021.json'
{
"id": 1021
"colony_name": "YDEF2-cre",
"mi_attempt_colony_name": "YDEF2",
"mi_plan_id": 7769,
"status_name":"Cre Excision Completed",
"consortium_name": "DTCC",
"production_centre_name": "UCD",
"cre_excision_required":true,
"deleter_strain_name":"MGI:3046308: Hprt<tm1(CMV-cre)Brd>",
"colony_background_strain_name":"MGI:3046308: Hprt<tm1(CMV-cre)Brd>",
"mouse_allele_type":"b"
}
Bob doesn't have the resources to phenotype the tm1b colony, but Bob and Sue make an agreement that she will do the phenotyping.
Sue finds the phenotype_attempt
$ curl --globoff --basic --user sue@sanger.ac.uk:password -X GET \
'https://www.i-dcc.org/staging/imits/phenotype_attempts.json?
colony_name_eq="YDEF2"'
[
{
"id": 1021
"colony_name": "YDEF2-cre",
"mi_attempt_colony_name": "YDEF2",
"mi_plan_id": 7769,
"status_name":"Phenotype Attempt Registered",
"consortium_name": "DTCC",
"production_centre_name": "UCD",
"cre_excision_required":true,
"phenotyping_productions_attributes":[{"id":3,"consortium_name":"DTCC","production_centre_name":"UCD", "colony_name":"YDEF2-cre", "phenotyping_experiments_started":"2013-04-07"}]
}
]
Sue makes a note of the phenotyping_productions id (3) and decides to re-assign this phenotyping production record to BaSH WTSI and change the colony_name to her colony bred up from colony YDEF2-cre.
$ curl --globoff --basic --user sue@sanger.ac.uk:password -X PUT \
-H 'Content-Type: application/json' --data-binary \
'{"phenotype_attempt": {phenotyping_productions_attributes": \
[{"id":3,"consortium_name":"BaSH","production_centre_name":"WTSI", "colony_name":"YDEF2-cre-BaSH"}]}}' \
'https://www.i-dcc.org/staging/imits/phenotype_attempts/1021.json'
{
"id": 1021
"colony_name": "YDEF2-cre",
"mi_attempt_colony_name": "YDEF2",
"mi_plan_id": 7769,
"status_name":"Phenotype Attempt Registered",
"consortium_name": "DTCC",
"production_centre_name": "UCD",
"cre_excision_required":true,
"phenotyping_productions_attributes":[{"id":3,"consortium_name":"BaSH","production_centre_name":"WTSI", "colony_name":"YDEF2-cre", "phenotyping_experiments_started":"2013-04-07"}]}
NB the id (value 3) of the phenotyping production is also included in the json. This results in the update of this record. If the id were to be left out a new phenotyping production record would be created.
Bob later decides he will also phenotype this colony to observe if any phenotyping anomalies occur due to the different mouse rearing systems in place at BaSH and UCD.
Bob shows his intention to phenotype colony_name by adding a new Phenotyping Production record and sets the phenotyping_experiments_started date.
$ curl --globoff --basic --user bob@ucdavis.edu:password -X PUT \
-H 'Content-Type: application/json' --data-binary \
'{"phenotype_attempt": {phenotyping_productions_attributes": \
[{"consortium_name":"DTCC","production_centre_name":"UCD", "colony_name":"YDEF2-cre-UCD", \
"phenotyping_experiments_started": "2014-05-01" }]}}' \
'https://www.i-dcc.org/staging/imits/phenotype_attempts/1021.json'
{
"id": 1021
"colony_name": "YDEF2-cre",
"mi_attempt_colony_name": "YDEF2",
"mi_plan_id": 7769,
"status_name":"Phenotype Attempt Registered",
"consortium_name": "DTCC",
"production_centre_name": "UCD",
"cre_excision_required":true,
"phenotyping_productions_attributes":[{"id":3,"consortium_name":"BaSH","production_centre_name":"WTSI", "colony_name":"YDEF2-cre-BaSH", "phenotyping_experiments_started":"2013-04-07"},
{"consortium_name":"DTCC","production_centre_name":"UCD", "colony_name":"YDEF2-cre-UCD", "phenotyping_experiments_started":"2014-05-01"}]}