Skip to content

Commit

Permalink
linting, standardizing
Browse files Browse the repository at this point in the history
  • Loading branch information
rxu17 committed Nov 7, 2023
1 parent 4fea695 commit 780ee66
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
4 changes: 2 additions & 2 deletions genie_registry/maf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class maf(FileTypeFormat):
_process_kwargs = []
_allele_cols = ["REFERENCE_ALLELE", "TUMOR_SEQ_ALLELE1", "TUMOR_SEQ_ALLELE2"]
_allowed_comb_alleles = ["A", "T", "C", "G", "N"]
_allowed_ind_alleles = ['-']
_allowed_ind_alleles = ["-"]

def _validateFilename(self, filePath):
"""
Expand Down Expand Up @@ -298,7 +298,7 @@ def _validate(self, mutationDF):
allowed_comb_alleles=self._allowed_comb_alleles,
allowed_ind_alleles=self._allowed_ind_alleles,
ignore_case=True,
allow_na=False
allow_na=False,
)
errors, warnings = validate.get_allele_validation_message(
invalid_indices,
Expand Down
37 changes: 19 additions & 18 deletions genie_registry/vcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class vcf(FileTypeFormat):
_fileType = "vcf"

_process_kwargs = []
_allele_col = "REF"
_allele_cols = ["REF"]
_allowed_comb_alleles = ["A", "T", "C", "G", "N"]
_allowed_ind_alleles = []

Expand Down Expand Up @@ -140,24 +140,25 @@ def _validate(self, vcfdf):
total_error += error
warning += warn

if process_functions.checkColExist(vcfdf, self._allele_col):
invalid_indices = validate.get_invalid_allele_rows(
vcfdf,
input_col=self._allele_col,
allowed_comb_alleles=self._allowed_comb_alleles,
allowed_ind_alleles=self._allowed_ind_alleles,
ignore_case=True,
allow_na=False
for allele_col in self._allele_cols:
if process_functions.checkColExist(vcfdf, allele_col):
invalid_indices = validate.get_invalid_allele_rows(
vcfdf,
input_col=allele_col,
allowed_comb_alleles=self._allowed_comb_alleles,
allowed_ind_alleles=self._allowed_ind_alleles,
ignore_case=True,
allow_na=False,
)
errors, warnings = validate.get_allele_validation_message(
invalid_indices,
invalid_col=self._allele_col,
allowed_comb_alleles=self._allowed_comb_alleles,
allowed_ind_alleles=self._allowed_ind_alleles,
fileformat=self._fileType,
)
total_error += errors
warning += warnings
errors, warnings = validate.get_allele_validation_message(
invalid_indices,
invalid_col=allele_col,
allowed_comb_alleles=self._allowed_comb_alleles,
allowed_ind_alleles=self._allowed_ind_alleles,
fileformat=self._fileType,
)
total_error += errors
warning += warnings

# No white spaces
white_space = vcfdf.apply(lambda x: contains_whitespace(x), axis=1)
Expand Down
8 changes: 7 additions & 1 deletion tests/test_maf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ def valid_maf_df():
dict(
CHROMOSOME=[1, 2, 3, 4, 5],
START_POSITION=[1, 2, 3, 4, 2],
REFERENCE_ALLELE=["A", "A", "A", "A", "A"],
REFERENCE_ALLELE=[
"C",
"G",
"NA",
"-",
"TAAAGATCGTACAGAA",
],
TUMOR_SAMPLE_BARCODE=[
"GENIE-SAGE-ID1-1",
"GENIE-SAGE-ID1-1",
Expand Down

0 comments on commit 780ee66

Please sign in to comment.