Skip to content

Commit a29a995

Browse files
committed
added unit test
1 parent 9fb2c04 commit a29a995

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tests/test_convert_gvf_to_vcf.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def setUp(self):
1818
self.dgva_input_file = os.path.join(self.input_folder_parent, "etc","dgvaINFOattributes.tsv")
1919
self.gvf_input_file = os.path.join(self.input_folder_parent, "etc","gvfINFOattributes.tsv")
2020
self.output_file = os.path.join(input_folder, "input", "a.vcf")
21+
self.assembly = os.path.join(input_folder, "input", "zebrafish.fa")
2122

2223
def test_read_in_gvf_file(self):
2324
gvf_pragmas, gvf_non_essential, gvf_lines_obj_list = read_in_gvf_file(self.input_file)
@@ -37,6 +38,7 @@ def test_gvf_features_to_vcf_objects(self):
3738
gvf_pragmas, gvf_non_essential, gvf_lines_obj_list = read_in_gvf_file(self.input_file)
3839
dgva_attribute_dict = read_dgva_info_attributes(self.dgva_input_file)
3940
gvf_attribute_dict = read_gvf_info_attributes(self.gvf_input_file)
41+
assembly_file = self.assembly
4042
# custom meta-information lines for this VCF file
4143
lines_custom_structured = []
4244
lines_custom_unstructured = []
@@ -52,7 +54,9 @@ def test_gvf_features_to_vcf_objects(self):
5254
all_possible_FORMAT_lines = generate_all_possible_standard_structured_format_lines()
5355

5456
vcf_data_lines, list_of_vcf_objects = gvf_features_to_vcf_objects(gvf_lines_obj_list, dgva_attribute_dict,
55-
gvf_attribute_dict, lines_custom_structured,
57+
gvf_attribute_dict,
58+
assembly_file,
59+
lines_custom_structured,
5660
lines_standard_ALT, lines_standard_INFO,
5761
lines_standard_FILTER, lines_standard_FORMAT,
5862
all_possible_ALT_lines,
@@ -64,12 +68,13 @@ def test_gvf_features_to_vcf_objects(self):
6468
assert len(list_of_vcf_objects) > 1
6569

6670
def test_get_ref(self):
67-
gvf_feature_line = "1 DGVa copy_number_loss 776614 786127 . + . ID=1;Name=nssv1412199;Alias=CNV28955;variant_call_so_id=SO:0001743;parent=nsv811094;Start_range=.,776614;End_range=786127,.;submitter_variant_call_id=CNV28955;sample_name=Wilds2-3;remap_score=.98857;Variant_seq=."
71+
gvf_feature_line = "chromosome1 DGVa copy_number_loss 77 78 . + . ID=1;Name=nssv1412199;Alias=CNV28955;variant_call_so_id=SO:0001743;parent=nsv811094;Start_range=.,776614;End_range=786127,.;submitter_variant_call_id=CNV28955;sample_name=Wilds2-3;remap_score=.98857;Variant_seq=."
6872
f_list = gvf_feature_line.split("\t")
6973
line_object = GvfFeatureline(f_list[0], f_list[1], f_list[2], f_list[3], f_list[4], f_list[5], f_list[6], f_list[7], f_list[8])
7074
gvf_pragmas, gvf_non_essential, gvf_lines_obj_list = read_in_gvf_file(self.input_file)
7175
dgva_attribute_dict = read_dgva_info_attributes(self.dgva_input_file)
7276
gvf_attribute_dict = read_gvf_info_attributes(self.gvf_input_file)
77+
assembly_file = self.assembly
7378
# custom meta-information lines for this VCF file
7479
lines_custom_structured = []
7580
lines_custom_unstructured = []
@@ -87,6 +92,7 @@ def test_get_ref(self):
8792
v = VcfLine(line_object,
8893
dgva_attribute_dict,
8994
gvf_attribute_dict,
95+
assembly_file,
9096
lines_custom_structured,
9197
lines_standard_ALT,
9298
lines_standard_INFO,
@@ -97,12 +103,13 @@ def test_get_ref(self):
97103
all_possible_FILTER_lines,
98104
all_possible_FORMAT_lines)
99105
reference_allele = v.get_ref()
100-
assert reference_allele == "."
106+
assert len(reference_allele) != 0
101107

102108
def test_print_vcf_datalines(self):
103109
gvf_pragmas, gvf_non_essential, gvf_lines_obj_list = read_in_gvf_file(self.input_file)
104110
dgva_attribute_dict = read_dgva_info_attributes(self.dgva_input_file)
105111
gvf_attribute_dict = read_gvf_info_attributes(self.gvf_input_file)
112+
assembly_file = self.assembly
106113
# custom meta-information lines for this VCF file
107114
lines_custom_structured = []
108115
lines_custom_unstructured = []
@@ -119,6 +126,7 @@ def test_print_vcf_datalines(self):
119126
vcf_data_lines, list_of_vcf_objects = gvf_features_to_vcf_objects(gvf_lines_obj_list,
120127
dgva_attribute_dict,
121128
gvf_attribute_dict,
129+
assembly_file,
122130
lines_custom_structured,
123131
lines_standard_ALT,
124132
lines_standard_INFO,
@@ -136,6 +144,7 @@ def test_generate_vcf_metainformation(self):
136144
gvf_pragmas, gvf_non_essential, gvf_lines_obj_list = read_in_gvf_file(self.input_file)
137145
dgva_attribute_dict = read_dgva_info_attributes(self.dgva_input_file)
138146
gvf_attribute_dict = read_gvf_info_attributes(self.gvf_input_file)
147+
assembly_file = self.assembly
139148
# custom meta-information lines for this VCF file
140149
lines_custom_structured = []
141150
lines_custom_unstructured = []
@@ -153,6 +162,7 @@ def test_generate_vcf_metainformation(self):
153162
vcf_data_lines, list_of_vcf_objects = gvf_features_to_vcf_objects(gvf_lines_obj_list,
154163
dgva_attribute_dict,
155164
gvf_attribute_dict,
165+
assembly_file,
156166
lines_custom_structured,
157167
lines_standard_ALT,
158168
lines_standard_INFO,

0 commit comments

Comments
 (0)