Repository: Sage-Bionetworks/Genie

Issue:
Validation of clinical files fails with numpy error
I have encountered the following error when performing validation on patient and sample clinical files.

```
docker run -v $(pwd):/data --rm sagebionetworks/genie genie --syn_user ###### --syn_pass ############ validate /data/data_clinical_supp_patient_PROV.txt /data/data_clinical_supp_sample_PROV.txt PROV

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
INFO:genie.example_filetype_format:VALIDATING data_clinical_supp_sample_PROV.txt
Traceback (most recent call last):
  File "/usr/local/bin/genie", line 33, in <module>
    sys.exit(load_entry_point('aacrgenie', 'console_scripts', 'genie')())
  File "/root/Genie/genie/__main__.py", line 149, in main
    args.func(syn, args)
  File "/root/Genie/genie/validate.py", line 260, in _perform_validate
    valid, message = validator.validate_single_file(**mykwargs)
  File "/root/Genie/genie/validate.py", line 91, in validate_single_file
    valid, errors, warnings = validator.validate(filePathList=filepathlist,
  File "/root/Genie/genie/example_filetype_format.py", line 173, in validate
    errors, warnings = self._validate(df, **mykwargs)
  File "/root/Genie/genie_registry/clinical.py", line 833, in _validate
    if not sample_class_vals.isin(['Tumor', 'cfDNA']).all():
AttributeError: 'numpy.ndarray' object has no attribute 'isin'
```

Discussion:

Patch:
diff --git a/genie_registry/clinical.py b/genie_registry/clinical.py
index 5ebd360..90fca60 100644
--- a/genie_registry/clinical.py
+++ b/genie_registry/clinical.py
@@ -898,11 +898,11 @@ class Clinical(FileTypeFormat):
         # CHECK: SAMPLE_CLASS is optional attribute
         have_column = process_functions.checkColExist(clinicaldf, "SAMPLE_CLASS")
         if have_column:
-            sample_class_vals = clinicaldf["SAMPLE_CLASS"].unique()
+            sample_class_vals = pd.Series(clinicaldf["SAMPLE_CLASS"].unique().tolist())
             if not sample_class_vals.isin(["Tumor", "cfDNA"]).all():
                 total_error.write(
-                    "Sample Clinical File: SAMPLE_CLASS column must"
-                    "be 'Tumor', or 'cfDNA'"
+                    "Sample Clinical File: SAMPLE_CLASS column must "
+                    "be 'Tumor', or 'cfDNA'\n"
                 )
 
         # CHECK: PRIMARY_RACE


Test patch:
diff --git a/tests/test_clinical.py b/tests/test_clinical.py
index eb5be59..8668f71 100644
--- a/tests/test_clinical.py
+++ b/tests/test_clinical.py
@@ -293,7 +293,8 @@ def test_perfect__validate():
         ONCOTREE_CODE=['AMPCA', 'AMPCA', 'Unknown', 'AMPCA', 'AMPCA'],
         SAMPLE_TYPE=[1, 2, 3, 4, 4],
         SEQ_ASSAY_ID=['SAGE-1-1', 'SAGE-SAGE-1', 'SAGE-1', 'SAGE-1', 'SAGE-1'],
-        SEQ_DATE=['Jan-2013', 'ApR-2013', 'Jul-2013', 'Oct-2013', 'release']))
+        SEQ_DATE=['Jan-2013', 'ApR-2013', 'Jul-2013', 'Oct-2013', 'release'],
+        SAMPLE_CLASS=["Tumor", "cfDNA", "cfDNA", "cfDNA", "cfDNA"]))
 
     clinicaldf = patientdf.merge(sampledf, on="PATIENT_ID")
     with mock.patch(
@@ -334,7 +335,9 @@ def test_nonull__validate():
         ONCOTREE_CODE=['AMPCA', 'AMPCA', 'Unknown', 'AMPCA', 'AMPCA'],
         SAMPLE_TYPE=[1, 2, 3, 4, float('nan')],
         SEQ_ASSAY_ID=['SAGE-1-1', 'SAGE-SAGE-1', 'SAGE-1', 'SAGE-1', 'SAGE-1'],
-        SEQ_DATE=['Jan-2013', 'ApR-2013', 'Jul-2013', 'Oct-2013', 'release']))
+        SEQ_DATE=['Jan-2013', 'ApR-2013', 'Jul-2013', 'Oct-2013', 'release'],
+        SAMPLE_CLASS=["Tumor", "cfDNA", "cfDNA", "cfDNA", float('nan')]
+    ))
 
     clinicaldf = patientdf.merge(sampledf, on="PATIENT_ID")
     with mock.patch(
@@ -371,6 +374,7 @@ def test_nonull__validate():
             "YEAR_CONTACT, INT_CONTACT.\n"
             "Patient: you have inconsistent redaction and text values in "
             "YEAR_DEATH, INT_DOD.\n"
+            "Sample Clinical File: SAMPLE_CLASS column must be 'Tumor', or 'cfDNA'\n"
             "Patient Clinical File: Please double check your PRIMARY_RACE "
             "column.  This column must only be these values: 1, 2, 3, 4, 99\n"
             "Patient Clinical File: Please double check your SECONDARY_RACE "