loqusdb 2.7.20__py3-none-any.whl → 2.7.22__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 CHANGED
@@ -4,7 +4,7 @@ from pymongo import ASCENDING, IndexModel
4
4
 
5
5
  logger = logging.getLogger(__name__)
6
6
 
7
- __version__ = "2.7.20"
7
+ __version__ = "2.7.22"
8
8
 
9
9
  INDEXES = {
10
10
  "variant": [
@@ -37,7 +37,7 @@ def build_profile_variant(variant, keep_chr_prefix=None):
37
37
 
38
38
  chrom = variant.CHROM
39
39
  if not keep_chr_prefix:
40
- if chrom.startswith(("chr", "CHR", "Chr")):
40
+ if chrom.lower().startswith("chr"):
41
41
  chrom = chrom[3:]
42
42
 
43
43
  pos = int(variant.POS)
@@ -99,7 +99,7 @@ def get_coords(variant, keep_chr_prefix, genome_build):
99
99
  }
100
100
  chrom = variant.CHROM
101
101
  if not keep_chr_prefix:
102
- if chrom.startswith(("chr", "CHR", "Chr")):
102
+ if chrom.lower().startswith("chr"):
103
103
  chrom = chrom[3:]
104
104
  coordinates["chrom"] = chrom
105
105
  end_chrom = chrom
@@ -121,7 +121,7 @@ def get_coords(variant, keep_chr_prefix, genome_build):
121
121
  other_coordinates = alt.strip("ATCGN").strip("[]").split(":")
122
122
  end_chrom = other_coordinates[0]
123
123
  if not keep_chr_prefix:
124
- if end_chrom.startswith(("chr", "CHR", "Chr")):
124
+ if chrom.lower().startswith("chr"):
125
125
  end_chrom = end_chrom[3:]
126
126
 
127
127
  end = int(other_coordinates[1])
@@ -56,9 +56,13 @@ def export(ctx, outfile, variant_type, freq):
56
56
  if genome == GRCH37 and chrom in existing_chromosomes:
57
57
  ordered_chromosomes.append(chrom)
58
58
  existing_chromosomes.remove(chrom)
59
- elif genome == GRCH38 and chrom[3:] in existing_chromosomes:
60
- ordered_chromosomes.append(chrom)
61
- existing_chromosomes.remove(chrom)
59
+ elif genome == GRCH38:
60
+ if chrom[3:] in existing_chromosomes:
61
+ ordered_chromosomes.append(chrom[3:])
62
+ existing_chromosomes.remove(chrom[3:])
63
+ elif chrom in existing_chromosomes:
64
+ ordered_chromosomes.append(chrom)
65
+ existing_chromosomes.remove(chrom)
62
66
  for chrom in existing_chromosomes:
63
67
  ordered_chromosomes.append(chrom)
64
68
 
loqusdb/commands/view.py CHANGED
@@ -117,16 +117,40 @@ def variants(
117
117
  sv_cases = True
118
118
  nr_cases = adapter.nr_cases(snv_cases=snv_cases, sv_cases=sv_cases)
119
119
 
120
+ if chromosome:
121
+ if chromosome.startswith("chr"):
122
+ chromosomes = [chromosome, chromosome[3:]]
123
+ elif not chromosome.startswith("chr"):
124
+ chromosomes = [chromosome, "chr" + chromosome]
125
+
126
+ if end_chromosome:
127
+ if end_chromosome.startswith("chr"):
128
+ end_chromosomes = [end_chromosome, end_chromosome[3:]]
129
+ elif not end_chromosome.startswith("chr"):
130
+ end_chromosomes = [end_chromosome, "chr" + end_chromosome]
131
+ else:
132
+ end_chromosomes = [None, None]
133
+
120
134
  if variant_id:
121
135
  if variant_type == "sv":
122
136
  variant_query = {
123
- "chrom": chromosome,
124
- "end_chrom": end_chromosome or chromosome,
137
+ "chrom": chromosomes[0],
138
+ "end_chrom": end_chromosomes[0] or chromosomes[0],
125
139
  "sv_type": sv_type,
126
140
  "pos": start,
127
141
  "end": end,
128
142
  }
129
- variant = adapter.get_structural_variant(variant_query)
143
+ variant = list(adapter.get_structural_variant(variant_query))
144
+ if len(variant) == 0:
145
+ variant_query = {
146
+ "chrom": chromosomes[1],
147
+ "end_chrom": end_chromosomes[1] or chromosomes[1],
148
+ "sv_type": sv_type,
149
+ "pos": start,
150
+ "end": end,
151
+ }
152
+ variant = adapter.get_structural_variant(variant_query)
153
+
130
154
  else:
131
155
  variant = adapter.get_variant({"_id": variant_id})
132
156
 
@@ -145,18 +169,29 @@ def variants(
145
169
 
146
170
  click.echo(variant)
147
171
  return
148
-
149
172
  if variant_type == "snv":
150
- result = adapter.get_variants(chromosome=chromosome, start=start, end=end)
173
+ result = list(adapter.get_variants(chromosome=chromosomes[0], start=start, end=end))
174
+ if len(result) == 0:
175
+ result = adapter.get_variants(chromosome=chromosomes[1], start=start, end=end)
151
176
  else:
152
177
  LOG.info("Search for svs")
153
- result = adapter.get_sv_variants(
154
- chromosome=chromosome,
155
- end_chromosome=end_chromosome,
156
- sv_type=sv_type,
157
- pos=start,
158
- end=end,
178
+ result = list(
179
+ adapter.get_sv_variants(
180
+ chromosome=chromosomes[0],
181
+ end_chromosome=end_chromosomes[0],
182
+ sv_type=sv_type,
183
+ pos=start,
184
+ end=end,
185
+ )
159
186
  )
187
+ if len(result) == 0:
188
+ result = adapter.get_sv_variants(
189
+ chromosome=chromosomes[1],
190
+ end_chromosome=end_chromosomes[1],
191
+ sv_type=sv_type,
192
+ pos=start,
193
+ end=end,
194
+ )
160
195
 
161
196
  if to_json:
162
197
  json.dumps(variant)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: loqusdb
3
- Version: 2.7.20
3
+ Version: 2.7.22
4
4
  Summary: A simple observation count database
5
5
  License: MIT
6
6
  Author: Your Name
@@ -1,21 +1,21 @@
1
- loqusdb/__init__.py,sha256=HCx0k7_ndzjGnRnnEFruQxC4eQlKosO4gSJ2TP86I1g,1415
1
+ loqusdb/__init__.py,sha256=Y0QmFuaSq7ltbH8xOPBqjJ3cGsEyN4XaFW4giE5d4Ps,1415
2
2
  loqusdb/__main__.py,sha256=8FGKySAGaWSzAYMj6HRsxeyiME3V01Idt7HrmN7pSYY,397
3
3
  loqusdb/build_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  loqusdb/build_models/case.py,sha256=AByutEYK2N3kS9JFvyZfPKNZdCpZHCSD0nNHAgaU1Cs,4127
5
- loqusdb/build_models/profile_variant.py,sha256=WzWhxq4HNvf67IknyBWYnMHQzPMZ9eitw_so6lfOkPc,1166
6
- loqusdb/build_models/variant.py,sha256=4_FDSRUGDt-h3lqBJ00kC9QDdTTGzpbEF-s51AjLQLU,8094
5
+ loqusdb/build_models/profile_variant.py,sha256=ORus7IPhMZQyA8C4v822MzXTW4ZXHRSgmTDC7frkfI4,1158
6
+ loqusdb/build_models/variant.py,sha256=QQqCdZCdpeY-l8unc6GVwORBrgjvKpEk85ItD5Toci4,8074
7
7
  loqusdb/commands/__init__.py,sha256=BXAN3UADgqPrkGczzjlLO9GyyQ96dnLnP7n92JlYHgo,603
8
8
  loqusdb/commands/annotate.py,sha256=MGU9EerKYsFx1lkyjQ6ZMUKYuShi0uSTPJCS0cyxq7U,1467
9
9
  loqusdb/commands/cli.py,sha256=lRgOYN3JDE81z3EUdqc5-eU7i0m5XF8p0WZvI3svQ3g,3577
10
10
  loqusdb/commands/delete.py,sha256=BRtm6Uade3l97FBcKFNkiYjks84AhuXYo-2QD8E74A4,2120
11
- loqusdb/commands/export.py,sha256=3eV0pYfkD73qoB0_Y2_wpxV0xOrCAppVoPs9C815zyI,4078
11
+ loqusdb/commands/export.py,sha256=mbRPOaUgPerLpH7ZKwyI2IzStAIsywZMHJystasLYec,4271
12
12
  loqusdb/commands/identity.py,sha256=KLA9c8e6cJFDxtqIa1G6zdHTHK1sz2b3v1Utdtik_4k,787
13
13
  loqusdb/commands/load.py,sha256=pHtjldblUM-HFFgcN5UtoaxGhYmo1yeexqGq4I427qk,4996
14
14
  loqusdb/commands/load_profile.py,sha256=x-T2bzi2SL5kwZhY_3hHQCtGDLao1xkxj1pZaOnzs4U,3436
15
15
  loqusdb/commands/migrate.py,sha256=2C8YL-zVqnpnqg3JIyUr0rbVnb8-AGPVWNhicHnPKLo,667
16
16
  loqusdb/commands/restore.py,sha256=eqPX0yao0IAYS5SbjCdlsfSJRBbRByBLISUU2hTzqqs,1492
17
17
  loqusdb/commands/update.py,sha256=zz3wueaJVqJ1FKact-rpY2az__5oa1LnZKf7mgqNGPk,3211
18
- loqusdb/commands/view.py,sha256=PkwyvzQgq5ArrEakI-lKQThrhjBLLl2gYejHI2g13WU,5197
18
+ loqusdb/commands/view.py,sha256=JOpgRnlkWRToD9Y5DfPWJ9x1HvIPFHXpi_dZWt29co4,6582
19
19
  loqusdb/commands/wipe.py,sha256=WTOjyNooCUhtmZ6pdcPFa0PZrFc9E_pkLbnat_zP96M,553
20
20
  loqusdb/constants/__init__.py,sha256=BpZQYpUF-B9AqoXE2R5XMFuURxH5iNLt1kUJSKMqZGY,2265
21
21
  loqusdb/exceptions/__init__.py,sha256=Fq0UQg9TepWh19D7WT3dARyAHvorwJF6phhnZi2AkxE,88
@@ -49,8 +49,8 @@ loqusdb/utils/profiling.py,sha256=uISq4xfRNPPedoYXS_D4dXphq8odDogfMBm_XfHBTpE,92
49
49
  loqusdb/utils/update.py,sha256=1edJG-u24FgOSxyXAQEiyTG4IyK-Uo3lSIl5qyzcXsI,4433
50
50
  loqusdb/utils/variant.py,sha256=U6nMZRUf5NDDQ74nG0HBCLMnFQVgFAT6eHll_F2uiwc,2087
51
51
  loqusdb/utils/vcf.py,sha256=og8JBYock31v_0CnsoRhuKIJCurLCIFW8PCCQIRWF-Q,5207
52
- loqusdb-2.7.20.dist-info/LICENSE,sha256=urpFcJXw3elN9kV2fFutc-lXegjuu2lqP_GSy8_CAbs,1054
53
- loqusdb-2.7.20.dist-info/METADATA,sha256=efArcCfHQNeSsFf5C2EPYII5cYFYTf80nmIIpLLFanM,5321
54
- loqusdb-2.7.20.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
55
- loqusdb-2.7.20.dist-info/entry_points.txt,sha256=wFoWzEFjsSgXkj9FMQA8C9ihZoJ9R1XvbGuX9hEEI6E,52
56
- loqusdb-2.7.20.dist-info/RECORD,,
52
+ loqusdb-2.7.22.dist-info/LICENSE,sha256=urpFcJXw3elN9kV2fFutc-lXegjuu2lqP_GSy8_CAbs,1054
53
+ loqusdb-2.7.22.dist-info/METADATA,sha256=UIyXnGX1KUcCWkGadC1Ce3AL17J7EUlKvrVvR3kuKKc,5321
54
+ loqusdb-2.7.22.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
55
+ loqusdb-2.7.22.dist-info/entry_points.txt,sha256=wFoWzEFjsSgXkj9FMQA8C9ihZoJ9R1XvbGuX9hEEI6E,52
56
+ loqusdb-2.7.22.dist-info/RECORD,,