loqusdb 2.7.2__tar.gz → 2.7.8__tar.gz

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 (106) hide show
  1. {loqusdb-2.7.2 → loqusdb-2.7.8}/PKG-INFO +27 -29
  2. {loqusdb-2.7.2 → loqusdb-2.7.8}/README.md +11 -11
  3. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/__init__.py +5 -3
  4. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/build_models/variant.py +12 -4
  5. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/commands/export.py +3 -4
  6. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/commands/identity.py +3 -4
  7. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/commands/view.py +5 -2
  8. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/plugins/mongo/case.py +3 -10
  9. loqusdb-2.7.8/loqusdb/resources/loqusdb.20181005.gz +0 -0
  10. loqusdb-2.7.8/loqusdb/resources/maf_50_sites_GRCh37.vcf.gz +0 -0
  11. loqusdb-2.7.8/loqusdb/resources/maf_50_sites_GRCh38.vcf.gz +0 -0
  12. loqusdb-2.7.8/pyproject.toml +38 -0
  13. loqusdb-2.7.8/tests/commands/test_export.py +16 -0
  14. loqusdb-2.7.8/tests/commands/test_identity.py +22 -0
  15. loqusdb-2.7.8/tests/commands/test_view.py +17 -0
  16. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/conftest.py +2 -2
  17. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/fixtures/profile_snv.vcf +1 -1
  18. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/vcf_tools/test_format_variant.py +14 -0
  19. loqusdb-2.7.2/CHANGELOG.md +0 -66
  20. loqusdb-2.7.2/CONTRIBUTING.md +0 -5
  21. loqusdb-2.7.2/MANIFEST.in +0 -10
  22. loqusdb-2.7.2/loqusdb.egg-info/PKG-INFO +0 -174
  23. loqusdb-2.7.2/loqusdb.egg-info/SOURCES.txt +0 -97
  24. loqusdb-2.7.2/loqusdb.egg-info/dependency_links.txt +0 -1
  25. loqusdb-2.7.2/loqusdb.egg-info/entry_points.txt +0 -3
  26. loqusdb-2.7.2/loqusdb.egg-info/requires.txt +0 -13
  27. loqusdb-2.7.2/loqusdb.egg-info/top_level.txt +0 -1
  28. loqusdb-2.7.2/setup.cfg +0 -4
  29. loqusdb-2.7.2/setup.py +0 -83
  30. {loqusdb-2.7.2 → loqusdb-2.7.8}/LICENSE +0 -0
  31. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/__main__.py +0 -0
  32. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/build_models/__init__.py +0 -0
  33. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/build_models/case.py +0 -0
  34. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/build_models/profile_variant.py +0 -0
  35. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/commands/__init__.py +0 -0
  36. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/commands/annotate.py +0 -0
  37. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/commands/cli.py +0 -0
  38. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/commands/delete.py +0 -0
  39. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/commands/load.py +0 -0
  40. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/commands/load_profile.py +0 -0
  41. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/commands/migrate.py +0 -0
  42. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/commands/restore.py +0 -0
  43. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/commands/update.py +0 -0
  44. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/commands/wipe.py +0 -0
  45. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/constants/__init__.py +0 -0
  46. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/exceptions/__init__.py +0 -0
  47. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/exceptions/case.py +0 -0
  48. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/exceptions/profile.py +0 -0
  49. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/exceptions/vcf.py +0 -0
  50. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/log.py +0 -0
  51. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/models/__init__.py +0 -0
  52. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/models/case.py +0 -0
  53. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/models/identity.py +0 -0
  54. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/models/profile_variant.py +0 -0
  55. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/models/variant.py +0 -0
  56. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/plugins/__init__.py +0 -0
  57. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/plugins/mongo/__init__.py +0 -0
  58. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/plugins/mongo/adapter.py +0 -0
  59. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/plugins/mongo/profile_variant.py +0 -0
  60. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/plugins/mongo/structural_variant.py +0 -0
  61. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/plugins/mongo/variant.py +0 -0
  62. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/resources/__init__.py +0 -0
  63. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/utils/__init__.py +0 -0
  64. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/utils/annotate.py +0 -0
  65. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/utils/case.py +0 -0
  66. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/utils/delete.py +0 -0
  67. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/utils/load.py +0 -0
  68. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/utils/migrate.py +0 -0
  69. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/utils/profiling.py +0 -0
  70. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/utils/update.py +0 -0
  71. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/utils/variant.py +0 -0
  72. {loqusdb-2.7.2 → loqusdb-2.7.8}/loqusdb/utils/vcf.py +0 -0
  73. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/build_models/test_build_case.py +0 -0
  74. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/build_models/test_build_variant.py +0 -0
  75. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/build_models/test_is_greater.py +0 -0
  76. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/fixtures/643594.clinical.SV.vcf +0 -0
  77. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/fixtures/643594.clinical.vcf.gz +0 -0
  78. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/fixtures/double_variant.vcf +0 -0
  79. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/fixtures/funny_trio.ped +0 -0
  80. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/fixtures/recessive_trio.ped +0 -0
  81. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/fixtures/test.SV.vcf +0 -0
  82. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/fixtures/test.vcf +0 -0
  83. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/fixtures/test.vcf.gz +0 -0
  84. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/fixtures/test.vcf.gz.tbi +0 -0
  85. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/fixtures/unsorted.vcf +0 -0
  86. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/functional/test_cli.py +0 -0
  87. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/plugins/mongo/test_case_operations.py +0 -0
  88. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/plugins/mongo/test_connect.py +0 -0
  89. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/plugins/mongo/test_flask_extension.py +0 -0
  90. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/plugins/mongo/test_get_sv.py +0 -0
  91. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/plugins/mongo/test_load_svs.py +0 -0
  92. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/plugins/mongo/test_variant_operations.py +0 -0
  93. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/utils/test_case.py +0 -0
  94. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/utils/test_delete.py +0 -0
  95. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/utils/test_delete_family.py +0 -0
  96. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/utils/test_delete_variant.py +0 -0
  97. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/utils/test_get_family.py +0 -0
  98. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/utils/test_load_database.py +0 -0
  99. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/utils/test_load_family.py +0 -0
  100. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/utils/test_load_variants.py +0 -0
  101. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/utils/test_migrate.py +0 -0
  102. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/utils/test_profiling.py +0 -0
  103. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/vcf_tools/test_check_par.py +0 -0
  104. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/vcf_tools/test_check_vcf.py +0 -0
  105. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/vcf_tools/test_format_sv_variant.py +0 -0
  106. {loqusdb-2.7.2 → loqusdb-2.7.8}/tests/vcf_tools/test_vcf.py +0 -0
