- We assume that you completed first tutorial API
Quickstart and that you have:
- Access token stored in
ACCESS_TOKENenvironment variable - Created Sample object and stored sample ID in
SAMPLE_IDenvironment variable
- Access token stored in
In order to add genetic data to an existing Sample you need to create Genotype object linked to the Sample.
In this guide we will create Genotype object from a genetic file that was previously imported into PBS (see Working with genetic files for more details on importing genetic files ).
Lets assume that we have genotype file available in PBS:
GENOTYPE_FILE_PATH="genotypes/genotype_user1040.txt"
First we need to find object_uri of given PBS object by invoking
Get File Details
operation.
curl --request GET \
--url https://myportal.lifenome.com/api/core-api/files/file/${GENOTYPE_FILE_PATH}/ \
--header "Authorization: Bearer ${ACCESS_TOKEN}"Response:
{
"name": "string",
"object_uri": "string",
"content_type": "string",
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"size": 0,
"md5_hash": "string",
"crc32c": "string",
"etag": "string",
"metadata": null
}Then you need to create Genotype object for SAMPLE_ID and PBS object (with
object_uri obtained from response above) with we need to invoke
Create
Genotype operation.
curl --request PUT \
--url https://myportal.lifenome.com/api/core-api/samples/${SAMPLE_ID}/genotype/ \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--data "{\"source_uri\": \"${OBJECT_URI}\"}"Also object_uri can be fetched this way in case you have jq installed:
OBJECT_URI=$(curl --request GET \
--url https://myportal.lifenome.com/api/core-api/files/file/${DEST_PATH}/ \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
| jq -r .object_uri)After the genotype is created you can fetch current details about the genotype
(current state, state history and other details) by invoking Get
Genotype operation.
curl --request GET \
--url "https://myportal.lifenome.com/api/core-api/samples/${SAMPLE_ID}/" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${ACCESS_TOKEN}"Current state is stored in the state property of the genotype object:
{
"id": "312235f8-...-c8b71648471d",
"assembly": "grch37",
"source_uri": "string",
"source_blob_metadata": null,
"state": "available",
"state_history": [
{
"state": "not-available",
"is_active": false,
"created_at": "2019-08-24T14:15:22Z"
},
{
"state": "not-available",
"is_active": true,
"created_at": "2019-08-24T14:15:24Z"
}
],
"created_at": "2019-08-24T14:15:22Z"
}At this poing genotype is created with valid data source and the state of the
genotype transitions to available state.
Next, genotype data stored in the file is automatically validated.
If a valid genotype file is uploaded, the state of genotype transitions to data-valid:
Finally, when uploaded file is completely processed, state will be processed:
As mentioned before, if provided genotype file is not recognized, state will
be data-invalid. See Supported Genetic Files for more
information about what kind of files with genotype data are supported.