-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c08f9e
commit ab34b8f
Showing
11 changed files
with
308 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requests==2.19.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
API_BASE = 'http://localhost:8000' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import requests | ||
import json | ||
import unittest | ||
|
||
from constants_for_tests import * | ||
|
||
class TestClustering(unittest.TestCase): | ||
|
||
def test_clustering(self): | ||
url = API_BASE + '/clustering' | ||
payload = { | ||
"sources":["ICGC-BRCA-EU"], | ||
"signatures":[ | ||
"COSMIC 1", | ||
"COSMIC 2", | ||
"COSMIC 3", | ||
"COSMIC 5", | ||
"COSMIC 6", | ||
"COSMIC 8", | ||
"COSMIC 13", | ||
"COSMIC 17", | ||
"COSMIC 18", | ||
"COSMIC 20", | ||
"COSMIC 26", | ||
"COSMIC 30" | ||
] | ||
} | ||
r = requests.post(url, data=json.dumps(payload)) | ||
r.raise_for_status() | ||
res = r.json() | ||
self.assertEqual({'name', 'children'}, set(res.keys())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import requests | ||
import unittest | ||
|
||
from constants_for_tests import * | ||
|
||
class TestDataListing(unittest.TestCase): | ||
|
||
def test_data_listing(self): | ||
url = API_BASE + '/data-listing' | ||
r = requests.post(url) | ||
r.raise_for_status() | ||
res = r.json() | ||
self.assertEqual(['sources', 'sigs', 'sig_presets'], list(res.keys())) | ||
self.assertIn("ICGC-BRCA-EU", list(res['sources'].keys())) | ||
brca_obj = { | ||
"name": "Breast ER+ and HER2- Cancer - EU/UK", | ||
"num_donors": 569, | ||
"source": "ICGC", | ||
"has_clinical": True, | ||
"has_ssm": True, | ||
"has_counts": True | ||
} | ||
self.assertEqual(brca_obj, res['sources']['ICGC-BRCA-EU']) | ||
self.assertEqual({'name', 'description', 'index', 'publication'}, set(res['sigs'][0].keys())) | ||
self.assertEqual({'group', 'id', 'cancer-types'}, set(res['sig_presets'][0].keys())) | ||
self.assertEqual({'name', 'id', 'signatures'}, set(res['sig_presets'][0]['cancer-types'][0].keys())) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import requests | ||
import json | ||
import unittest | ||
|
||
from constants_for_tests import * | ||
|
||
class TestExposures(unittest.TestCase): | ||
|
||
def test_exposures(self): | ||
url = API_BASE + '/exposures' | ||
payload = { | ||
"sources": ["ICGC-BRCA-EU"], | ||
"signatures": [ | ||
"COSMIC 1", | ||
"COSMIC 2", | ||
"COSMIC 3", | ||
"COSMIC 4", | ||
"COSMIC 5", | ||
"COSMIC 6", | ||
"COSMIC 7", | ||
"COSMIC 8", | ||
"COSMIC 9", | ||
"COSMIC 10", | ||
"COSMIC 11", | ||
"COSMIC 12", | ||
"COSMIC 13", | ||
"COSMIC 14", | ||
"COSMIC 15", | ||
"COSMIC 16", | ||
"COSMIC 17", | ||
"COSMIC 18", | ||
"COSMIC 19", | ||
"COSMIC 20", | ||
"COSMIC 21", | ||
"COSMIC 22", | ||
"COSMIC 23", | ||
"COSMIC 24", | ||
"COSMIC 25", | ||
"COSMIC 26", | ||
"COSMIC 27", | ||
"COSMIC 28", | ||
"COSMIC 29", | ||
"COSMIC 30", | ||
"5* A" | ||
] | ||
} | ||
r = requests.post(url, data=json.dumps(payload)) | ||
r.raise_for_status() | ||
res = r.json() | ||
self.assertEqual(569, len(res)) | ||
self.assertEqual({'donor_id', 'proj_id', 'exposures', 'clinical'}, set(res[0].keys())) | ||
self.assertEqual(31, len(res[0]['exposures'])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import requests | ||
import json | ||
import unittest | ||
|
||
from constants_for_tests import * | ||
|
||
class TestExposuresSingleDonor(unittest.TestCase): | ||
|
||
def test_exposures_single_donor(self): | ||
url = API_BASE + '/exposures-single-donor' | ||
payload = { | ||
"donor_id": "DO220823", | ||
"proj_id": "ICGC-BRCA-EU", | ||
"sources":["PCAWG-BRCA-EU"], | ||
"signatures":[ | ||
"COSMIC 1", | ||
"COSMIC 2", | ||
"COSMIC 3", | ||
"COSMIC 4", | ||
"COSMIC 5", | ||
"COSMIC 6", | ||
"COSMIC 7", | ||
"COSMIC 8", | ||
"COSMIC 9", | ||
"COSMIC 10", | ||
"COSMIC 11", | ||
"COSMIC 12", | ||
"COSMIC 13", | ||
"COSMIC 14", | ||
"COSMIC 15", | ||
"COSMIC 16", | ||
"COSMIC 17", | ||
"COSMIC 18", | ||
"COSMIC 19", | ||
"COSMIC 20", | ||
"COSMIC 21", | ||
"COSMIC 22", | ||
"COSMIC 23", | ||
"COSMIC 24", | ||
"COSMIC 25", | ||
"COSMIC 26", | ||
"COSMIC 27", | ||
"COSMIC 28", | ||
"COSMIC 29", | ||
"COSMIC 30", | ||
"5* A" | ||
] | ||
} | ||
r = requests.post(url, data=json.dumps(payload)) | ||
r.raise_for_status() | ||
res = r.json() | ||
self.assertEqual(1, len(res)) | ||
self.assertEqual({'donor_id', 'proj_id', 'exposures', 'clinical'}, set(res[0].keys())) | ||
self.assertEqual(31, len(res[0]['exposures'])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import requests | ||
import json | ||
import unittest | ||
|
||
from constants_for_tests import * | ||
|
||
class TestKataegis(unittest.TestCase): | ||
|
||
def test_kataegis(self): | ||
url = API_BASE + '/kataegis' | ||
|
||
payload = { | ||
"sources":[ | ||
"ICGC-BRCA-EU" | ||
] | ||
} | ||
r = requests.post(url, data=json.dumps(payload)) | ||
r.raise_for_status() | ||
res = r.json() | ||
self.assertEqual(569, len(res.keys())) | ||
self.assertEqual(4, len(res['DO217786']['kataegis']['1'])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import requests | ||
import json | ||
import csv | ||
import unittest | ||
|
||
from constants_for_tests import * | ||
|
||
class TestRainfall(unittest.TestCase): | ||
|
||
def test_rainfall(self): | ||
url = API_BASE + '/kataegis-rainfall' | ||
|
||
payload = { | ||
"proj_id": "ICGC-BRCA-EU", | ||
"donor_id": "DO217786" | ||
} | ||
r = requests.post(url, data=json.dumps(payload)) | ||
r.raise_for_status() | ||
decoded_content = r.content.decode('utf-8') | ||
|
||
res = list(csv.reader(decoded_content.splitlines(), delimiter=',')) | ||
self.assertEqual({'chr', 'pos', 'cat', 'cat_index', 'mut_dist', 'kataegis'}, set(res[0])) | ||
|
||
self.assertEqual(3107, len(res)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import requests | ||
import json | ||
import unittest | ||
|
||
from constants_for_tests import * | ||
|
||
class TestSamplesWithSignatures(unittest.TestCase): | ||
|
||
def test_samples_with_signatures(self): | ||
url = API_BASE + '/samples-with-signatures' | ||
|
||
payload = { | ||
"sources":["ICGC-BRCA-EU"], | ||
"signatures":[ | ||
"COSMIC 1", | ||
"COSMIC 2", | ||
"COSMIC 3", | ||
"COSMIC 4", | ||
"COSMIC 5", | ||
"COSMIC 6", | ||
"COSMIC 7", | ||
"COSMIC 8", | ||
"COSMIC 9", | ||
"COSMIC 10", | ||
"COSMIC 11", | ||
"COSMIC 12", | ||
"COSMIC 13", | ||
"COSMIC 14", | ||
"COSMIC 15", | ||
"COSMIC 16", | ||
"COSMIC 17", | ||
"COSMIC 18", | ||
"COSMIC 19", | ||
"COSMIC 20", | ||
"COSMIC 21", | ||
"COSMIC 22", | ||
"COSMIC 23", | ||
"COSMIC 24", | ||
"COSMIC 25", | ||
"COSMIC 26", | ||
"COSMIC 27", | ||
"COSMIC 28", | ||
"COSMIC 29", | ||
"COSMIC 30", | ||
"5* A" | ||
] | ||
} | ||
r = requests.post(url, data=json.dumps(payload)) | ||
r.raise_for_status() | ||
res = r.json() | ||
|
||
self.assertEqual({'signatures', 'projects'}, set(res.keys())) | ||
self.assertEqual(31, len(list(res['signatures'].keys()))) | ||
self.assertEqual(569, res['projects']['ICGC-BRCA-EU']) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import requests | ||
import json | ||
import unittest | ||
|
||
from constants_for_tests import * | ||
|
||
class TestSignature(unittest.TestCase): | ||
|
||
def test_signature(self): | ||
url = API_BASE + '/signature' | ||
|
||
payload = { | ||
"signature": "COSMIC 1" | ||
} | ||
r = requests.post(url, data=json.dumps(payload)) | ||
r.raise_for_status() | ||
res = r.json() | ||
|
||
self.assertEqual({'data', 'meta'}, set(res.keys())) | ||
self.assertEqual(96, len(res['data'])) | ||
self.assertEqual(["A[C>A]A", 0.011098326], res['data'][0]) | ||
|
||
self.assertEqual({'name', 'description', 'index', 'publication'}, set(res['meta'].keys())) | ||
|
||
def test_another_signature(self): | ||
url = API_BASE + '/signature' | ||
|
||
payload = { | ||
"signature": "COSMIC 2" | ||
} | ||
r = requests.post(url, data=json.dumps(payload)) | ||
r.raise_for_status() | ||
res = r.json() | ||
|
||
self.assertEqual(["A[C>A]A", 0.0006827080000000001], res['data'][0]) |