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
@@ -1,64 +0,0 @@
|
|
1
|
-
import pytest
|
2
|
-
from loqusdb.exceptions import VcfError
|
3
|
-
from loqusdb.utils.vcf import check_vcf
|
4
|
-
|
5
|
-
|
6
|
-
def test_check_vcf_correct(vcf_path):
|
7
|
-
## GIVEN a vcf file and a counter that checks the number of variants
|
8
|
-
true_nr = 0
|
9
|
-
|
10
|
-
with open(vcf_path, "r") as f:
|
11
|
-
for line in f:
|
12
|
-
if not line.startswith("#"):
|
13
|
-
true_nr += 1
|
14
|
-
|
15
|
-
## WHEN collecting the VCF info
|
16
|
-
vcf_info = check_vcf(vcf_path)
|
17
|
-
|
18
|
-
## THEN assert that the number of variants collected is correct
|
19
|
-
assert vcf_info["nr_variants"] == true_nr
|
20
|
-
## THEN assert that the variant type is correct
|
21
|
-
assert vcf_info["variant_type"] == "snv"
|
22
|
-
|
23
|
-
|
24
|
-
def test_check_vcf_double_variant(double_vcf_path):
|
25
|
-
## GIVEN a variant file where a variant is duplicated
|
26
|
-
## WHEN checking the vcf
|
27
|
-
## THEN assert that the function raises a VcfError
|
28
|
-
with pytest.raises(VcfError):
|
29
|
-
check_vcf(double_vcf_path)
|
30
|
-
|
31
|
-
|
32
|
-
def test_check_vcf_unsorted(unsorted_vcf_path):
|
33
|
-
## GIVEN a vcf file with unsorted variants
|
34
|
-
## WHEN checking the vcf
|
35
|
-
## THEN assert that the function raises a VcfError
|
36
|
-
with pytest.raises(VcfError):
|
37
|
-
check_vcf(unsorted_vcf_path)
|
38
|
-
|
39
|
-
|
40
|
-
def test_check_sv_vcf(sv_vcf_path):
|
41
|
-
## GIVEN a vcf file and a counter that checks the number of variants
|
42
|
-
true_nr = 0
|
43
|
-
|
44
|
-
with open(sv_vcf_path, "r") as f:
|
45
|
-
for line in f:
|
46
|
-
if not line.startswith("#"):
|
47
|
-
true_nr += 1
|
48
|
-
|
49
|
-
## WHEN collecting the VCF info
|
50
|
-
vcf_info = check_vcf(sv_vcf_path, "sv")
|
51
|
-
|
52
|
-
## THEN assert that the number of variants collected is correct
|
53
|
-
assert vcf_info["nr_variants"] == true_nr
|
54
|
-
## THEN assert that the variant type is correct
|
55
|
-
assert vcf_info["variant_type"] == "sv"
|
56
|
-
|
57
|
-
|
58
|
-
def test_check_vcf_wrong_type(sv_vcf_path):
|
59
|
-
## GIVEN a sv vcf file
|
60
|
-
|
61
|
-
## WHEN collecting the VCF info with wrong variant type
|
62
|
-
## THEN assert that a VcfError is raised
|
63
|
-
with pytest.raises(VcfError):
|
64
|
-
vcf_info = check_vcf(sv_vcf_path, "snv")
|
@@ -1,102 +0,0 @@
|
|
1
|
-
from loqusdb.build_models.variant import build_variant
|
2
|
-
|
3
|
-
|
4
|
-
def test_format_indel(del_variant, case_obj):
|
5
|
-
## GIVEN a SV deletion
|
6
|
-
variant = del_variant
|
7
|
-
case_id = case_obj["case_id"]
|
8
|
-
## WHEN parsing the variant
|
9
|
-
formated_variant = build_variant(variant=variant, case_obj=case_obj, case_id=case_id)
|
10
|
-
expected_id = "_".join([variant.CHROM, str(variant.POS), variant.REF, variant.ALT[0]])
|
11
|
-
|
12
|
-
## THEN assert the sv is parsed correct
|
13
|
-
assert formated_variant
|
14
|
-
assert formated_variant["variant_id"] == expected_id
|
15
|
-
assert formated_variant["chrom"] == variant.CHROM
|
16
|
-
assert formated_variant["end_chrom"] == variant.CHROM
|
17
|
-
assert formated_variant["pos"] == variant.POS
|
18
|
-
assert formated_variant["end"] == variant.INFO["END"]
|
19
|
-
assert formated_variant["sv_len"] == abs(variant.INFO["SVLEN"])
|
20
|
-
|
21
|
-
assert formated_variant["ref"] == variant.REF
|
22
|
-
assert formated_variant["alt"] == variant.ALT[0]
|
23
|
-
assert formated_variant["sv_type"] == "DEL"
|
24
|
-
assert formated_variant["case_id"] == case_id
|
25
|
-
assert formated_variant["homozygote"] == 0
|
26
|
-
assert formated_variant["hemizygote"] == 0
|
27
|
-
|
28
|
-
|
29
|
-
def test_format_small_ins(small_insert_variant, case_obj):
|
30
|
-
## GIVEN a small insertion (This means that the insertion is included in ALT field)
|
31
|
-
variant = small_insert_variant
|
32
|
-
case_id = case_obj["case_id"]
|
33
|
-
## WHEN parsing the variant
|
34
|
-
formated_variant = build_variant(variant=variant, case_obj=case_obj, case_id=case_id)
|
35
|
-
|
36
|
-
## THEN assert the sv is parsed correct
|
37
|
-
assert formated_variant["chrom"] == variant.CHROM
|
38
|
-
assert formated_variant["end_chrom"] == variant.CHROM
|
39
|
-
assert formated_variant["pos"] == variant.POS
|
40
|
-
assert formated_variant["end"] == variant.POS + abs(variant.INFO["SVLEN"])
|
41
|
-
assert formated_variant["sv_len"] == abs(variant.INFO["SVLEN"])
|
42
|
-
|
43
|
-
assert formated_variant["ref"] == variant.REF
|
44
|
-
assert formated_variant["alt"] == variant.ALT[0]
|
45
|
-
assert formated_variant["sv_type"] == "INS"
|
46
|
-
|
47
|
-
|
48
|
-
def test_format_insertion(insertion_variant, case_obj):
|
49
|
-
## GIVEN a small insertion (This means that the insertion is included in ALT field)
|
50
|
-
variant = insertion_variant
|
51
|
-
case_id = case_obj["case_id"]
|
52
|
-
## WHEN parsing the variant
|
53
|
-
formated_variant = build_variant(variant=variant, case_obj=case_obj, case_id=case_id)
|
54
|
-
|
55
|
-
## THEN assert the sv is parsed correct
|
56
|
-
assert formated_variant["chrom"] == variant.CHROM
|
57
|
-
assert formated_variant["end_chrom"] == variant.CHROM
|
58
|
-
assert formated_variant["pos"] == variant.POS
|
59
|
-
assert formated_variant["end"] == variant.INFO["END"]
|
60
|
-
assert formated_variant["sv_len"] == 0
|
61
|
-
|
62
|
-
assert formated_variant["ref"] == variant.REF
|
63
|
-
assert formated_variant["alt"] == variant.ALT[0]
|
64
|
-
assert formated_variant["sv_type"] == "INS"
|
65
|
-
|
66
|
-
|
67
|
-
def test_format_dup_tandem(duptandem_variant, case_obj):
|
68
|
-
## GIVEN a small insertion (This means that the insertion is included in ALT field)
|
69
|
-
variant = duptandem_variant
|
70
|
-
case_id = case_obj["case_id"]
|
71
|
-
## WHEN parsing the variant
|
72
|
-
formated_variant = build_variant(variant=variant, case_obj=case_obj, case_id=case_id)
|
73
|
-
|
74
|
-
## THEN assert the sv is parsed correct
|
75
|
-
assert formated_variant["chrom"] == variant.CHROM
|
76
|
-
assert formated_variant["end_chrom"] == variant.CHROM
|
77
|
-
assert formated_variant["pos"] == variant.POS
|
78
|
-
assert formated_variant["end"] == variant.INFO["END"]
|
79
|
-
assert formated_variant["sv_len"] == abs(variant.INFO["SVLEN"])
|
80
|
-
|
81
|
-
assert formated_variant["ref"] == variant.REF
|
82
|
-
assert formated_variant["alt"] == variant.ALT[0]
|
83
|
-
assert formated_variant["sv_type"] == "DUP"
|
84
|
-
|
85
|
-
|
86
|
-
def test_format_translocation(translocation_variant, case_obj):
|
87
|
-
## GIVEN a small insertion (This means that the insertion is included in ALT field)
|
88
|
-
variant = translocation_variant
|
89
|
-
case_id = case_obj["case_id"]
|
90
|
-
## WHEN parsing the variant
|
91
|
-
formated_variant = build_variant(variant=variant, case_obj=case_obj, case_id=case_id)
|
92
|
-
|
93
|
-
## THEN assert the sv is parsed correct
|
94
|
-
assert formated_variant["chrom"] == variant.CHROM
|
95
|
-
assert formated_variant["end_chrom"] == "11"
|
96
|
-
assert formated_variant["pos"] == variant.POS
|
97
|
-
assert formated_variant["end"] == 119123896
|
98
|
-
assert formated_variant["sv_len"] == float("inf")
|
99
|
-
|
100
|
-
assert formated_variant["ref"] == variant.REF
|
101
|
-
assert formated_variant["alt"] == variant.ALT[0]
|
102
|
-
assert formated_variant["sv_type"] == "BND"
|
@@ -1,113 +0,0 @@
|
|
1
|
-
from loqusdb.build_models.variant import build_variant, GENOTYPE_MAP
|
2
|
-
|
3
|
-
|
4
|
-
def test_format_variant(het_variant, case_obj):
|
5
|
-
## GIVEN a parsed variant
|
6
|
-
variant = het_variant
|
7
|
-
case_id = case_obj["case_id"]
|
8
|
-
## WHEN parsing the variant
|
9
|
-
formated_variant = build_variant(variant=variant, case_obj=case_obj, case_id=case_id)
|
10
|
-
|
11
|
-
expected_id = "_".join([variant.CHROM, str(variant.POS), variant.REF, variant.ALT[0]])
|
12
|
-
|
13
|
-
## THEN assert it was built in a correct way
|
14
|
-
assert formated_variant
|
15
|
-
assert formated_variant["variant_id"] == expected_id
|
16
|
-
assert formated_variant["chrom"] == variant.CHROM
|
17
|
-
assert formated_variant["pos"] == variant.POS
|
18
|
-
assert formated_variant["ref"] == variant.REF
|
19
|
-
assert formated_variant["alt"] == variant.ALT[0]
|
20
|
-
assert formated_variant["case_id"] == case_id
|
21
|
-
assert formated_variant["homozygote"] == 0
|
22
|
-
|
23
|
-
|
24
|
-
def test_format_variant_no_qual(variant_no_gq, case_obj):
|
25
|
-
## GIVEN a variant without GQ
|
26
|
-
variant = variant_no_gq
|
27
|
-
## And that has a missing QUAL value
|
28
|
-
variant.QUAL = None
|
29
|
-
case_id = case_obj["case_id"]
|
30
|
-
## WHEN parsing the variant using a QUAL threshold
|
31
|
-
formated_variant = build_variant(
|
32
|
-
variant=variant, case_obj=case_obj, case_id=case_id, gq_qual=True, gq_threshold=20
|
33
|
-
)
|
34
|
-
## THEN assert that None is returned since requirements are not fulfilled
|
35
|
-
assert formated_variant is None
|
36
|
-
|
37
|
-
|
38
|
-
def test_format_variant_no_gq(variant_no_gq, case_obj):
|
39
|
-
## GIVEN a variant without GQ
|
40
|
-
variant = variant_no_gq
|
41
|
-
case_id = case_obj["case_id"]
|
42
|
-
## WHEN parsing the variant using a GQ threshold
|
43
|
-
formated_variant = build_variant(
|
44
|
-
variant=variant, case_obj=case_obj, case_id=case_id, gq_threshold=20
|
45
|
-
)
|
46
|
-
## THEN assert that None is returned since requirements are not fulfilled
|
47
|
-
assert formated_variant is None
|
48
|
-
|
49
|
-
|
50
|
-
def test_format_variant_chr_prefix(variant_chr, case_obj):
|
51
|
-
## GIVEN a variant with 'chr' prefix in chromosome name
|
52
|
-
variant = variant_chr
|
53
|
-
assert variant.CHROM.startswith("chr")
|
54
|
-
case_id = case_obj["case_id"]
|
55
|
-
## WHEN parsing the variant using a GQ threshold
|
56
|
-
formated_variant = build_variant(
|
57
|
-
variant=variant, case_obj=case_obj, case_id=case_id, gq_threshold=20
|
58
|
-
)
|
59
|
-
## THEN assert that the 'chr' part has been stripped away
|
60
|
-
assert formated_variant["chrom"] == variant.CHROM[3:]
|
61
|
-
|
62
|
-
|
63
|
-
def test_format_variant_no_family_id(het_variant, case_obj):
|
64
|
-
## GIVEN a parsed variant
|
65
|
-
variant = het_variant
|
66
|
-
case_id = case_obj["case_id"]
|
67
|
-
## WHEN parsing the variant telling that 'case_id' is None
|
68
|
-
formated_variant = build_variant(variant=variant, case_obj=case_obj, case_id=None)
|
69
|
-
## THEN assert that case_id was not added
|
70
|
-
assert formated_variant.get("case_id") == None
|
71
|
-
assert formated_variant["homozygote"] == 0
|
72
|
-
assert formated_variant["hemizygote"] == 0
|
73
|
-
|
74
|
-
|
75
|
-
def test_format_homozygote_variant(hom_variant, case_obj):
|
76
|
-
## GIVEN a parsed hom variant
|
77
|
-
variant = hom_variant
|
78
|
-
case_id = case_obj["case_id"]
|
79
|
-
|
80
|
-
## WHEN parsing the variant
|
81
|
-
formated_variant = build_variant(variant=variant, case_obj=case_obj, case_id=case_id)
|
82
|
-
|
83
|
-
## THEN assert that the variant has hom count
|
84
|
-
assert formated_variant["homozygote"] == 1
|
85
|
-
assert formated_variant["hemizygote"] == 0
|
86
|
-
|
87
|
-
|
88
|
-
def test_format_hemizygote_variant(hem_variant, case_obj):
|
89
|
-
## GIVEN a parsed hemizygous variant
|
90
|
-
variant = hem_variant
|
91
|
-
case_id = case_obj["case_id"]
|
92
|
-
|
93
|
-
## WHEN parsing the variant
|
94
|
-
formated_variant = build_variant(variant=variant, case_obj=case_obj, case_id=case_id)
|
95
|
-
|
96
|
-
## THEN assert that hemizygote count is 1
|
97
|
-
assert formated_variant["homozygote"] == 0
|
98
|
-
assert formated_variant["hemizygote"] == 1
|
99
|
-
|
100
|
-
|
101
|
-
def test_format_variant_no_call(variant_no_call, case_obj):
|
102
|
-
## GIVEN a parsed variant with no call in all individuals
|
103
|
-
variant = variant_no_call
|
104
|
-
case_id = case_obj["case_id"]
|
105
|
-
|
106
|
-
for call in variant.gt_types:
|
107
|
-
assert GENOTYPE_MAP[call] in ["no_call", "hom_ref"]
|
108
|
-
|
109
|
-
## WHEN parsing the variant
|
110
|
-
formated_variant = build_variant(variant=variant, case_obj=case_obj, case_id=case_id)
|
111
|
-
|
112
|
-
## THEN assert that the result is None
|
113
|
-
assert formated_variant is None
|
tests/vcf_tools/test_vcf.py
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
import pytest
|
2
|
-
from cyvcf2 import VCF
|
3
|
-
from loqusdb.utils.vcf import get_file_handle, check_vcf
|
4
|
-
|
5
|
-
|
6
|
-
def test_get_file_handle(vcf_path):
|
7
|
-
## GIVEN the path to a vcf
|
8
|
-
|
9
|
-
## WHEN geting the file handle
|
10
|
-
vcf = get_file_handle(vcf_path)
|
11
|
-
|
12
|
-
## THEN assert that a VCF object is returned
|
13
|
-
assert type(vcf) is VCF
|
14
|
-
|
15
|
-
|
16
|
-
def test_get_zipped_file_handle(zipped_vcf_path):
|
17
|
-
## GIVEN the path to a zipped vcf
|
18
|
-
|
19
|
-
## WHEN geting the file handle
|
20
|
-
vcf = get_file_handle(zipped_vcf_path)
|
21
|
-
|
22
|
-
## THEN assert that a VCF object is returned
|
23
|
-
assert type(vcf) is VCF
|
24
|
-
|
25
|
-
|
26
|
-
def test_get_vcf_non_vcf(ped_path):
|
27
|
-
## GIVEN the path to a non vcf
|
28
|
-
|
29
|
-
## WHEN geting the file handle
|
30
|
-
|
31
|
-
## THEN assert that a IOError is raised
|
32
|
-
with pytest.raises(IOError):
|
33
|
-
vcf = get_file_handle(ped_path)
|
34
|
-
|
35
|
-
|
36
|
-
def test_get_vcf_non_existing():
|
37
|
-
## GIVEN the path to a non existing file
|
38
|
-
|
39
|
-
## WHEN geting the file handle
|
40
|
-
|
41
|
-
## THEN assert that a IOError is raised
|
42
|
-
with pytest.raises(IOError):
|
43
|
-
vcf = get_file_handle("hello")
|
44
|
-
|
45
|
-
|
46
|
-
def test_check_vcf(vcf_path):
|
47
|
-
## GIVEN the path to a vcf
|
48
|
-
nr_variants = 0
|
49
|
-
vcf = VCF(vcf_path)
|
50
|
-
inds = vcf.samples
|
51
|
-
for var in vcf:
|
52
|
-
nr_variants += 1
|
53
|
-
## WHEN checking the vcf
|
54
|
-
vcf_info = check_vcf(vcf_path)
|
55
|
-
|
56
|
-
## THEN assert that the number of variants is correct
|
57
|
-
assert vcf_info["nr_variants"] == nr_variants
|
58
|
-
|
59
|
-
## THEN assert that the individuals are returned
|
60
|
-
assert vcf_info["individuals"] == inds
|
61
|
-
|
62
|
-
## THEN assert that the variant type is correct
|
63
|
-
assert vcf_info["variant_type"] == "snv"
|
File without changes
|
File without changes
|