@@ -1,50 +1,49 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: loqusdb
3
- Version: 2.7.2
4
- Summary: Store observations of vcf variants in a mongodb
5
- Home-page: https://github.com/moonso/loqusdb
6
- Author: Måns Magnusson
7
- Author-email: mans.magnusson@scilifelab.com
3
+ Version: 2.7.8
4
+ Summary: A simple observation count database
8
5
  License: MIT
9
- Keywords: vcf,variants
10
- Platform: UNKNOWN
6
+ Author: Your Name
7
+ Author-email: you@example.com
8
+ Requires-Python: >=3.12,<4.0
11
9
  Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Programming Language :: Python
13
10
  Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.6
15
- Classifier: Programming Language :: Python :: Implementation :: CPython
16
- Classifier: Operating System :: MacOS :: MacOS X
17
- Classifier: Operating System :: Unix
18
- Classifier: Intended Audience :: Science/Research
19
- Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
20
- Requires-Python: >=3.7.0
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Requires-Dist: PyYAML
13
+ Requires-Dist: click
14
+ Requires-Dist: coloredlogs
15
+ Requires-Dist: cyvcf2
16
+ Requires-Dist: mongo-adapter
17
+ Requires-Dist: numpy
18
+ Requires-Dist: ped_parser
19
+ Requires-Dist: pymongo
20
+ Requires-Dist: setuptools
21
+ Requires-Dist: vcftoolbox
21
22
  Description-Content-Type: text/markdown
22
- License-File: LICENSE
23
-
24
23
 
25
24
  # loqusdb
