loqusdb 2.7.11__py3-none-any.whl → 2.7.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. loqusdb/__init__.py +1 -1
  2. loqusdb/commands/export.py +4 -1
  3. {loqusdb-2.7.11.dist-info → loqusdb-2.7.13.dist-info}/METADATA +3 -2
  4. {loqusdb-2.7.11.dist-info → loqusdb-2.7.13.dist-info}/RECORD +7 -48
  5. {loqusdb-2.7.11.dist-info → loqusdb-2.7.13.dist-info}/WHEEL +1 -1
  6. README.md +0 -148
  7. tests/build_models/test_build_case.py +0 -150
  8. tests/build_models/test_build_variant.py +0 -15
  9. tests/build_models/test_is_greater.py +0 -49
  10. tests/commands/test_export.py +0 -16
  11. tests/commands/test_identity.py +0 -19
  12. tests/commands/test_view.py +0 -19
  13. tests/conftest.py +0 -438
  14. tests/fixtures/643594.clinical.SV.vcf +0 -178
  15. tests/fixtures/643594.clinical.vcf.gz +0 -0
  16. tests/fixtures/double_variant.vcf +0 -21
  17. tests/fixtures/funny_trio.ped +0 -4
  18. tests/fixtures/profile_snv.vcf +0 -47
  19. tests/fixtures/recessive_trio.ped +0 -4
  20. tests/fixtures/test.SV.vcf +0 -178
  21. tests/fixtures/test.vcf +0 -26
  22. tests/fixtures/test.vcf.gz +0 -0
  23. tests/fixtures/test.vcf.gz.tbi +0 -0
  24. tests/fixtures/unsorted.vcf +0 -20
  25. tests/functional/test_cli.py +0 -213
  26. tests/plugins/mongo/test_case_operations.py +0 -143
  27. tests/plugins/mongo/test_connect.py +0 -8
  28. tests/plugins/mongo/test_flask_extension.py +0 -27
  29. tests/plugins/mongo/test_get_sv.py +0 -27
  30. tests/plugins/mongo/test_load_svs.py +0 -74
  31. tests/plugins/mongo/test_variant_operations.py +0 -278
  32. tests/utils/test_case.py +0 -34
  33. tests/utils/test_delete.py +0 -73
  34. tests/utils/test_delete_family.py +0 -30
  35. tests/utils/test_delete_variant.py +0 -74
  36. tests/utils/test_get_family.py +0 -13
  37. tests/utils/test_load_database.py +0 -52
  38. tests/utils/test_load_family.py +0 -69
  39. tests/utils/test_load_variants.py +0 -225
  40. tests/utils/test_migrate.py +0 -38
  41. tests/utils/test_profiling.py +0 -68
  42. tests/vcf_tools/test_check_par.py +0 -67
  43. tests/vcf_tools/test_check_vcf.py +0 -64
  44. tests/vcf_tools/test_format_sv_variant.py +0 -102
  45. tests/vcf_tools/test_format_variant.py +0 -113
  46. tests/vcf_tools/test_vcf.py +0 -63
  47. {loqusdb-2.7.11.dist-info → loqusdb-2.7.13.dist-info}/LICENSE +0 -0
  48. {loqusdb-2.7.11.dist-info → loqusdb-2.7.13.dist-info}/entry_points.txt +0 -0
