Skip to content

Commit 73e3a1d

Browse files
authored
Merge pull request #79 from Rohan-cod/0based-1based
Fixed base conversion for Conversion Region Disctionary
2 parents ff35e57 + ef5d07d commit 73e3a1d

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

vcf2fhir/converter.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class Converter(object):
3939
file (conv_region_filename):
4040
4141
**conv_region_dict** : Array of regions (e.g. '{"Chromosome":
42-
["X", "X", "M"],"Start": [50001, 55001, 50001],"End": [52001,
43-
60601, 60026]}'). Values for Chromosome must align with values in
42+
["X", "X", "M"],"Start": [50000, 55000, 50000],"End": [52000,
43+
60600, 60025]}'). Values for Chromosome must align with values in
4444
VCF #CHROM field. Ranges must be `0-based \
4545
<https://www.biostars.org/p/84686/>`_
4646
(or 0-start, half-open) and based on GRCh37 or GRCh38 \
@@ -141,7 +141,6 @@ def __init__(
141141
"Please provide valid 'conv_region_filename'")
142142
elif conv_region_dict:
143143
try:
144-
self._fix_conv_region_zero_based(conv_region_dict)
145144
self.conversion_region = pyranges.from_dict(conv_region_dict)
146145
except FileNotFoundError:
147146
raise
@@ -199,16 +198,6 @@ def convert(self, output_filename='fhir.json'):
199198
output_filename)
200199
general_logger.info("Completed VCF to FHIR Conversion")
201200

202-
def _fix_conv_region_zero_based(self, conv_region_dict):
203-
i = 0
204-
for start in conv_region_dict["Start"]:
205-
conv_region_dict["Start"][i] = start - 1
206-
i += 1
207-
i = 0
208-
for end in conv_region_dict["End"]:
209-
conv_region_dict["End"][i] = end - 1
210-
i += 1
211-
212201
def _generate_exception(self, msg):
213202
general_logger.error(msg, exc_info=True)
214203
raise Exception(msg, sys.exc_info)

vcf2fhir/test/test_integration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def test_conv_region_only(self):
124124
def test_conv_region_dict(self):
125125
conv_region_dict = {
126126
"Chromosome": ["X", "X", "M"],
127-
"Start": [50001, 55001, 50001],
128-
"End": [52001, 60601, 60026]
127+
"Start": [50000, 55000, 50000],
128+
"End": [52000, 60600, 60025]
129129
}
130130
o_vcf_2_fhir = vcf2fhir.Converter(
131131
os.path.join(
@@ -281,8 +281,8 @@ def test_region_studied(self):
281281
def test_region_studied_dict(self):
282282
conv_region_dict = {
283283
"Chromosome": ["X", "X", "M"],
284-
"Start": [50001, 55001, 50001],
285-
"End": [52001, 60601, 60026]
284+
"Start": [50000, 55000, 50000],
285+
"End": [52000, 60600, 60025]
286286
}
287287
self.maxDiff = None
288288
region_studied_filename = os.path.join(

0 commit comments

Comments
 (0)