Legacy API Docs. These docs are for Virtool 4.3.3.

Samples

Find

Find samples based on the sample name or creator username.

GET
/api/samples

Parameters

NameTypeDefaultDescription
findstringsample name or username to filter by
pageinteger1page number of results to return
per_pageinteger15number of documents to return per page

Example

GET /api/samples?find=test&page=1

Response

Status: 200 OK

{
  "documents": [
    {
      "name": "Test 1",
      "isolate": "",
      "host": "",
      "nuvs": true,
      "pathoscope": true,
      "created_at": "2018-02-01T00:29:44.867000Z",
      "imported": false,
      "archived": false,
      "user": {
        "id": "igboyes"
      },
      "id": "htosefxu"
    }
  ],
  "total_count": 1,
  "found_count": 1,
  "page_count": 1,
  "per_page": 15,
  "page": 1
}

Errors

StatusMessageReason
422Invalid queryinvalid URL query fields or values

Get

Requires read permission on reference

Get the complete representation of a sample.

GET
/api/samples/:id

Example

GET /api/samples/htosefxu

Response

Status: 200 OK

{
	"name": "Test 1",
	"isolate": "",
	"host": "",
	"locale": "",
	"subtraction": {
		"id": "Arabidopsis"
	},
	"files": [
		"jekfyjur-S00196E_AGTCAA_L007_R1.fq"
	],
	"group": "none",
	"nuvs": true,
	"pathoscope": true,
	"created_at": "2018-02-01T00:29:44.867000Z",
	"format": "fastq",
	"imported": false,
	"quality": {
		"count": 2086040,
		"encoding": "Sanger / Illumina 1.9\n",
		"length": [
			50,
			101
		],
		"gc": 49.0,
		"bases": [
			[32, 34, 33, 34, 31, 34], ...
        ],
		"sequences": [
			0, ...
        ],
		"composition": [
			[27, 14, 12, 45], ...
        ]
	},
	"analyzed": false,
	"hold": true,
	"archived": false,
	"group_read": true,
	"group_write": false,
	"all_read": true,
	"all_write": false,
	"user": {
		"id": "igboyes"
	},
	"id": "htosefxu"
}

Errors

StatusMessageReason
403Insufficient rightsclient does not have the required rights to read the sample
404Not foundsample_id in URL does not exist

Create

Requires create_sample permission

Creates a sample record and starts a job that populates the record from a FASTQ file stored in the file manager.

The array of files must contain only one or two items. Samples with arrays containing one item will be assumed to by derived from single-end libraries, while arrays with two items will correspond to paired-end libraries.

POST
/api/samples

Input

NameTypeRequiredDescription
namestringtruea unique name for the sample
hoststringfalsethe exact (not subtraction) host
isolatestringfalsethe originating isolate
localestringfalsethe location in which the sample was collected
subtractionstringtruethe id of a previously imported subtraction genome
filesarraytrueids of previously uploaded files

Example

POST /api/samples

{
  "name": "Test A",
  "host": "Tree",
  "isolate": "Isolate A-1",
  "locale": "Earth",
  "subtraction": "Arabidopsis",
  "files": ["sibvzhqc-S00196E_AGTCAA_L007_R1.fq"]
}

Response

Status: 201 Created

{
  "name": "Test A",
  "host": "Tree",
  "isolate": "Isolate A-1",
  "locale": "Earth",
  "subtraction": {
    "id": "Arabidopsis"
  },
  "files": ["sibvzhqc-S00196E_AGTCAA_L007_R1.fq"],
  "group": "none",
  "nuvs": false,
  "pathoscope": false,
  "created_at": "2018-02-07T00:25:53.786000Z",
  "format": "fastq",
  "imported": "ip",
  "quality": null,
  "analyzed": false,
  "hold": true,
  "archived": false,
  "group_read": true,
  "group_write": false,
  "all_read": true,
  "all_write": false,
  "user": {
    "id": "igboyes"
  },
  "id": "oggjipxw"
}

Errors

StatusMessageReason
400File does not existthe provided file_id does not exist
400Group does not existgroup in POST body does not exist
400Group value required for sample creationthe server is configured to required group assignment of samples on creation
400Sample name is already in usethe provided name is already assigned to an existing sample
400Subtraction does not existsubtraction in POST body does not exist
403Not permittedclient does not have the create_sample permission
422Invalid inputJSON request body is invalid

Edit

Requires write permission on reference

Update modifiable fields of a sample.

PATCH
/api/samples/:id

Input

NameTypeDescription
namestringthe sample name
hoststringthe exact (not subtraction) host
isolatestringthe originating isolate
localestringthe location in which the sample was collected

Example

PATCH /api/samples/oggjipxw