tests/conftest.py DELETED
@@ -1,438 +0,0 @@
1
- import logging
2
-
3
- import cyvcf2
4
- import pytest
5
-
6
- from loqusdb.build_models.case import build_case
7
- from loqusdb.build_models.variant import build_variant
8
- from loqusdb.log import init_log
9
- from loqusdb.models import Case
10
- from loqusdb.plugins.mongo.adapter import MongoAdapter
11
- from loqusdb.utils.load import update_case
12
- from mongomock import MongoClient as MockClient
13
- from ped_parser import FamilyParser
14
- from pymongo import MongoClient
15
-
16
- logger = logging.getLogger(".")
17
-
18
- init_log(logger, loglevel="DEBUG")
19
-
20
- REAL_DATABASE = "loqus-test"
21
- TEST_DATABASE = "test"
22
-
23
-
24
- class CyvcfVariant(object):
25
- """Mock a cyvcf variant
26
-
27
- Default is to return a variant with three individuals high genotype
28
- quality.
29
- """
30
-
31
- def __init__(
32
- self,
33
- chrom="1",
34
- pos=80000,
35
- ref="A",
36
- alt="C",
37
- end=None,
38
- gt_quals=[60, 60, 60],
39
- gt_types=[1, 1, 0],
40
- var_type="snv",
41
- var_id=None,
42
- info_dict={},
43
- ):
44
- super(CyvcfVariant, self).__init__()
45
- self.CHROM = chrom
46
- self.POS = pos
47
- self.REF = ref
48
- self.ALT = [alt]
49
- self.end = end or pos
50
- self.gt_quals = gt_quals
51
- self.gt_types = gt_types
52
- self.var_type = var_type
53
- self.INFO = info_dict
54
- if var_id is None:
55
- var_id = "."
56
- self.ID = var_id
57
-
58
-
59
- @pytest.fixture(scope="function")
60
- def real_db_name(request):
61
- """Return the name of the real mongo test db"""
62
- return REAL_DATABASE
63
-
64
-
65
- @pytest.fixture(scope="function")
66
- def mongo_client(request):
67
- """Return a mongomock client"""
68
- client = MockClient(directConnection=True)
69
- return client
70
-
71
-
72
- @pytest.fixture(scope="function")
73
- def real_mongo_client(request):
74
- """Return a mongomock client"""
75
- client = MongoClient(directConnection=True)
76
-
77
- def teardown():
78
- print("\n")
79
- logger.info("Deleting database")
80
- client.drop_database(REAL_DATABASE)
81
- logger.info("Database deleted")
82
-
83
- request.addfinalizer(teardown)
84
-
85
- return client
86
-
87
-
88
- @pytest.fixture(scope="function")
89
- def mongo_adapter(request, mongo_client):
90
- """Return a mongo adapter"""
91
- db_name = TEST_DATABASE
92
- adapter = MongoAdapter(mongo_client, db_name)
93
-
94
- return adapter
95
-
96
-
97
- @pytest.fixture(scope="function")
98
- def real_mongo_adapter(request, real_mongo_client):
99
- """Return a mongo adapter"""
100
- db_name = REAL_DATABASE
101
- adapter = MongoAdapter(real_mongo_client, db_name)
102
-
103
- return adapter
104
-
105
-
106
- @pytest.fixture(scope="function")
107
- def simplest_variant(request):
108
- variant = {
109
- "_id": "test",
110
- }
111
- return variant
112
-
113
-
114
- @pytest.fixture(scope="function")
115
- def homozygous_variant(request):
116
- variant = {"_id": "test", "homozygote": 1, "case_id": "1"}
117
- return variant
118
-
119
-
120
- @pytest.fixture(scope="function")
121
- def simple_case(request):
122
- case = Case("test", "./test.vcf")
123
-
124
- return case
125
-
126
-
127
- @pytest.fixture(scope="function")
128
- def vcf_path(request):
129
- file_path = "tests/fixtures/test.vcf"
130
- return file_path
131
-
132
-
133
- @pytest.fixture(scope="function")
134
- def sv_vcf_path(request):
135
- file_path = "tests/fixtures/test.SV.vcf"
136
- return file_path
137
-
138
-
139
- @pytest.fixture(scope="function")
140
- def double_vcf_path(request):
141
- "This will return a vcf with the same variant two times"
142
- file_path = "tests/fixtures/double_variant.vcf"
143
- return file_path
144
-
145
-
146
- @pytest.fixture(scope="function")
147
- def unsorted_vcf_path(request):
148
- "This will return a vcf with unsorted variants"
149
- file_path = "tests/fixtures/unsorted.vcf"
150
- return file_path
151
-
152
-
153
- @pytest.fixture(scope="function")
154
- def zipped_vcf_path(request):
155
- "Returns a VCF that is gzipped and have a index companion"
156
- file_path = "tests/fixtures/test.vcf.gz"
157
- return file_path
158
-
159
-
160
- @pytest.fixture(scope="function")
161
- def profile_vcf_path(request):
162
- "Returns a VCF containing profile variants"
163
- file_path = "tests/fixtures/profile_snv.vcf"
164
- return file_path
165
-
166
-
167
- @pytest.fixture(scope="function")
168
- def ped_path(request):
169
- file_path = "tests/fixtures/recessive_trio.ped"
170
- return file_path
171
-
172
-
173
- @pytest.fixture(scope="function")
174
- def funny_ped_path(request):
175
- "Returns a ped file with incorrect family relations"
176
- return "tests/fixtures/funny_trio.ped"
177
-
178
-
179
- @pytest.fixture(scope="function")
180
- def ind_positions(request):
181
- return {"proband": 0, "mother": 1, "father": 2}
182
-
183
-
184
- @pytest.fixture(scope="function")
185
- def case_lines(request, ped_path):
186
- """Return ped formated case lines"""
187
- case = []
188
- with open(ped_path, "r") as f:
189
- for line in f:
190
- case.append(line)
191
-
192
- return case
193
-
194
-
195
- @pytest.fixture(scope="function")
196
- def case_id(request, ped_path):
197
- """Return ped formated case lines"""
198
- case_id = None
199
- with open(ped_path, "r") as f:
200
- for line in f:
201
- case_id = line.split("\t")[0]
202
-
203
- return case_id
204
-
205
-
206
- @pytest.fixture(scope="function")
207
- def vcf_obj(request, vcf_path):
208
- """return a cyvcf2.VCF obj"""
209
- return cyvcf2.VCF(vcf_path)
210
-
211
-
212
- @pytest.fixture(scope="function")
213
- def sv_vcf_obj(request, sv_vcf_path):
214
- """return a cyvcf2.VCF obj"""
215
- return cyvcf2.VCF(sv_vcf_path)
216
-
217
-
218
- @pytest.fixture(scope="function")
219
- def profile_list(request):
220
- return ["AA", "CC", "GG", "TT"]
221
-
222
-
223
- @pytest.fixture(scope="function")
224
- def case_obj(request, case_lines, vcf_obj, vcf_path, profile_list):
225
- """Return a case obj"""
226
- family_parser = FamilyParser(case_lines, family_type="ped")
227
- families = list(family_parser.families.keys())
228
- family = family_parser.families[families[0]]
229
- vcf_individuals = vcf_obj.samples
230
- nr_variants = 0
231
- for nr_variants, variant in enumerate(vcf_obj, 1):
232
- continue
233
- return build_case(
234
- case=family,
235
- vcf_individuals=vcf_individuals,
236
- vcf_path=vcf_path,
237
- nr_variants=nr_variants,
238
- profiles={individual: profile_list for individual in vcf_individuals},
239
- )
240
-
241
-
242
- @pytest.fixture(scope="function")
243
- def sv_case_obj(request, case_lines, sv_vcf_obj, sv_vcf_path):
244
- """Return a case obj"""
245
- family_parser = FamilyParser(case_lines, family_type="ped")
246
- families = list(family_parser.families.keys())
247
- family = family_parser.families[families[0]]
248
- vcf_individuals = sv_vcf_obj.samples
249
- nr_variants = 0
250
- for nr_variants, variant in enumerate(sv_vcf_obj, 1):
251
- continue
252
- return build_case(
253
- case=family,
254
- sv_individuals=vcf_individuals,
255
- vcf_sv_path=sv_vcf_path,
256
- nr_sv_variants=nr_variants,
257
- )
258
-
259
-
260
- @pytest.fixture(scope="function")
261
- def complete_case_obj(request, case_obj, sv_case_obj):
262
- """Return a case obj with both sv and snv information"""
263
- return update_case(case_obj, sv_case_obj)
264
-
265
-
266
- @pytest.fixture(scope="function")
267
- def family_obj(request, case_lines):
268
- """Return a case obj"""
269
- family_parser = FamilyParser(case_lines, family_type="ped")
270
- families = list(family_parser.families.keys())
271
- return family_parser.families[families[0]]
272
-
273
-
274
- @pytest.fixture(scope="function")
275
- def case_id(request, case_lines):
276
- """Return a case id"""
277
- family_parser = FamilyParser(case_lines, family_type="ped")
278
- families = list(family_parser.families.keys())
279
- family = family_parser.families[families[0]]
280
- return family.family_id
281
-
282
-
283
- @pytest.fixture(scope="function")
284
- def individuals(request, case_obj):
285
- """Return a case obj"""
286
-
287
- return case_obj.individuals
288
-
289
-
290
- @pytest.fixture(scope="function")
291
- def two_cases(request):
292
- """Return ped formated case lines"""
293
- return [
294
- "#FamilyID\tSampleID\tFather\tMother\tSex\tPhenotype\n",
295
- "1\tproband\t0\t0\t1\t2\n",
296
- "2\tproband\t0\t0\t2\t1\n",
297
- ]
298
-
299
-
300
- ## Variant fixtures:
301
-
302
- # chrom='1',
303
- # pos=80000,
304
- # ref='A',
305
- # alt='C',
306
- # end=None,
307
- # gt_quals=[60, 60, 60],
308
- # gt_types=[1, 1, 0],
309
- # var_type='snv',
310
- # info_dict={}
311
-
312
- ### Variant objects
313
-
314
-
315
- @pytest.fixture(scope="function")
316
- def variant_obj(request, het_variant, ind_positions, individuals):
317
- return build_variant(
318
- variant=het_variant,
319
- individuals=individuals,
320
- ind_positions=ind_positions,
321
- case_id="test",
322
- gq_threshold=None,
323
- )
324
-
325
-
326
- ### CYVCF2 variants
327
- ### SNVs:
328
- @pytest.fixture(scope="function")
329
- def hem_variant(request):
330
- return CyvcfVariant(chrom="X", pos=60000)
331
-
332
-
333
- @pytest.fixture(scope="function")
334
- def variant_chr(request):
335
- return CyvcfVariant(chrom="chrX", pos=60000)
336
-
337
-
338
- @pytest.fixture(scope="function")
339
- def par_variant(request):
340
- return CyvcfVariant(chrom="X", pos=60001)
341
-
342
-
343
- @pytest.fixture(scope="function")
344
- def het_variant(request):
345
- return CyvcfVariant()
346
-
347
-
348
- @pytest.fixture(scope="function")
349
- def bnd_variant(request):
350
- return CyvcfVariant(
351
- chrom="1",
352
- pos=80000,
353
- alt="N[1:80000[",
354
- ref="N",
355
- end=80000,
356
- info_dict={"SVTYPE": "BND"},
357
- )
358
-
359
-
360
- @pytest.fixture(scope="function")
361
- def variant_no_gq(request):
362
- return CyvcfVariant(gt_quals=[-1, -1, -1])
363
-
364
-
365
- @pytest.fixture(scope="function")
366
- def hom_variant(request):
367
- return CyvcfVariant(gt_types=[3, 1, 1])
368
-
369
-
370
- @pytest.fixture(scope="function")
371
- def variant_no_call(request):
372
- return CyvcfVariant(gt_types=[2, 2, 2])
373
-
374
-
375
- ### SVs:
376
- @pytest.fixture(scope="function")
377
- def del_variant(request):
378
- return CyvcfVariant(
379
- chrom="1",
380
- ref="G",
381
- alt="<DEL>",
382
- pos=1285001,
383
- end=1287000,
384
- var_type="sv",
385
- info_dict={"END": 1287000, "SVLEN": -20000, "SVTYPE": "DEL"},
386
- )
387
-
388
-
389
- @pytest.fixture(scope="function")
390
- def small_insert_variant(request):
391
- return CyvcfVariant(
392
- chrom="1",
393
- ref="G",
394
- alt="GGGACGGGGGTTCTGAGATAAGCAAGCCCCCACCAGGTGAGACCGGCGGAGCTGTGGCCACCGAGGTCCCGGGAGCTGGTGCT",
395
- pos=3021145,
396
- end=3021145,
397
- var_type="sv",
398
- info_dict={"END": 3021145, "SVLEN": 82, "SVTYPE": "INS"},
399
- )
400
-
401
-
402
- @pytest.fixture(scope="function")
403
- def insertion_variant(request):
404
- return CyvcfVariant(
405
- chrom="1",
406
- ref="A",
407
- alt="<INS>",
408
- pos=3177306,
409
- end=3177306,
410
- var_type="sv",
411
- info_dict={"END": 3177306, "SVLEN": None, "SVTYPE": "INS"},
412
- )
413
-
414
-
415
- @pytest.fixture(scope="function")
416
- def duptandem_variant(request):
417
- return CyvcfVariant(
418
- chrom="1",
419
- ref="A",
420
- alt="<DUP:TANDEM>",
421
- pos=3092626,
422
- end=3092849,
423
- var_type="sv",
424
- info_dict={"END": 3092849, "SVLEN": 223, "SVTYPE": "DUP"},
425
- )
426
-
427
-
428
- @pytest.fixture(scope="function")
429
- def translocation_variant(request):
430
- return CyvcfVariant(
431
- chrom="1",
432
- ref="N",
433
- alt="N[11:119123896[",
434
- pos=3754913,
435
- end=3754913,
436
- var_type="sv",
437
- info_dict={"END": None, "SVLEN": None, "SVTYPE": "BND"},
438
- )