From c413091941f47d34c56631e0347509e8cad4510c Mon Sep 17 00:00:00 2001 From: Daisie Huang Date: Fri, 28 Oct 2022 10:55:58 -0700 Subject: [PATCH] add tests for multisample --- data/files/multisample_1.vcf.gz | Bin 0 -> 914 bytes data/files/multisample_1.vcf.gz.tbi | Bin 0 -> 127 bytes data/files/multisample_2.vcf.gz | Bin 0 -> 924 bytes data/files/multisample_2.vcf.gz.tbi | Bin 0 -> 127 bytes tests/test_htsget_server.py | 175 +++++++++++++++++++++++++++- 5 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 data/files/multisample_1.vcf.gz create mode 100644 data/files/multisample_1.vcf.gz.tbi create mode 100644 data/files/multisample_2.vcf.gz create mode 100644 data/files/multisample_2.vcf.gz.tbi diff --git a/data/files/multisample_1.vcf.gz b/data/files/multisample_1.vcf.gz new file mode 100644 index 0000000000000000000000000000000000000000..99ca7a1b6fe034a9e680b36617cffac614ebff5d GIT binary patch literal 914 zcmV;D18w{tiwFb&00000{{{d;LjnMG1FcqTZ=*OA{Y-y_HC44!4NVOReb8m4D1=O; zv`K+hyB|H^G}aJ1W1GzO-|sa^It}q?Guo99fdfAGocl02J)N_P&V^hO9X$_{b+6-{ zoSr7*Nj^-Y-^Xz@>t~r8Q&mW|(oFE^L%*sJtkP5}v?5B;^1~mnMu}P$GuPYjjxu!2v?(^nClM0n|r58xd(YKmZOuwQpL{Zg5c;m~a z_x*f4*pcE5X;P7wea0~_SwS>ah|Q6tg^(p;3K66P_+q@p0>!ViLTNT_6MK<82{-;A#=)}*TGe$dhExfL|21kw936Q&ka z{-)6IZ&GNKQ>D>t!)B78>!pyNxM`>gt)WFAH(b2s209Jx5`sWx)voOSCE-WxMu~~L z&DJI4{$1#It**56@P4QXRSM|^;mE^hreI5x=?1tpz>lh{dbJW#Lye%*NC_Rm;h@kT zlJK$}it&jvVI($H%#Y}t z5#>U|!-K_-$4u&OHG164Xq)A@c~8L(ip{vU*QfC@>*L){A$QYu@vaEXwt+r2IrGlj z5&FLtVO!*%@%sn-Njhw2(pHA&ZSz1kQW)8}q~B^VVo7N4nC+lxwWdu_A!@EwXmWEo z|6aPyg`{iOc-bK40+1$FA-HBQO{`)8Q((b73+7v}t_AB^u)u;{S+Hvhc4NVAE!ZLC zTdeuE_bk>dkj1RUtHr9tsl}+pr^V*|A@t`V^cO&b&*}8unN2fi96RYSar%?od3@?m zoXy_kn2p%kG@kQdekM--bU#f`nlw29?&2WuoQ~6X25>fi4xD%vc^KbqKgxGm7Wr@* zMBO|1phVss?CBBi1Q=syl!v3oFrI~J9QNbTObOie9DIqxP8bB{z#%>h{lN8lE_N|I z^5D@eHisYj9sl|)?A^HC8`pEace1X!H;t_P-(>avi>zxGj<&2W$O?KO>)O3Cviy^O o09Uy!p;rk203VA81ONa4009360763o02=@U000000000001C3ghyVZp literal 0 HcmV?d00001 diff --git a/data/files/multisample_1.vcf.gz.tbi b/data/files/multisample_1.vcf.gz.tbi new file mode 100644 index 0000000000000000000000000000000000000000..3be879302756f8d1ae13083d4e9e099c168681c2 GIT binary patch literal 127 zcmb2|=3rp}f&Xj_PR>jWNetYDpHfm%5)u-ak|cPUP6f>3?U-!b)x&ep$n=mv=q#Cl z%r>JmftRM7i-cok(xiB17${xoxwQC;hOJjWjB0LfV`TWXvQa^bi-AEN%?fD-X0VMQ F0sxlnBc}iW literal 0 HcmV?d00001 diff --git a/data/files/multisample_2.vcf.gz b/data/files/multisample_2.vcf.gz new file mode 100644 index 0000000000000000000000000000000000000000..6f30a8312b5099813d40e6917cf7963874f1f035 GIT binary patch literal 924 zcmV;N17rLjiwFb&00000{{{d;LjnMQ1FcqVZ`wK-{ha*@YgM&XH>G){G+ibkLKqS) zG)b$wk6vPmwO}*bVe7xYPXe?MJc(%+PzWdSdCqxW9L~<>v?OybmRN;PgLv(A?008p z@pzIAlkn3x3TOQ^H6tQ(L05`$7QXM7C4yCo2#Ho$N>aT43~MB>L{7pdEYch^2axf7 zJZ(6lnR#C=zY!7IX7;io;g~7%OvE8?#uYA6K~`#k_#FMHa7on*`i3QuO@vpzbb8m% z#)BQHwIPj5{CvnbW(Cc$A`;O#5+vuMKvW`(BnQ7VN6Sj#`qmbG+LD_pL0OAC-BL(k zsAMg8jRnO_p^sLWkU0^A<;1kZ5fRIhGGaR6c8%$Vlj#=|ae@5sk$q?UC%b4%82pI_ za7GYiXtofffSE_pld+qf-hf1f7Np=m-WM0{tN{ zE83wbD@ZvMg12U1Lcf#p1z{kX*WL=Sq&RAB-|}Jw@u7=XT+-Lxji(8W#HNbb37s<{ zj4QZ!wD{qaN!_hR51Scnvz#{X3D`kVJ?`!GNp#BkXtz^{-Lzfq6`|QS(8nfc_C-5F z|IZ?9i~Ku&=ZHT}hV4x1%J8&p9_U5_BRd!5M+HVS3H46d4w_bL+63jiVoC;eZm#A( z3$r;9WNp@7Hb{K}NE0jPOws2iR=$8K&|tO(b2ON%!8{G-Yp|{cyVhVm4R)i!jv+^5 z&C%Vbv8I7EW;I?lRy9sFMm0V)Ht&w1e~+QB01dt*(>r4}O^tD6B*WO~Pcq}-u|F|3 zdy`Rb#KxxajQjd)Vq}kZ)8t)~Cd0Q}tLI%C9V0XPaIF6v7||@e?%i&m$+u}5I&c_- z?kzk|Li-lB^w8?~7QBp67K|Q(Xci<<(2s(8O5m4gSXWli2^=qQdw~^L=K<`)PS>zJ->!uw5@ZTl_=8X1E<{eiwFb&00000{{{d;LjnLB00RI3000000000ah^N8; literal 0 HcmV?d00001 diff --git a/data/files/multisample_2.vcf.gz.tbi b/data/files/multisample_2.vcf.gz.tbi new file mode 100644 index 0000000000000000000000000000000000000000..ffdd43f950080262a5419d7135d0c6f403a97242 GIT binary patch literal 127 zcmb2|=3rp}f&Xj_PR>jWNetYDpHfm%5)u-ak|cPUP6f>3?U-!b)x&ep$n=mv=q#Cl z%r>?(ftRM7i-cok(xiB17${xoxwQC;hOJjWjB0LfV`Nw#nwBcX#lRqsW`#5ZGuTED F0RVY?BL)Bf literal 0 HcmV?d00001 diff --git a/tests/test_htsget_server.py b/tests/test_htsget_server.py index 9e326e63..9a6011dc 100644 --- a/tests/test_htsget_server.py +++ b/tests/test_htsget_server.py @@ -78,7 +78,7 @@ def test_post_update(): def test_index_variants(): - return [('sample.compressed'), ('NA18537'), ('NA20787')] + return [('sample.compressed'), ('NA18537'), ('NA20787'), ('multisample_1'), ('multisample_2')] @pytest.mark.parametrize('sample', test_index_variants()) @@ -253,6 +253,33 @@ def test_search_snp(): print(response.text) assert len(response.json()["results"]) == 1 + +def test_multisamples(): + return [ + ({ + 'regions': [ + { + 'referenceName': 'chr21', + 'start': 5030000, + 'end': 5032000 + } + ] + }, 2) + ] + + +@pytest.mark.parametrize('body, count', test_multisamples()) +# The two multisample files both have two identically-named samples in them: +# both files should return two samples +def test_multisample(body, count): + url = f"{HOST}/htsget/v1/variants/search" + + response = requests.post(url, json=body, headers=headers) + print(response.text) + for result in response.json()["results"]: + assert len(result['samples']) == count + + @pytest.fixture def drs_objects(): return [ @@ -329,6 +356,152 @@ def drs_objects(): "updated_time": "2021-09-27T18:40:00.539022", "version": "v1" }, + { + "access_methods": [ + { + "access_url": { + "headers": [], + "url": f"file://{CWD}/data/files/multisample_1.vcf.gz.tbi" + }, + "type": "file" + } + ], + "aliases": [], + "checksums": [], + "created_time": "2021-09-27T18:40:00.538843", + "description": "", + "id": "multisample_1.vcf.gz.tbi", + "mime_type": "application/octet-stream", + "name": "multisample_1.vcf.gz.tbi", + "self_uri": "drs://localhost/multisample_1.vcf.gz.tbi", + "size": 0, + "updated_time": "2021-09-27T18:40:00.539022", + "version": "v1" + }, + { + "access_methods": [ + { + "access_url": { + "headers": [], + "url": f"file://{CWD}/data/files/multisample_1.vcf.gz" + }, + "type": "file" + } + ], + "aliases": [], + "checksums": [], + "created_time": "2021-09-27T18:40:00.538843", + "description": "", + "id": "multisample_1.vcf.gz", + "mime_type": "application/octet-stream", + "name": "multisample_1.vcf.gz", + "self_uri": "drs://localhost/multisample_1.vcf.gz", + "size": 0, + "updated_time": "2021-09-27T18:40:00.539022", + "version": "v1" + }, + { + "aliases": [], + "checksums": [], + "contents": [ + { + "drs_uri": [ + "drs://localhost/multisample_1.vcf.gz" + ], + "name": "multisample_1.vcf.gz", + "id": "variant" + }, + { + "drs_uri": [ + "drs://localhost/multisample_1.vcf.gz.tbi" + ], + "name": "multisample_1.vcf.gz.tbi", + "id": "index" + } + ], + "created_time": "2021-09-27T18:40:00.538843", + "description": "", + "id": "multisample_1", + "mime_type": "application/octet-stream", + "name": "multisample_1", + "self_uri": "drs://localhost/multisample_1", + "size": 0, + "updated_time": "2021-09-27T18:40:00.539022", + "version": "v1" + }, + { + "access_methods": [ + { + "access_url": { + "headers": [], + "url": f"file://{CWD}/data/files/multisample_2.vcf.gz.tbi" + }, + "type": "file" + } + ], + "aliases": [], + "checksums": [], + "created_time": "2021-09-27T18:40:00.538843", + "description": "", + "id": "multisample_2.vcf.gz.tbi", + "mime_type": "application/octet-stream", + "name": "multisample_2.vcf.gz.tbi", + "self_uri": "drs://localhost/multisample_2.vcf.gz.tbi", + "size": 0, + "updated_time": "2021-09-27T18:40:00.539022", + "version": "v1" + }, + { + "access_methods": [ + { + "access_url": { + "headers": [], + "url": f"file://{CWD}/data/files/multisample_2.vcf.gz" + }, + "type": "file" + } + ], + "aliases": [], + "checksums": [], + "created_time": "2021-09-27T18:40:00.538843", + "description": "", + "id": "multisample_2.vcf.gz", + "mime_type": "application/octet-stream", + "name": "multisample_2.vcf.gz", + "self_uri": "drs://localhost/multisample_2.vcf.gz", + "size": 0, + "updated_time": "2021-09-27T18:40:00.539022", + "version": "v1" + }, + { + "aliases": [], + "checksums": [], + "contents": [ + { + "drs_uri": [ + "drs://localhost/multisample_2.vcf.gz" + ], + "name": "multisample_2.vcf.gz", + "id": "variant" + }, + { + "drs_uri": [ + "drs://localhost/multisample_2.vcf.gz.tbi" + ], + "name": "multisample_2.vcf.gz.tbi", + "id": "index" + } + ], + "created_time": "2021-09-27T18:40:00.538843", + "description": "", + "id": "multisample_2", + "mime_type": "application/octet-stream", + "name": "multisample_2", + "self_uri": "drs://localhost/multisample_2", + "size": 0, + "updated_time": "2021-09-27T18:40:00.539022", + "version": "v1" + }, { "access_methods": [ {