{
  "name": "Test A",
  "host": "Vine",
  "isolate": "Isolate A1",
  "locale": ""
}

Response

Status: 200 OK

{
  "name": "Test A",
  "host": "Vine",
  "isolate": "Isolate A1",
  "nuvs": false,
  "pathoscope": false,
  "created_at": "2018-02-07T00:25:53.786000Z",
  "imported": false,
  "archived": false,
  "user": {
    "id": "igboyes"
  },
  "id": "oggjipxw"
}

Errors

StatusMessageReason
400Sample name is already in usethe provided name is already assigned to an existing sample
403Insufficient rightsclient does not have the required rights to edit the sample
404Not foundsample_id in URL does not exist
422Invalid inputrequest body JSON failed validation

Edit Rights

Role Administrator or Owner

Edit the access rights for a sample.

PATCH
/api/samples/:id/rights

Input

NameTypeDescription
groupstringthe owner group_id
group_readbooleangroup can read sample
group_writebooleangroup can modify sample
all_readbooleanall users can read sample
all_writebooleanall users can modify sample

Example

PATCH /api/samples/oggjipxw/rights

{
  "group": "administrator",
  "group_read": true,
  "group_write": true
}

Response

Status: 200 OK

{
  "group": "administrator",
  "group_read": true,
  "group_write": true,
  "all_read": true,
  "all_write": false
}

Errors

StatusMessageReason
400Group does not existuser group does not exist in instance
403Must be administrator or sample owneruser is neither the sample owner nor an administrator
404Not foundsample_id in URL does not exist
422Invalid inputrequest body JSON failed validation

Replace Files

Requires write permission on reference

Replace old trimmed files with original raw files.

Remove

Role Administrator or Owner

Remove an existing sample record and its associated data files.

DELETE
/api/samples/:id

Example

DELETE /api/samples/oggjipxw

Response

Status: 204 No Content

 

Errors

StatusMessageReason
403Insufficient rightsclient does not have the required rights to remove the sample
404Not foundsample_id in URL does not exist

List Analyses

Requires read permission on reference

Retrieve a summary list of analyses associated with a sample.

Returned documents do not include diagnostic data. Use the analyses endpoints for more extensive modification and querying of analysis data.

GET
/api/samples/:id/analyses

Example

GET /api/samples/htosefxu/analyses

Response

Status: 200 OK

{
  "total_count": 2,
  "documents": [
    {
      "ready": true,
      "created_at": "2018-02-06T19:32:59.533000Z",
      "job": {
        "id": "khjhwnlf"
      },
      "algorithm": "nuvs",
      "sample": {
        "id": "htosefxu",
        "name": "Test 1"
      },
      "index": {
        "id": "jiwncaqr",
        "version": 0
      },
      "user": {
        "id": "igboyes"
      },
      "id": "yzgqgbld"
    },
    {
      "ready": true,
      "created_at": "2018-02-06T22:15:37.411000Z",
      "job": {
        "id": "dqswirty"
      },
      "algorithm": "pathoscope_bowtie",
      "sample": {
        "id": "htosefxu",
        "name": "Test 1"
      },
      "index": {
        "id": "bznqwjsa",
        "version": 1
      },
      "user": {
        "id": "igboyes"
      },
      "id": "xfvpxvwi"
    }
  ]
}

Errors

StatusMessageReason
403Insufficient rightsclient does not have the required rights to view the sample analyses
404Not foundsample_id in URL does not exist

Analyze

Requires write permission on reference

Immediately create and placeholder analysis record for a sample and start an analysis job. When the job succeeds the analysis document will be populated.

POST
/api/samples/:id/analyses

Input

NameTypeRequiredDescription
algorithmstringTruethe algorithm name (eg. pathoscope_bowtie)
ref_idstringTruethe reference to run the analysis against

Example

POST /api/samples/htosefxu/analyses

{
  "algorithm": "pathoscope_bowtie",
  "ref_id": "foo"
}

Response

Status: 201 Created

{
  "ready": false,
  "created_at": "2018-02-07T17:50:44.508000Z",
  "job": {
    "id": "kizfvroe"
  },
  "algorithm": "pathoscope_bowtie",
  "sample": {
    "id": "htosefxu"
  },
  "index": {
    "id": "bznqwjsa",
    "version": 1
  },
  "user": {
    "id": "igboyes"
  },
  "id": "fbzypgva"
}

Errors

StatusMessageReason
400Reference does not existspecified ref_id not found
400No index is ready for the referencethe reference doesn’t have a built index ready for analysis
403Insufficient rightsclient does not have the required rights to create a new analysis for the sample
404Not foundsample_id in URL does not exist
422Invalid inputthe JSON request body is invalid