26
25
  [![Publish to PyPI](https://github.com/moonso/loqusdb/actions/workflows/build_and_publish.yml/badge.svg)](https://github.com/moonso/loqusdb/actions/workflows/build_and_publish.yml)
27
26
  [![Coverage Status](https://coveralls.io/repos/github/moonso/loqusdb/badge.svg?branch=master)](https://coveralls.io/github/moonso/loqusdb?branch=master)
28
27
  [![PyPI Version][pypi-img]][pypi-url]
29
28
 
30
- Small tool to setup a local variant database. If you find loqusdb useful in your work, please cite the [article][publication].
29
+ Small tool to set up a local variant database.
30
+ If you find Loqusdb useful in your work, please cite the [article][publication].
31
31
 
32
- Right now **locusdb** uses [mongodb][mongodb] as backend for
33
- storing variants but there should not be a huge difference to use another
32
+ Right now **Locusdb** uses [mongodb][mongodb] as backend for
33
+ storing variants, but there should not be a huge difference to use another
34
34
  database manager.
35
35
 
36
36
  ## Installation ##
37
37
 
38
- These instructions were written and tested using a conda environment with a version of **Python >=3.9**, which is required by the installer file (setup.py).
39
38
 
40
- `pip install loqusdb`
39
+ `poetry install`
41
40
 
42
41
  or
43
42
 
44
43
  ```
45
44
  $git clone https://github.com/moonso/loqusdb
46
45
  $cd loqusdb
47
- $pip install --editable .
46
+ $poetry install
48
47
  ```
49
48
 
50
49
  ## Idea ##
@@ -54,16 +53,16 @@ This is **NOT** a tool to create a true frequency database.
54
53
  It will basically count the number of times we have seen a variant in any individual.
55
54
  We will also keep track of the variants that have been seen in a homozygous or hemizygous state.
56
55
 
57
- Variants are stored by providing a vcf file and a (ped or ped like)family file.
56
+ Variants are stored by providing a VCF file and a (ped or ped like) family file.
58
57
 
59
- Loqusdb will first check if the vcf file looks ok.
58
+ Loqusdb will first check if the VCF file adheres to the VCF format.
60
59
 
61
60
  The tool will then check all variants if they have been observed in any of the individuals in the family.
62
61
 
63
62
  When the variants are added:
64
63
 
65
64
  - Either the variant exists, in this case we increase the number of observations with one
66
- - Or this variant has not ben seen before, then the variant is added to database
65
+ - Or this variant has not been seen before, then the variant is added to the database
67
66
 
68
67
 
69
68
  ## Command Line Interface ##
@@ -120,7 +119,7 @@ Commands:
120
119
 
121
120
  ### Connecting ###
122
121
 
123
- 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, looks like:
122
+ 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:
124
123
 
125
124
  ```yaml
126
125
  uri: mongodb://loqusdb-username:loqusdb-pwd@localhost:27030/loqusdb-rd?authSource=admin
@@ -138,7 +137,7 @@ db_name: loqusdb_test
138
137
 
139
138
  ### Mongo ###
140
139
 
141
- The collections looks like:
140
+ The collections are defined as follows:
142
141
 
143
142
  **Case**
144
143
 
@@ -171,4 +170,3 @@ The collections looks like:
171
170
  [pypi-img]: https://img.shields.io/pypi/v/loqusdb.svg?style=flat-square
172
171
  [pypi-url]: https://pypi.python.org/pypi/loqusdb/
173
172
 
174
-
@@ -3,24 +3,24 @@
3
3
  [![Coverage Status](https://coveralls.io/repos/github/moonso/loqusdb/badge.svg?branch=master)](https://coveralls.io/github/moonso/loqusdb?branch=master)
4
4
  [![PyPI Version][pypi-img]][pypi-url]
5
5
 
6
- Small tool to setup a local variant database. If you find loqusdb useful in your work, please cite the [article][publication].
6
+ Small tool to set up a local variant database.
7
+ If you find Loqusdb useful in your work, please cite the [article][publication].
7
8
 
8
- Right now **locusdb** uses [mongodb][mongodb] as backend for
9
- storing variants but there should not be a huge difference to use another
9
+ Right now **Locusdb** uses [mongodb][mongodb] as backend for
10
+ storing variants, but there should not be a huge difference to use another
10
11
  database manager.
11
12
 
12
13
  ## Installation ##
13
14
 
14
- These instructions were written and tested using a conda environment with a version of **Python >=3.9**, which is required by the installer file (setup.py).
15
15
 
16
- `pip install loqusdb`
16
+ `poetry install`
17
17
 
18
18
  or
19
19
 
20
20
  ```
21
21
  $git clone https://github.com/moonso/loqusdb
22
22
  $cd loqusdb
23
- $pip install --editable .
23
+ $poetry install
24
24
  ```
25
25
 
26
26
  ## Idea ##
@@ -30,16 +30,16 @@ This is **NOT** a tool to create a true frequency database.
30
30
  It will basically count the number of times we have seen a variant in any individual.
31
31
  We will also keep track of the variants that have been seen in a homozygous or hemizygous state.
32
32
 
33
- Variants are stored by providing a vcf file and a (ped or ped like)family file.
33
+ Variants are stored by providing a VCF file and a (ped or ped like) family file.
34
34
 
35
- Loqusdb will first check if the vcf file looks ok.
35
+ Loqusdb will first check if the VCF file adheres to the VCF format.
36
36
 
37
37
  The tool will then check all variants if they have been observed in any of the individuals in the family.
38
38
 
39
39
  When the variants are added:
40
40
 
41
41
  - Either the variant exists, in this case we increase the number of observations with one
42
- - Or this variant has not ben seen before, then the variant is added to database
42
+ - Or this variant has not been seen before, then the variant is added to the database
43
43
 
44
44
 
45
45
  ## Command Line Interface ##
@@ -96,7 +96,7 @@ Commands:
96
96
 
97
97
  ### Connecting ###
98
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, looks like:
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
100
 
101
101
  ```yaml
102
102
  uri: mongodb://loqusdb-username:loqusdb-pwd@localhost:27030/loqusdb-rd?authSource=admin
@@ -114,7 +114,7 @@ db_name: loqusdb_test
114
114
 
115
115
  ### Mongo ###
116
116
 
117
- The collections looks like:
117
+ The collections are defined as follows:
118
118
 
119
119
  **Case**
120
120
 
@@ -1,11 +1,10 @@
1
1
  import logging
2
2
 
3
- from pkg_resources import get_distribution
4
3
  from pymongo import ASCENDING, IndexModel
5
4
 
6
5
  logger = logging.getLogger(__name__)
7
6
 
8
- __version__ = get_distribution("loqusdb").version
7
+ __version__ = "2.7.7"
9
8
 
10
9
  INDEXES = {
11
10
  "variant": [
@@ -28,12 +27,14 @@ INDEXES = {
28
27
  "structural_variant": [
29
28
  IndexModel(
30
29
  [
30
+ ("sv_type", ASCENDING),
31
31
  ("chrom", ASCENDING),
32
32
  ("end_chrom", ASCENDING),
33
- ("sv_type", ASCENDING),
34
33
  ("pos_left", ASCENDING),
34
+ ("pos_right", ASCENDING),
35
35
  ],
36
36
  name="coordinates",
37
+ background=True,
37
38
  ),
38
39
  IndexModel(
39
40
  [
@@ -42,6 +43,7 @@ INDEXES = {
42
43
  ("end_right", ASCENDING),
43
44
  ],
44
45
  name="short_coordinates",
46
+ background=True,
45
47
  ),
46
48
  ],
47
49
  "identity": [
@@ -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 criterias are not fullfilled, eg. variant have no gt call or quality
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 = int(variant.QUAL)
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])
@@ -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.cases().count()
56
- LOG.info("Found {0} cases in database".format(nr_cases))
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".format(variants.count()))
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
@@ -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
- result = adapter.get_clusters(variant_id)
25
- if result.count() == 0:
26
- LOG.info("No hits for variant %s", variant_id)
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:
@@ -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
- cases = adapter.cases()
46
- if cases.count() == 0:
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))
@@ -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({})
@@ -0,0 +1,38 @@
1
+ [tool.poetry]
2
+ name = "loqusdb"
3
+ version = "2.7.8"
4
+ description = "A simple observation count database"
5
+ authors = ["Your Name <you@example.com>"]
6
+ license = "MIT"
7
+ readme = "README.md"
8
+ include = [
9
+ "README.md",
10
+ "loqusdb/**/*",
11
+ "tests/**/*"
12
+ ]
13
+
14
+ [tool.poetry.dependencies]
15
+ python = "^3.12"
16
+ cyvcf2 = "*"
17
+ click = "*"
18
+ pymongo = "*"
19
+ numpy = "*"
20
+ coloredlogs = "*"
21
+ PyYAML = "*"
22
+ vcftoolbox = "*"
23
+ setuptools = "*"
24
+ mongo-adapter = "*"
25
+ ped_parser = "*"
26
+
27
+ [tool.poetry.group.dev.dependencies]
28
+ coveralls = "^3"
29
+ mongomock = "*"
30
+ pytest = "*"
31
+ pytest-cov = "*"
32
+
33
+ [tool.poetry.scripts]
34
+ loqusdb = "loqusdb.commands.cli:cli"
35
+
36
+ [build-system]
37
+ requires = ["poetry-core"]
38
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,16 @@
1
+ from click.testing import CliRunner
2
+
3
+ from loqusdb.commands.cli import cli as base_command
4
+
5
+ def test_export_base(real_db_name:str):
6
+ """Test the base command that exports variants."""
7
+
8
+ runner = CliRunner()
9
+
10
+ # WHEN the base command to export cases is run
11
+ command = ["--database", real_db_name, "export"]
12
+
13
+ ## THEN it should return success
14
+ result = runner.invoke(base_command, command)
15
+ assert result.exit_code == 0
16
+
@@ -0,0 +1,22 @@
1
+ from click.testing import CliRunner
2
+
3
+ from loqusdb.commands.cli import cli as base_command
4
+
5
+ def test_identity(real_db_name:str):
6
+ """Test the SV identity base command."""
7
+
8
+ runner = CliRunner()
9
+
10
+ # WHEN the base identity command is run on an empty database
11
+ command = ["--database", real_db_name, "identity", "-v", "1_7890024_TGA_GGG"]
12
+
13
+ # THEN the command should return success
14
+ result = runner.invoke(base_command, command)
15
+ assert result.exit_code == 0
16
+
17
+ # AND no variant found message
18
+ assert "No hits for variant" in result.output
19
+
20
+
21
+
22
+
@@ -0,0 +1,17 @@
1
+ from click.testing import CliRunner
2
+ from loqusdb.plugins.mongo.adapter import MongoAdapter
3
+ from loqusdb.commands.cli import cli as base_command
4
+
5
+ def test_view_cases_base(real_mongo_adapter: MongoAdapter, real_db_name:str):
6
+ """Test the base command that returns database cases."""
7
+
8
+ ## GIVEN an empty database
9
+ assert sum([1 for _ in real_mongo_adapter.cases()]) == 0
10
+
11
+ runner = CliRunner()
12
+
13
+ # THEN the case command should return No cases found error
14
+ command = ["--database", real_db_name, "cases" ]
15
+ result = runner.invoke(base_command, command)
16
+ assert result.exit_code == 1
17
+ assert "No cases found in database" in result.output
@@ -65,14 +65,14 @@ def real_db_name(request):
65
65
  @pytest.fixture(scope="function")
66
66
  def mongo_client(request):
67
67
  """Return a mongomock client"""
68
- client = MockClient()
68
+ client = MockClient(directConnection=True)
69
69
  return client
70
70
 
71
71
 
72
72
  @pytest.fixture(scope="function")
73
73
  def real_mongo_client(request):
74
74
  """Return a mongomock client"""
75
- client = MongoClient()
75
+ client = MongoClient(directConnection=True)
76
76
 
77
77
  def teardown():
78
78
  print("\n")
@@ -25,7 +25,7 @@
25
25
  ##contig=<ID=Y,length=59373566>
26
26
  ##contig=<ID=MT,length=16569>
27
27
  ##reference=file:///humgen/gsa-hpprojects/GATK/bundle/current/b37/human_g1k_v37.fasta
28
- #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT proband_2
28
+ #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT proband_2
29
29
  1 44072018 rs1065772 C T . . CAF=[0.7121,0.2879];COMMON=1;G5;GNO;HD;KGPROD;KGPhase1;OTHERKG;PH3;REF;RS=1065772;RSPOS=44072018;SAO=0;SLO;SSR=0;SYN;VC=SNV;VLD;VP=0x050100000301150517000100;WGT=1;dbSNPBuildID=86 GT ./.
30
30
  1 183072590 rs2296288 T C . . CAF=[0.4656,0.5344];COMMON=1;G5;G5A;GNO;HD;KGPROD;KGPhase1;KGPilot123;OTHERKG;PH3;REF;RS=2296288;RSPOS=183072590;SAO=0;SLO;SSR=0;SYN;VC=SNV;VLD;VP=0x05010000030117051f000100;WGT=1;dbSNPBuildID=100 GT ./.
31
31
  1 212619339 rs4804 T C . . CAF=[0.5069,0.4931];COMMON=1;G5;G5A;GNO;HD;KGPROD;KGPhase1;KGPilot123;OTHERKG;PH3;REF;RS=4804;RSPOS=212619339;SAO=0;SLO;SSR=0;SYN;VC=SNV;VLD;VP=0x05010000030117051f000101;WGT=1;dbSNPBuildID=52 GT ./.
@@ -21,6 +21,20 @@ def test_format_variant(het_variant, case_obj):
21
21
  assert formated_variant["homozygote"] == 0
22
22
 
23
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
+
24
38
  def test_format_variant_no_gq(variant_no_gq, case_obj):
25
39
  ## GIVEN a variant without GQ
26
40
  variant = variant_no_gq
@@ -1,66 +0,0 @@
1
- # Change Log
2
- All notable changes to this project will be documented in this file.
3
- This project adheres to [Semantic Versioning](http://semver.org/).
4
-
5
- About changelog [here](https://keepachangelog.com/en/1.0.0/)
6
-
7
- ## [unreleased]
8
- ### Fixed
9
- - `Deprecated config in setup.cfg` error when installing the package
10
-
11
- ## [2.7.1]
12
- ### Added
13
- - Script to correct contig name
14
- - Expanded instructions on how to set up an instance and load data into database
15
- ### Changed
16
- - GitHub actions run tests using MongoDB versions 3.2, 4.4 and 5.0
17
- ### Fixed
18
- - Restore command accepts custom database name
19
- - Restore command uses either database URI or host:port params
20
-
21
- ## [2.5.2]
22
-
23
- ### Changed
24
- - Convert version to string
25
- - Use Github Actions for running CI instead of Travis
26
-
27
- ## [2.5.1]
28
-
29
- ### Added
30
- - Option to add observation frequencies to exported VCF (--freq)
31
-
32
- ## [2.5]
33
-
34
- ### Added
35
- - Profiling feature added. Each sample gets a profile based on the genotypes for
36
- a set of high maf variants.
37
- - High maf variants used in profiling is loaded into DB via CLI
38
- - Reject loading a case if a similar profile already exists for any of the samples
39
- - Statistics of the profiles in DB can be generated through CLI
40
- - use bulk operations when deleting variants
41
- - Compatible with GRCh38
42
- - Option to include case count when querying for a variant
43
-
44
- ### Fixed
45
- - Use correct fields in index
46
-
47
- ## [2.3]
48
-
49
- ### Added
50
- - Use bulk updates when inserting snvs
51
-
52
- ## [2.2]
53
-
54
- ### Added
55
- - CLI function to annotate variants
56
- - CLI functionality to dump and restore a database
57
-
58
- ## [2.1]
59
-
60
- ### Fixed
61
- - Fix bug with inserting variants
62
-
63
- ### [2.0]
64
-
65
- ### Added
66
- - Adds structural variants to loqus
@@ -1,5 +0,0 @@
1
- ## Versioning
2
- LoqusDB adheres to [semantic versioning](https://semver.org/).
3
-
4
- ## Branching model
5
- LoqusDB follows a githubflow [branching model](https://guides.github.com/introduction/flow/).
loqusdb-2.7.2/MANIFEST.in DELETED
@@ -1,10 +0,0 @@
1
- include AUTHORS
2
- include CONTRIBUTING.md
3
- include CHANGELOG.md
4
- include LICENSE
5
- include README.md
6
-
7
- recursive-include tests *
8
- recursive-exclude * __pycache__
9
- recursive-exclude * *.py[co]
10
- recursive-exclude * *.db