loqusdb 2.7.2__py3-none-any.whl → 2.7.4__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/build_models/variant.py +12 -4
- loqusdb/commands/export.py +3 -4
- loqusdb/commands/identity.py +3 -4
- loqusdb/commands/view.py +5 -2
- loqusdb/plugins/mongo/case.py +3 -10
- {loqusdb-2.7.2.dist-info → loqusdb-2.7.4.dist-info}/METADATA +4 -4
- {loqusdb-2.7.2.dist-info → loqusdb-2.7.4.dist-info}/RECORD +11 -11
- {loqusdb-2.7.2.dist-info → loqusdb-2.7.4.dist-info}/WHEEL +1 -1
- {loqusdb-2.7.2.dist-info → loqusdb-2.7.4.dist-info}/LICENSE +0 -0
- {loqusdb-2.7.2.dist-info → loqusdb-2.7.4.dist-info}/entry_points.txt +0 -0
- {loqusdb-2.7.2.dist-info → loqusdb-2.7.4.dist-info}/top_level.txt +0 -0
loqusdb/build_models/variant.py
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
import logging
|
2
2
|
from collections import namedtuple
|
3
3
|
|
4
|
+
import cyvcf2
|
5
|
+
|
6
|
+
from typing import Optional
|
7
|
+
|
4
8
|
from loqusdb.constants import CHROM_TO_INT, GENOTYPE_MAP, GRCH37, PAR
|
5
|
-
from loqusdb.models import Variant
|
9
|
+
from loqusdb.models import Case, Variant
|
6
10
|
|
7
11
|
LOG = logging.getLogger(__name__)
|
8
12
|
|
@@ -139,19 +143,21 @@ def get_coords(variant):
|
|
139
143
|
return coordinates
|
140
144
|
|
141
145
|
|
142
|
-
def build_variant(variant, case_obj, case_id=None, gq_threshold=None, gq_qual=False, genome_build=None):
|
146
|
+
def build_variant(variant: cyvcf2.Variant, case_obj: Case, case_id: Optional[str]=None, gq_threshold: Optional[int]=None, gq_qual: Optional[bool]=False, genome_build: Optional[str]=None) -> Variant:
|
143
147
|
"""Return a Variant object
|
144
148
|
|
145
149
|
Take a cyvcf2 formated variant line and return a models.Variant.
|
146
150
|
|
147
|
-
If
|
151
|
+
If criteria are not fulfilled, eg variant has no GT call or quality.
|
148
152
|
is below gq threshold then return None.
|
149
153
|
|
154
|
+
|
150
155
|
Args:
|
151
156
|
variant(cyvcf2.Variant)
|
152
157
|
case_obj(Case): We need the case object to check individuals sex
|
153
158
|
case_id(str): The case id
|
154
159
|
gq_threshold(int): Genotype Quality threshold
|
160
|
+
gq_qual(bool): Use variant.QUAL for quality instead of GQ
|
155
161
|
|
156
162
|
Return:
|
157
163
|
formated_variant(models.Variant): A variant dictionary
|
@@ -190,7 +196,9 @@ def build_variant(variant, case_obj, case_id=None, gq_threshold=None, gq_qual=Fa
|
|
190
196
|
ind_pos = ind_obj["ind_index"]
|
191
197
|
|
192
198
|
if gq_qual:
|
193
|
-
gq =
|
199
|
+
gq = 0
|
200
|
+
if variant.QUAL:
|
201
|
+
gq = int(variant.QUAL)
|
194
202
|
|
195
203
|
if not gq_qual:
|
196
204
|
gq = int(variant.gt_quals[ind_pos])
|
loqusdb/commands/export.py
CHANGED
@@ -39,7 +39,6 @@ def export(ctx, outfile, variant_type, freq):
|
|
39
39
|
version = ctx.obj["version"]
|
40
40
|
|
41
41
|
LOG.info("Export the variants from {0}".format(adapter))
|
42
|
-
nr_cases = 0
|
43
42
|
|
44
43
|
is_sv = variant_type == "sv"
|
45
44
|
existing_chromosomes = set(adapter.get_chromosomes(sv=is_sv))
|
@@ -52,8 +51,8 @@ def export(ctx, outfile, variant_type, freq):
|
|
52
51
|
for chrom in existing_chromosomes:
|
53
52
|
ordered_chromosomes.append(chrom)
|
54
53
|
|
55
|
-
nr_cases = adapter.
|
56
|
-
LOG.info("Found {
|
54
|
+
nr_cases = adapter.case_count()
|
55
|
+
LOG.info(f"Found {nr_cases} cases in database")
|
57
56
|
|
58
57
|
head = HeaderParser()
|
59
58
|
head.add_fileformat("VCFv4.3")
|
@@ -85,7 +84,7 @@ def export(ctx, outfile, variant_type, freq):
|
|
85
84
|
else:
|
86
85
|
LOG.info("Collecting all SV variants")
|
87
86
|
variants = adapter.get_sv_variants(chromosome=chrom)
|
88
|
-
LOG.info("{} variants found"
|
87
|
+
LOG.info(f"{adapter.nr_variants(chromosome=chrom)} variants found")
|
89
88
|
for variant in variants:
|
90
89
|
variant_line = format_variant(
|
91
90
|
variant, variant_type=variant_type, nr_cases=nr_cases, add_freq=freq
|
loqusdb/commands/identity.py
CHANGED
@@ -17,13 +17,12 @@ def identity(ctx, variant_id):
|
|
17
17
|
ctx.abort()
|
18
18
|
|
19
19
|
adapter = ctx.obj["adapter"]
|
20
|
-
version = ctx.obj["version"]
|
21
20
|
|
22
21
|
LOG.info("Search variants {0}".format(adapter))
|
23
22
|
|
24
|
-
|
25
|
-
if
|
26
|
-
LOG.info("No hits for variant
|
23
|
+
variant_count: int = adapter.db.identity.count_documents({"variant_id": variant_id})
|
24
|
+
if variant_count == 0:
|
25
|
+
LOG.info(f"No hits for variant {variant_id}")
|
27
26
|
return
|
28
27
|
|
29
28
|
for res in result:
|
loqusdb/commands/view.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
import json
|
3
3
|
import logging
|
4
4
|
from pprint import pprint as pp
|
5
|
+
from pymongo.cursor import Cursor
|
5
6
|
|
6
7
|
import click
|
7
8
|
|
@@ -42,10 +43,12 @@ def cases(ctx, case_id, to_json, count, case_type):
|
|
42
43
|
case_obj["_id"] = str(case_obj["_id"])
|
43
44
|
cases.append(case_obj)
|
44
45
|
else:
|
45
|
-
|
46
|
-
if
|
46
|
+
case_count: int = adapter.case_count()
|
47
|
+
if case_count == 0:
|
47
48
|
LOG.info("No cases found in database")
|
48
49
|
ctx.abort()
|
50
|
+
cases: Cursor = adapter.cases()
|
51
|
+
|
49
52
|
|
50
53
|
if to_json:
|
51
54
|
click.echo(json.dumps(cases))
|
loqusdb/plugins/mongo/case.py
CHANGED
@@ -99,13 +99,6 @@ class CaseMixin:
|
|
99
99
|
LOG.info("Removing case {0} from database".format(mongo_case.get("case_id")))
|
100
100
|
self.db.case.delete_one({"_id": mongo_case["_id"]})
|
101
101
|
|
102
|
-
def case_count(self):
|
103
|
-
"""Returns the total number of cases in the database
|
104
|
-
|
105
|
-
returns:
|
106
|
-
nr_of_cases (int): Total number of cases in database
|
107
|
-
"""
|
108
|
-
nr_of_cases = 0
|
109
|
-
res = self.cases
|
110
|
-
|
111
|
-
return res.count()
|
102
|
+
def case_count(self) -> int:
|
103
|
+
"""Returns the total number of cases in the database."""
|
104
|
+
return self.db.case.count_documents({})
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: loqusdb
|
3
|
-
Version: 2.7.
|
3
|
+
Version: 2.7.4
|
4
4
|
Summary: Store observations of vcf variants in a mongodb
|
5
5
|
Home-page: https://github.com/moonso/loqusdb
|
6
6
|
Author: Måns Magnusson
|
@@ -22,16 +22,16 @@ Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
23
23
|
Requires-Dist: pytest ==5.4.3
|
24
24
|
Requires-Dist: cyvcf2 ==0.30.12
|
25
|
-
Requires-Dist: mongomock
|
25
|
+
Requires-Dist: mongomock
|
26
26
|
Requires-Dist: click ==7.1.2
|
27
|
-
Requires-Dist: pymongo
|
27
|
+
Requires-Dist: pymongo
|
28
28
|
Requires-Dist: numpy ==1.21.4
|
29
29
|
Requires-Dist: coloredlogs ==14.0
|
30
30
|
Requires-Dist: pyyaml >=5.4.1
|
31
31
|
Requires-Dist: vcftoolbox ==1.5
|
32
32
|
Requires-Dist: pip ==23.1.2
|
33
33
|
Requires-Dist: setuptools ==65.5.1
|
34
|
-
Requires-Dist: mongo-adapter
|
34
|
+
Requires-Dist: mongo-adapter
|
35
35
|
Requires-Dist: ped-parser
|
36
36
|
|
37
37
|
|
@@ -4,19 +4,19 @@ loqusdb/log.py,sha256=CDcrCjzs9ef-d5Wg8Q_41bCOZRM5j8PyP06kNcynTj0,1691
|
|
4
4
|
loqusdb/build_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
loqusdb/build_models/case.py,sha256=P3sfQkI_fH8u5iqecYWhV866lcHz4upWkepaea5MMIw,4255
|
6
6
|
loqusdb/build_models/profile_variant.py,sha256=TbSxfVjESstS_FgbkOW4NQwMQVeTyhn9oc9yPZmDhzI,1021
|
7
|
-
loqusdb/build_models/variant.py,sha256=
|
7
|
+
loqusdb/build_models/variant.py,sha256=LviEaovB_s_-jaLM64x0NzqzilFr__NPgv4Vf49Rhbk,6939
|
8
8
|
loqusdb/commands/__init__.py,sha256=BXAN3UADgqPrkGczzjlLO9GyyQ96dnLnP7n92JlYHgo,603
|
9
9
|
loqusdb/commands/annotate.py,sha256=748kImopE5WbaO1nuv3WUgIqezWFSsi7SBeWhOz26-s,1384
|
10
10
|
loqusdb/commands/cli.py,sha256=wJD5S1BoCxtRTAobd1QtmQpzlngJg-mt1nsyD92fDD4,3176
|
11
11
|
loqusdb/commands/delete.py,sha256=R6ysHKSMw1mmL4ZbktoUIKzdzDLQ3314YPYhIy1myic,1979
|
12
|
-
loqusdb/commands/export.py,sha256
|
13
|
-
loqusdb/commands/identity.py,sha256=
|
12
|
+
loqusdb/commands/export.py,sha256=-9SHgvr0G8FlyW0FGSfe1dmNDnjx4HKAaa-xYzSkvNc,3238
|
13
|
+
loqusdb/commands/identity.py,sha256=KLA9c8e6cJFDxtqIa1G6zdHTHK1sz2b3v1Utdtik_4k,787
|
14
14
|
loqusdb/commands/load.py,sha256=cVDdY7meBfcv8nMEGsjAX6aE-SKDOceGqM2vAvXPhko,4407
|
15
15
|
loqusdb/commands/load_profile.py,sha256=cflCbF9f77_HCH8xPnN8zSSocvIffRMnC2LPE0j7Xq8,3336
|
16
16
|
loqusdb/commands/migrate.py,sha256=2C8YL-zVqnpnqg3JIyUr0rbVnb8-AGPVWNhicHnPKLo,667
|
17
17
|
loqusdb/commands/restore.py,sha256=eqPX0yao0IAYS5SbjCdlsfSJRBbRByBLISUU2hTzqqs,1492
|
18
18
|
loqusdb/commands/update.py,sha256=zz3wueaJVqJ1FKact-rpY2az__5oa1LnZKf7mgqNGPk,3211
|
19
|
-
loqusdb/commands/view.py,sha256=
|
19
|
+
loqusdb/commands/view.py,sha256=kQ_HuFhIX5wTHoEFC6atH-5unQFkRtopzD2_GqHNPKY,5198
|
20
20
|
loqusdb/commands/wipe.py,sha256=WTOjyNooCUhtmZ6pdcPFa0PZrFc9E_pkLbnat_zP96M,553
|
21
21
|
loqusdb/constants/__init__.py,sha256=r6y2TN8BqbKuh2Uyxq0trh-3A9xiWeStqWlvEPp-rSA,1645
|
22
22
|
loqusdb/exceptions/__init__.py,sha256=Fq0UQg9TepWh19D7WT3dARyAHvorwJF6phhnZi2AkxE,88
|
@@ -31,7 +31,7 @@ loqusdb/models/variant.py,sha256=9QpM0ojJ24tKY9RrcgC411Wjnl3uRUawVYo6RWz1gXY,106
|
|
31
31
|
loqusdb/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
32
32
|
loqusdb/plugins/mongo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
33
33
|
loqusdb/plugins/mongo/adapter.py,sha256=rRUQ2y_bZwjINbdTtfzJ_1JwE0Ns0usyAJ3o0O1Y10I,2593
|
34
|
-
loqusdb/plugins/mongo/case.py,sha256=
|
34
|
+
loqusdb/plugins/mongo/case.py,sha256=zKnaaam8Ey1AEH-1GofXp6iNqgmSvWWxZZWsx7dAO0Y,3006
|
35
35
|
loqusdb/plugins/mongo/profile_variant.py,sha256=madOBa3HacIN_T1V8mp7NEC4QOpqQBqSY6pKTObkMLA,600
|
36
36
|
loqusdb/plugins/mongo/structural_variant.py,sha256=RPc3GF37-O3GqRS9Z5PRxsBXACljfRT4KFsrEl0jCu0,12955
|
37
37
|
loqusdb/plugins/mongo/variant.py,sha256=NS3N8bhRap1b2ZSGjOw2LO6l7q_CzD00GZs499l38Tg,8715
|
@@ -46,9 +46,9 @@ loqusdb/utils/profiling.py,sha256=3OizF7CpYvSl9kyl2g4KGJxbIRUqWfmfLxn3843XYDk,91
|
|
46
46
|
loqusdb/utils/update.py,sha256=1edJG-u24FgOSxyXAQEiyTG4IyK-Uo3lSIl5qyzcXsI,4433
|
47
47
|
loqusdb/utils/variant.py,sha256=Lq5x9egVB-3rExBiRceF67TaL4Hp2gGoWMSRBEcnm4Q,2088
|
48
48
|
loqusdb/utils/vcf.py,sha256=ybmrTBEPYa0FbUXo8ttlwATk13RnKjX9eIDbRDwCiVE,5175
|
49
|
-
loqusdb-2.7.
|
50
|
-
loqusdb-2.7.
|
51
|
-
loqusdb-2.7.
|
52
|
-
loqusdb-2.7.
|
53
|
-
loqusdb-2.7.
|
54
|
-
loqusdb-2.7.
|
49
|
+
loqusdb-2.7.4.dist-info/LICENSE,sha256=urpFcJXw3elN9kV2fFutc-lXegjuu2lqP_GSy8_CAbs,1054
|
50
|
+
loqusdb-2.7.4.dist-info/METADATA,sha256=XxP5xaw8eJa0wWxJn2DCLk9aSd3P2f69-K9s4mw4lSU,6007
|
51
|
+
loqusdb-2.7.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
52
|
+
loqusdb-2.7.4.dist-info/entry_points.txt,sha256=39QklW01vy9ilBLcRPgCP18kN6oKXXLoOK50gZE7Jbs,59
|
53
|
+
loqusdb-2.7.4.dist-info/top_level.txt,sha256=lRdRO6hqPhJEjFhfNsbCgVWMztvkYsjiOGK9DAL0UAI,8
|
54
|
+
loqusdb-2.7.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|