loqusdb 2.7.11__py3-none-any.whl → 2.7.12__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.
- loqusdb/__init__.py +1 -1
- loqusdb/commands/export.py +4 -1
- {loqusdb-2.7.11.dist-info → loqusdb-2.7.12.dist-info}/METADATA +3 -2
- {loqusdb-2.7.11.dist-info → loqusdb-2.7.12.dist-info}/RECORD +7 -48
- {loqusdb-2.7.11.dist-info → loqusdb-2.7.12.dist-info}/WHEEL +1 -1
- README.md +0 -148
- tests/build_models/test_build_case.py +0 -150
- tests/build_models/test_build_variant.py +0 -15
- tests/build_models/test_is_greater.py +0 -49
- tests/commands/test_export.py +0 -16
- tests/commands/test_identity.py +0 -19
- tests/commands/test_view.py +0 -19
- tests/conftest.py +0 -438
- tests/fixtures/643594.clinical.SV.vcf +0 -178
- tests/fixtures/643594.clinical.vcf.gz +0 -0
- tests/fixtures/double_variant.vcf +0 -21
- tests/fixtures/funny_trio.ped +0 -4
- tests/fixtures/profile_snv.vcf +0 -47
- tests/fixtures/recessive_trio.ped +0 -4
- tests/fixtures/test.SV.vcf +0 -178
- tests/fixtures/test.vcf +0 -26
- tests/fixtures/test.vcf.gz +0 -0
- tests/fixtures/test.vcf.gz.tbi +0 -0
- tests/fixtures/unsorted.vcf +0 -20
- tests/functional/test_cli.py +0 -213
- tests/plugins/mongo/test_case_operations.py +0 -143
- tests/plugins/mongo/test_connect.py +0 -8
- tests/plugins/mongo/test_flask_extension.py +0 -27
- tests/plugins/mongo/test_get_sv.py +0 -27
- tests/plugins/mongo/test_load_svs.py +0 -74
- tests/plugins/mongo/test_variant_operations.py +0 -278
- tests/utils/test_case.py +0 -34
- tests/utils/test_delete.py +0 -73
- tests/utils/test_delete_family.py +0 -30
- tests/utils/test_delete_variant.py +0 -74
- tests/utils/test_get_family.py +0 -13
- tests/utils/test_load_database.py +0 -52
- tests/utils/test_load_family.py +0 -69
- tests/utils/test_load_variants.py +0 -225
- tests/utils/test_migrate.py +0 -38
- tests/utils/test_profiling.py +0 -68
- tests/vcf_tools/test_check_par.py +0 -67
- tests/vcf_tools/test_check_vcf.py +0 -64
- tests/vcf_tools/test_format_sv_variant.py +0 -102
- tests/vcf_tools/test_format_variant.py +0 -113
- tests/vcf_tools/test_vcf.py +0 -63
- {loqusdb-2.7.11.dist-info → loqusdb-2.7.12.dist-info}/LICENSE +0 -0
- {loqusdb-2.7.11.dist-info → loqusdb-2.7.12.dist-info}/entry_points.txt +0 -0
loqusdb/__init__.py
CHANGED
loqusdb/commands/export.py
CHANGED
@@ -59,7 +59,10 @@ def export(ctx, outfile, variant_type, freq):
|
|
59
59
|
head.add_meta_line("NrCases", nr_cases)
|
60
60
|
if freq:
|
61
61
|
head.add_info(
|
62
|
-
"Frq",
|
62
|
+
"Frq",
|
63
|
+
"1",
|
64
|
+
"Float",
|
65
|
+
f"Observation frequency of the variant (not allele frequency) based on {nr_cases} cases",
|
63
66
|
)
|
64
67
|
head.add_info("Obs", "1", "Integer", "The number of observations for the variant")
|
65
68
|
head.add_info("Hom", "1", "Integer", "The number of observed homozygotes")
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.3
|
2
2
|
Name: loqusdb
|
3
|
-
Version: 2.7.
|
3
|
+
Version: 2.7.12
|
4
4
|
Summary: A simple observation count database
|
5
5
|
License: MIT
|
6
6
|
Author: Your Name
|
@@ -9,6 +9,7 @@ Requires-Python: >=3.12,<4.0
|
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
11
11
|
Classifier: Programming Language :: Python :: 3.12
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
12
13
|
Requires-Dist: PyYAML
|
13
14
|
Requires-Dist: click
|
14
15
|
Requires-Dist: coloredlogs
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
loqusdb/__init__.py,sha256=tVCT5pNoMl8Zuqcc32Dbade0bG0SS7s05LMGyRM2gL0,1688
|
1
|
+
loqusdb/__init__.py,sha256=8HkygPjhH1mlqoo1IXBaXPSGUkIRHyhkkz5f29Am25I,1688
|
3
2
|
loqusdb/__main__.py,sha256=8FGKySAGaWSzAYMj6HRsxeyiME3V01Idt7HrmN7pSYY,397
|
4
3
|
loqusdb/build_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
4
|
loqusdb/build_models/case.py,sha256=AByutEYK2N3kS9JFvyZfPKNZdCpZHCSD0nNHAgaU1Cs,4127
|
@@ -9,7 +8,7 @@ loqusdb/commands/__init__.py,sha256=BXAN3UADgqPrkGczzjlLO9GyyQ96dnLnP7n92JlYHgo,
|
|
9
8
|
loqusdb/commands/annotate.py,sha256=748kImopE5WbaO1nuv3WUgIqezWFSsi7SBeWhOz26-s,1384
|
10
9
|
loqusdb/commands/cli.py,sha256=wJD5S1BoCxtRTAobd1QtmQpzlngJg-mt1nsyD92fDD4,3176
|
11
10
|
loqusdb/commands/delete.py,sha256=R6ysHKSMw1mmL4ZbktoUIKzdzDLQ3314YPYhIy1myic,1979
|
12
|
-
loqusdb/commands/export.py,sha256
|
11
|
+
loqusdb/commands/export.py,sha256=DPcMo4QgTCA5fu8x_IWZ9YskRl4_ikKARXpnuFr1iow,3302
|
13
12
|
loqusdb/commands/identity.py,sha256=KLA9c8e6cJFDxtqIa1G6zdHTHK1sz2b3v1Utdtik_4k,787
|
14
13
|
loqusdb/commands/load.py,sha256=sDGCOGbukdfebLn1iBGyWoI6t3tijLzywP1tg3WheQI,4431
|
15
14
|
loqusdb/commands/load_profile.py,sha256=cflCbF9f77_HCH8xPnN8zSSocvIffRMnC2LPE0j7Xq8,3336
|
@@ -50,48 +49,8 @@ loqusdb/utils/profiling.py,sha256=3OizF7CpYvSl9kyl2g4KGJxbIRUqWfmfLxn3843XYDk,91
|
|
50
49
|
loqusdb/utils/update.py,sha256=1edJG-u24FgOSxyXAQEiyTG4IyK-Uo3lSIl5qyzcXsI,4433
|
51
50
|
loqusdb/utils/variant.py,sha256=U6nMZRUf5NDDQ74nG0HBCLMnFQVgFAT6eHll_F2uiwc,2087
|
52
51
|
loqusdb/utils/vcf.py,sha256=ybmrTBEPYa0FbUXo8ttlwATk13RnKjX9eIDbRDwCiVE,5175
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
tests/commands/test_view.py,sha256=036iug8YB67ZYi_qtSU_VBBAIcJZEj_EolNDRsOaVCM,662
|
59
|
-
tests/conftest.py,sha256=F7teEGvH3mD1zO5tqd_yEWneFrmW5U8d74-IDDSAXoI,10531
|
60
|
-
tests/fixtures/643594.clinical.SV.vcf,sha256=e-RVC96kxwrohNmiZ7xHAHcTcnWI5-NSpOVMX2zGsXA,59626
|
61
|
-
tests/fixtures/643594.clinical.vcf.gz,sha256=CuGqNRVLnkPDy8JM9i8JhYQZn28CDM1eGenECi2dD4E,413153
|
62
|
-
tests/fixtures/double_variant.vcf,sha256=LlVy4mW1-HAw0dyJpWPJTbAGQm5LZOtOuD2uLkbJE7w,2165
|
63
|
-
tests/fixtures/funny_trio.ped,sha256=t4Mroxg51i5zhLPnbbWSXaC2aKgETMvNcfQc-ArjFpk,130
|
64
|
-
tests/fixtures/profile_snv.vcf,sha256=SdQA2CCzCLCrwYEEod2yuZsVt6--8dHppUVyaIKxan0,5420
|
65
|
-
tests/fixtures/recessive_trio.ped,sha256=leXtMPWrwXeDQY557R_sL5QLcewu1uwHFsn8moOjMCY,148
|
66
|
-
tests/fixtures/test.SV.vcf,sha256=OqNrkQQpgbXs2L1en7S6C8A0KFCKDn4w1czRRAU-lEY,59618
|
67
|
-
tests/fixtures/test.vcf,sha256=AGTIHfmy_c2R0CUSwia7HjvyEYUWLi-uZVam38k9hg8,2393
|
68
|
-
tests/fixtures/test.vcf.gz,sha256=3XRv5PmJro-Dm8duXrByuAqrBSfsM9dnQjZuRE4Rru8,652
|
69
|
-
tests/fixtures/test.vcf.gz.tbi,sha256=ew7qzOaJQlmMyI8Oq-kmnba4mFnCtD2INpN4RXhKgVQ,267
|
70
|
-
tests/fixtures/unsorted.vcf,sha256=NSsdgsVVJuJwd3udD__GBrZaregz4qa_egDg4OzBLF4,2049
|
71
|
-
tests/functional/test_cli.py,sha256=XO7toMozpFU3MrqxSqsqKjUgeLSbeEmNtLSmGePWuXg,8095
|
72
|
-
tests/plugins/mongo/test_case_operations.py,sha256=SJ9KHiDV7iHRtxu-4C9mp9uSKQ5wen3hoqK0W7JULGA,4271
|
73
|
-
tests/plugins/mongo/test_connect.py,sha256=RsyDY5T9BkkgZANyOrMZ3-nXRZX8sjvBH7E1BD5noYU,199
|
74
|
-
tests/plugins/mongo/test_flask_extension.py,sha256=UtvMJbRqVcVn82b9sGL-IQCK5GBW2KdnhckLuB9Dqkk,738
|
75
|
-
tests/plugins/mongo/test_get_sv.py,sha256=9LBnCv7zLjKuioNMhSBMo0zJ3Md3wpEUa395Gz_18ms,1029
|
76
|
-
tests/plugins/mongo/test_load_svs.py,sha256=zkDiowbG2p6uiUC5nzajDp_QDky5lyKAnyr_sir8Pic,2670
|
77
|
-
tests/plugins/mongo/test_variant_operations.py,sha256=Th42H-rHuN8oa-e8Sug29-_8tJtezevjmD4rM3543kM,9687
|
78
|
-
tests/utils/test_case.py,sha256=DTbdiTn5myeE1K91wXtJwiDeLfmYOU8uqooSAq_B56o,1317
|
79
|
-
tests/utils/test_delete.py,sha256=Gzatf_WpqdtRhkELEt2WgVuKF-UwiPUuycS7cjtKcgg,1872
|
80
|
-
tests/utils/test_delete_family.py,sha256=ym0ffeCf8IvNy9-AUL2ix1BWBapxZo4P4ZuLtQfQNtQ,845
|
81
|
-
tests/utils/test_delete_variant.py,sha256=bRNFmV9OvQJ-Ao6eq2yKIhjz3-FOH75OCqclKTu9c8A,2171
|
82
|
-
tests/utils/test_get_family.py,sha256=WLIqNHCfmHbZoL-TMLf6wFGxf_vBeEBE9ndWOE2iHTQ,329
|
83
|
-
tests/utils/test_load_database.py,sha256=gZOLSTrRYsTq8q3in0gazmZJxZVreoFN1_o9EzXD_1s,1473
|
84
|
-
tests/utils/test_load_family.py,sha256=DWDqC9UCMVMwVKoYToL_KGc0kpsn9DVFFZovD3zOCMc,2376
|
85
|
-
tests/utils/test_load_variants.py,sha256=CAo8oDw9mz8oTszscIS38yl7jKUPVapJIH_Y4MUBZHs,6278
|
86
|
-
tests/utils/test_migrate.py,sha256=DM4RC_sY6C3aCbE0-Rzg5Yi5pp0BgKNefP1OCaviPSw,1177
|
87
|
-
tests/utils/test_profiling.py,sha256=tehPKrE0tNbaz26On8lp4MeDTMwTpw_iyQdW1cW5iMo,2658
|
88
|
-
tests/vcf_tools/test_check_par.py,sha256=zmG3HKWy6omyofqK4WjzmcbkVEvkncUm26GeMtnxHiI,1155
|
89
|
-
tests/vcf_tools/test_check_vcf.py,sha256=bTZQOSbhXthRDwTmcfvf4sW-DMUdlpM7bBSDsmXSDrU,1966
|
90
|
-
tests/vcf_tools/test_format_sv_variant.py,sha256=eeQ6XI6X2lNpsVaWecu5lfdRHrDh1XZvcz9UhL7j3qo,4375
|
91
|
-
tests/vcf_tools/test_format_variant.py,sha256=CfgCnrS5OvuIcUOCTUGCiDRUelk3fZgT7YQAytNPvvM,4176
|
92
|
-
tests/vcf_tools/test_vcf.py,sha256=Fc9tO1IgKFo_DCfj_GrsXGx9t_69xkWhn1ZCL7IXqLU,1563
|
93
|
-
loqusdb-2.7.11.dist-info/LICENSE,sha256=urpFcJXw3elN9kV2fFutc-lXegjuu2lqP_GSy8_CAbs,1054
|
94
|
-
loqusdb-2.7.11.dist-info/METADATA,sha256=Kcjp_pYPIFrSDYb5sQYxHfTJY5z1ql99WYlGQSWB0SY,5270
|
95
|
-
loqusdb-2.7.11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
96
|
-
loqusdb-2.7.11.dist-info/entry_points.txt,sha256=wFoWzEFjsSgXkj9FMQA8C9ihZoJ9R1XvbGuX9hEEI6E,52
|
97
|
-
loqusdb-2.7.11.dist-info/RECORD,,
|
52
|
+
loqusdb-2.7.12.dist-info/LICENSE,sha256=urpFcJXw3elN9kV2fFutc-lXegjuu2lqP_GSy8_CAbs,1054
|
53
|
+
loqusdb-2.7.12.dist-info/METADATA,sha256=xuej6Yy1Xc1YBsrc1YxlnTO6MkMr80_HoDAYqVcqzKs,5321
|
54
|
+
loqusdb-2.7.12.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
55
|
+
loqusdb-2.7.12.dist-info/entry_points.txt,sha256=wFoWzEFjsSgXkj9FMQA8C9ihZoJ9R1XvbGuX9hEEI6E,52
|
56
|
+
loqusdb-2.7.12.dist-info/RECORD,,
|
README.md
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
# loqusdb
|
2
|
-
[](https://github.com/moonso/loqusdb/actions/workflows/build_and_publish.yml)
|
3
|
-
[](https://coveralls.io/github/moonso/loqusdb?branch=master)
|
4
|
-
[![PyPI Version][pypi-img]][pypi-url]
|
5
|
-
|
6
|
-
Small tool to set up a local variant database.
|
7
|
-
If you find Loqusdb useful in your work, please cite the [article][publication].
|
8
|
-
|
9
|
-
Right now **Locusdb** uses [mongodb][mongodb] as backend for
|
10
|
-
storing variants, but there should not be a huge difference to use another
|
11
|
-
database manager.
|
12
|
-
|
13
|
-
## Installation ##
|
14
|
-
|
15
|
-
|
16
|
-
`poetry install`
|
17
|
-
|
18
|
-
or
|
19
|
-
|
20
|
-
```
|
21
|
-
$git clone https://github.com/moonso/loqusdb
|
22
|
-
$cd loqusdb
|
23
|
-
$poetry install
|
24
|
-
```
|
25
|
-
|
26
|
-
## Idea ##
|
27
|
-
|
28
|
-
Tool to keep track of what variants that have been seen and in what families they have been observed.
|
29
|
-
This is **NOT** a tool to create a true frequency database.
|
30
|
-
It will basically count the number of times we have seen a variant in any individual.
|
31
|
-
We will also keep track of the variants that have been seen in a homozygous or hemizygous state.
|
32
|
-
|
33
|
-
Variants are stored by providing a VCF file and a (ped or ped like) family file.
|
34
|
-
|
35
|
-
Loqusdb will first check if the VCF file adheres to the VCF format.
|
36
|
-
|
37
|
-
The tool will then check all variants if they have been observed in any of the individuals in the family.
|
38
|
-
|
39
|
-
When the variants are added:
|
40
|
-
|
41
|
-
- Either the variant exists, in this case we increase the number of observations with one
|
42
|
-
- Or this variant has not been seen before, then the variant is added to the database
|
43
|
-
|
44
|
-
|
45
|
-
## Command Line Interface ##
|
46
|
-
|
47
|
-
```
|
48
|
-
$ loqusdb
|
49
|
-
Usage: loqusdb [OPTIONS] COMMAND [ARGS]...
|
50
|
-
|
51
|
-
loqusdb: manage a local variant count database.
|
52
|
-
|
53
|
-
Options:
|
54
|
-
-db, --database TEXT Defaults to 'loqusdb' if not specified
|
55
|
-
-u, --username TEXT
|
56
|
-
-p, --password TEXT
|
57
|
-
-a, --authdb TEXT If authentication should be done against
|
58
|
-
another database than --database
|
59
|
-
|
60
|
-
-port, --port INTEGER Specify the port where to look for the mongo
|
61
|
-
database. [default: 27017]
|
62
|
-
|
63
|
-
-h, --host TEXT Specify the host where to look for the mongo
|
64
|
-
database. [default: localhost]
|
65
|
-
|
66
|
-
--uri TEXT Specify a mongodb uri
|
67
|
-
-c, --config FILENAME Use a config with db information
|
68
|
-
-t, --test Used for testing. This will use a mongomock
|
69
|
-
database.
|
70
|
-
|
71
|
-
-g, --genome-build [GRCh37|GRCh38]
|
72
|
-
Specify what genome build to use
|
73
|
-
-v, --verbose
|
74
|
-
--version Show the version and exit.
|
75
|
-
--help Show this message and exit.
|
76
|
-
|
77
|
-
Commands:
|
78
|
-
annotate Annotate a VCF with observations
|
79
|
-
cases Display cases in database
|
80
|
-
delete Delete the variants of a family
|
81
|
-
dump Dump the database
|
82
|
-
export Export variants to VCF format
|
83
|
-
identity Search identity collection
|
84
|
-
index Add indexes to database
|
85
|
-
load Load the variants of a family
|
86
|
-
migrate Migrate an old loqusdb instance
|
87
|
-
profile Loads variants to be used in profiling
|
88
|
-
restore Restore database from dump
|
89
|
-
update Update an existing case with a new type of variants
|
90
|
-
variants Display variants in database
|
91
|
-
wipe Wipe a loqusdb instance
|
92
|
-
```
|
93
|
-
|
94
|
-
|
95
|
-
## Database ##
|
96
|
-
|
97
|
-
### Connecting ###
|
98
|
-
|
99
|
-
Connection can be specified on command line with `--database`, `--username`, `--password`, `--port`, `--host` and/or `--uri`. Or these options can be sent with a config file that can take the same options:
|
100
|
-
|
101
|
-
```yaml
|
102
|
-
uri: mongodb://loqusdb-username:loqusdb-pwd@localhost:27030/loqusdb-rd?authSource=admin
|
103
|
-
db_name: loqusdb_test
|
104
|
-
```
|
105
|
-
or
|
106
|
-
```yaml
|
107
|
-
host: localhost
|
108
|
-
port: 27030
|
109
|
-
username: loqusdb-username
|
110
|
-
password: loqusdb-pwd
|
111
|
-
authdb: admin
|
112
|
-
db_name: loqusdb_test
|
113
|
-
```
|
114
|
-
|
115
|
-
### Mongo ###
|
116
|
-
|
117
|
-
The collections are defined as follows:
|
118
|
-
|
119
|
-
**Case**
|
120
|
-
|
121
|
-
```python
|
122
|
-
{
|
123
|
-
'case_id': 'case_id',
|
124
|
-
'vcf_path': 'path_to_vcf'
|
125
|
-
}
|
126
|
-
```
|
127
|
-
|
128
|
-
**Variant**
|
129
|
-
|
130
|
-
```python
|
131
|
-
{
|
132
|
-
'_id': 'variant_id',
|
133
|
-
'chrom': 'CHROM',
|
134
|
-
'start': postition,
|
135
|
-
'end': end postition,
|
136
|
-
'ref': reference base(s),
|
137
|
-
'alt': alternative base(s),
|
138
|
-
'homozygote': number_of_homozygotes,
|
139
|
-
'hemizygote': number_of_hemizygotes,
|
140
|
-
'observations': number_of_observations,
|
141
|
-
'families': ['family_id', ...]
|
142
|
-
}
|
143
|
-
```
|
144
|
-
|
145
|
-
[mongodb]: https://www.mongodb.org
|
146
|
-
[publication]: https://bmcbioinformatics.biomedcentral.com/articles/10.1186/s12859-020-03609-z
|
147
|
-
[pypi-img]: https://img.shields.io/pypi/v/loqusdb.svg?style=flat-square
|
148
|
-
[pypi-url]: https://pypi.python.org/pypi/loqusdb/
|
@@ -1,150 +0,0 @@
|
|
1
|
-
import pytest
|
2
|
-
|
3
|
-
from loqusdb.build_models.case import build_case, get_individual_positions
|
4
|
-
from loqusdb.exceptions import CaseError
|
5
|
-
|
6
|
-
|
7
|
-
def test_get_individual_positions():
|
8
|
-
## GIVEN a list with ids
|
9
|
-
inds = ["1", "2", "3"]
|
10
|
-
## WHEN getting the individual positions
|
11
|
-
ind_pos = get_individual_positions(inds)
|
12
|
-
## THEN assert they where given the correct position
|
13
|
-
assert ind_pos["1"] == 0
|
14
|
-
assert ind_pos["2"] == 1
|
15
|
-
assert ind_pos["3"] == 2
|
16
|
-
|
17
|
-
|
18
|
-
def test_get_individual_positions_no_inds():
|
19
|
-
## GIVEN a list with ids
|
20
|
-
inds = None
|
21
|
-
## WHEN getting the individual positions
|
22
|
-
ind_pos = get_individual_positions(inds)
|
23
|
-
## THEN assert an empty dict is returned
|
24
|
-
assert ind_pos == {}
|
25
|
-
|
26
|
-
|
27
|
-
def test_build_case_no_ped():
|
28
|
-
## GIVEN some vcf individuals
|
29
|
-
|
30
|
-
vcf_individuals = ["mother", "proband"]
|
31
|
-
case_id = "test"
|
32
|
-
|
33
|
-
## WHEN building a case object
|
34
|
-
case_obj = build_case(
|
35
|
-
case=None,
|
36
|
-
vcf_individuals=vcf_individuals,
|
37
|
-
case_id=case_id,
|
38
|
-
)
|
39
|
-
|
40
|
-
## THEN assert that the case got the right ID
|
41
|
-
assert case_obj["case_id"] == case_id
|
42
|
-
for ind_obj in case_obj["individuals"]:
|
43
|
-
assert ind_obj["name"] in vcf_individuals
|
44
|
-
assert ind_obj["ind_id"] in vcf_individuals
|
45
|
-
|
46
|
-
|
47
|
-
def test_build_case_no_ped_no_case_id():
|
48
|
-
## WHEN building a case object
|
49
|
-
|
50
|
-
## THEN assert a CaseError is raised
|
51
|
-
with pytest.raises(CaseError):
|
52
|
-
## GIVEN some vcf individuals
|
53
|
-
|
54
|
-
vcf_individuals = ["mother", "proband"]
|
55
|
-
|
56
|
-
case_obj = build_case(
|
57
|
-
case=None,
|
58
|
-
vcf_individuals=vcf_individuals,
|
59
|
-
)
|
60
|
-
|
61
|
-
|
62
|
-
def test_build_case_ped(family_obj, vcf_path):
|
63
|
-
## GIVEN a ped parser family_obj
|
64
|
-
vcf_inds = [ind_id for ind_id in family_obj.individuals]
|
65
|
-
nr_variants = 10
|
66
|
-
|
67
|
-
## WHEN building a case object
|
68
|
-
case_obj = build_case(
|
69
|
-
case=family_obj,
|
70
|
-
vcf_individuals=vcf_inds,
|
71
|
-
vcf_path=vcf_path,
|
72
|
-
nr_variants=nr_variants,
|
73
|
-
)
|
74
|
-
|
75
|
-
## THEN assert that the case has the correct id
|
76
|
-
assert case_obj["case_id"] == family_obj.family_id
|
77
|
-
|
78
|
-
for ind_obj in case_obj["individuals"]:
|
79
|
-
assert ind_obj["ind_id"] in vcf_inds
|
80
|
-
|
81
|
-
## THEN assert that the vcf_path was added
|
82
|
-
assert case_obj["vcf_path"] == vcf_path
|
83
|
-
|
84
|
-
## THEN assert that the nr variants is correct
|
85
|
-
assert case_obj["nr_variants"] == nr_variants
|
86
|
-
|
87
|
-
|
88
|
-
def test_build_case_ped_sv(family_obj, sv_vcf_path):
|
89
|
-
## GIVEN a ped parser family_obj
|
90
|
-
vcf_inds = [ind_id for ind_id in family_obj.individuals]
|
91
|
-
nr_sv_variants = 10
|
92
|
-
|
93
|
-
## WHEN building a case object
|
94
|
-
case_obj = build_case(
|
95
|
-
case=family_obj,
|
96
|
-
sv_individuals=vcf_inds,
|
97
|
-
vcf_sv_path=sv_vcf_path,
|
98
|
-
nr_sv_variants=nr_sv_variants,
|
99
|
-
)
|
100
|
-
|
101
|
-
## THEN assert that the case has the correct id
|
102
|
-
assert case_obj["case_id"] == family_obj.family_id
|
103
|
-
|
104
|
-
case_obj["individuals"] == []
|
105
|
-
for ind_obj in case_obj["sv_individuals"]:
|
106
|
-
assert ind_obj["ind_id"] in vcf_inds
|
107
|
-
|
108
|
-
## THEN assert that the vcf_path was added
|
109
|
-
assert case_obj["vcf_path"] is None
|
110
|
-
assert case_obj["vcf_sv_path"] == sv_vcf_path
|
111
|
-
|
112
|
-
## THEN assert that the nr variants is correct
|
113
|
-
assert case_obj["nr_variants"] is None
|
114
|
-
assert case_obj["nr_sv_variants"] == nr_sv_variants
|
115
|
-
|
116
|
-
|
117
|
-
def test_build_case_ped_sv_and_snv(family_obj, sv_vcf_path, vcf_path):
|
118
|
-
## GIVEN a ped parser family_obj
|
119
|
-
vcf_inds = [ind_id for ind_id in family_obj.individuals]
|
120
|
-
sv_vcf_inds = [ind_id for ind_id in family_obj.individuals]
|
121
|
-
nr_sv_variants = 10
|
122
|
-
nr_variants = 20
|
123
|
-
|
124
|
-
## WHEN building a case object
|
125
|
-
case_obj = build_case(
|
126
|
-
case=family_obj,
|
127
|
-
sv_individuals=vcf_inds,
|
128
|
-
vcf_sv_path=sv_vcf_path,
|
129
|
-
nr_sv_variants=nr_sv_variants,
|
130
|
-
vcf_individuals=vcf_inds,
|
131
|
-
vcf_path=vcf_path,
|
132
|
-
nr_variants=nr_variants,
|
133
|
-
)
|
134
|
-
|
135
|
-
## THEN assert that the case has the correct id
|
136
|
-
assert case_obj["case_id"] == family_obj.family_id
|
137
|
-
|
138
|
-
for ind_obj in case_obj["individuals"]:
|
139
|
-
assert ind_obj["ind_id"] in vcf_inds
|
140
|
-
|
141
|
-
for ind_obj in case_obj["sv_individuals"]:
|
142
|
-
assert ind_obj["ind_id"] in sv_vcf_inds
|
143
|
-
|
144
|
-
## THEN assert that the vcf_path was added
|
145
|
-
assert case_obj["vcf_path"] == vcf_path
|
146
|
-
assert case_obj["vcf_sv_path"] == sv_vcf_path
|
147
|
-
|
148
|
-
## THEN assert that the nr variants is correct
|
149
|
-
assert case_obj["nr_variants"] == nr_variants
|
150
|
-
assert case_obj["nr_sv_variants"] == nr_sv_variants
|
@@ -1,15 +0,0 @@
|
|
1
|
-
from loqusdb.build_models.variant import get_coords, build_variant
|
2
|
-
|
3
|
-
|
4
|
-
def test_build_het_variant(het_variant, case_obj):
|
5
|
-
variant_obj = build_variant(variant=het_variant, case_obj=case_obj)
|
6
|
-
assert variant_obj["chrom"] == het_variant.CHROM
|
7
|
-
assert variant_obj["homozygote"] == 0
|
8
|
-
assert variant_obj["hemizygote"] == 0
|
9
|
-
|
10
|
-
|
11
|
-
def test_get_coords_for_BND(bnd_variant):
|
12
|
-
coords = get_coords(bnd_variant)
|
13
|
-
assert coords["pos"] == coords["end"]
|
14
|
-
assert coords["sv_length"] == float("inf")
|
15
|
-
assert coords["sv_type"] == "BND"
|
@@ -1,49 +0,0 @@
|
|
1
|
-
from loqusdb.build_models.variant import Position, is_greater
|
2
|
-
|
3
|
-
|
4
|
-
def test_is_greater_different_chrom():
|
5
|
-
## GIVEN two positions where a is smaller than b. Different chroms
|
6
|
-
a = Position("1", 100)
|
7
|
-
b = Position("3", 100)
|
8
|
-
|
9
|
-
## WHEN testing if a is greater than b
|
10
|
-
res = is_greater(a, b)
|
11
|
-
## THEN assert a was not greater than b
|
12
|
-
assert res is False
|
13
|
-
|
14
|
-
## WHEN testing if b is greater than a
|
15
|
-
res = is_greater(b, a)
|
16
|
-
## THEN assert b was greater than a
|
17
|
-
assert res is True
|
18
|
-
|
19
|
-
|
20
|
-
def test_is_greater_same_chrom():
|
21
|
-
## GIVEN two positions where a is smaller than b. Same chroms
|
22
|
-
a = Position("1", 100)
|
23
|
-
b = Position("1", 300)
|
24
|
-
|
25
|
-
## WHEN testing if a is greater than b
|
26
|
-
res = is_greater(a, b)
|
27
|
-
## THEN assert a was not greater than b
|
28
|
-
assert res is False
|
29
|
-
|
30
|
-
## WHEN testing if b is greater than a
|
31
|
-
res = is_greater(b, a)
|
32
|
-
## THEN assert b was greater than a
|
33
|
-
assert res is True
|
34
|
-
|
35
|
-
|
36
|
-
def test_is_greater_wierd_chrom():
|
37
|
-
## GIVEN two positions where one chrom is unknown b
|
38
|
-
a = Position("1", 100)
|
39
|
-
b = Position("GRLrs2", 300)
|
40
|
-
|
41
|
-
## WHEN testing if a is greater than b
|
42
|
-
res = is_greater(a, b)
|
43
|
-
## THEN assert a was not greater than b
|
44
|
-
assert res is False
|
45
|
-
|
46
|
-
## WHEN testing if b is greater than a
|
47
|
-
res = is_greater(b, a)
|
48
|
-
## THEN assert a was not greater than b
|
49
|
-
assert res is False
|
tests/commands/test_export.py
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
from click.testing import CliRunner
|
2
|
-
|
3
|
-
from loqusdb.commands.cli import cli as base_command
|
4
|
-
|
5
|
-
|
6
|
-
def test_export_base(real_db_name: str):
|
7
|
-
"""Test the base command that exports variants."""
|
8
|
-
|
9
|
-
runner = CliRunner()
|
10
|
-
|
11
|
-
# WHEN the base command to export cases is run
|
12
|
-
command = ["--database", real_db_name, "export"]
|
13
|
-
|
14
|
-
## THEN it should return success
|
15
|
-
result = runner.invoke(base_command, command)
|
16
|
-
assert result.exit_code == 0
|
tests/commands/test_identity.py
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
from click.testing import CliRunner
|
2
|
-
|
3
|
-
from loqusdb.commands.cli import cli as base_command
|
4
|
-
|
5
|
-
|
6
|
-
def test_identity(real_db_name: str):
|
7
|
-
"""Test the SV identity base command."""
|
8
|
-
|
9
|
-
runner = CliRunner()
|
10
|
-
|
11
|
-
# WHEN the base identity command is run on an empty database
|
12
|
-
command = ["--database", real_db_name, "identity", "-v", "1_7890024_TGA_GGG"]
|
13
|
-
|
14
|
-
# THEN the command should return success
|
15
|
-
result = runner.invoke(base_command, command)
|
16
|
-
assert result.exit_code == 0
|
17
|
-
|
18
|
-
# AND no variant found message
|
19
|
-
assert "No hits for variant" in result.output
|
tests/commands/test_view.py
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
from click.testing import CliRunner
|
2
|
-
|
3
|
-
from loqusdb.commands.cli import cli as base_command
|
4
|
-
from loqusdb.plugins.mongo.adapter import MongoAdapter
|
5
|
-
|
6
|
-
|
7
|
-
def test_view_cases_base(real_mongo_adapter: MongoAdapter, real_db_name: str):
|
8
|
-
"""Test the base command that returns database cases."""
|
9
|
-
|
10
|
-
## GIVEN an empty database
|
11
|
-
assert sum([1 for _ in real_mongo_adapter.cases()]) == 0
|
12
|
-
|
13
|
-
runner = CliRunner()
|
14
|
-
|
15
|
-
# THEN the case command should return No cases found error
|
16
|
-
command = ["--database", real_db_name, "cases"]
|
17
|
-
result = runner.invoke(base_command, command)
|
18
|
-
assert result.exit_code == 1
|
19
|
-
assert "No cases found in database" in result.output
|