diff --git a/Tests/test_dataset.py b/Tests/test_dataset.py index 4762101..69e5fe9 100644 --- a/Tests/test_dataset.py +++ b/Tests/test_dataset.py @@ -1261,7 +1261,10 @@ class test_dataset_addsampleinfo(unittest.TestCase): def setUp(self): self.Data = nPYc.MSDataset(os.path.join('..','..','npc-standard-project','Derived_Data','UnitTest1_PCSOP.069_QI.csv'), fileType='QI') - self.Data.addSampleInfo(descriptionFormat='Filenames') + try: + self.Data.addSampleInfo(descriptionFormat='Filenames') + except nPYc.utilities._errorHandling.npycToolboxError: + pass # This is user warning, not an error so can be ignored def test_dataset_load_npc_lims(self): diff --git a/Tests/test_msdataset.py b/Tests/test_msdataset.py index d1ed7c7..9180277 100644 --- a/Tests/test_msdataset.py +++ b/Tests/test_msdataset.py @@ -1394,8 +1394,10 @@ class test_msdataset_import_QI(unittest.TestCase): def setUp(self): self.msData = nPYc.MSDataset(os.path.join('..','..','npc-standard-project','Derived_Data','UnitTest1_PCSOP.069_QI.csv'), fileType='QI') - - self.msData.addSampleInfo(descriptionFormat='Filenames') + try: + self.msData.addSampleInfo(descriptionFormat='Filenames') + except nPYc.utilities._errorHandling.npycToolboxError: + pass # This is user warning, not an error so can be ignored def test_dimensions(self): @@ -1883,10 +1885,16 @@ def setUp(self): path = os.path.join('..','..','npc-standard-project','Derived_Data', 'UnitTest1_PCSOP.069_Metaboscape.xlsx') self.lcData = nPYc.MSDataset(path, fileType='Metaboscape', noFeatureParams=18, sheetName='Test Data') - self.lcData.addSampleInfo(descriptionFormat='Filenames') + try: + self.lcData.addSampleInfo(descriptionFormat='Filenames') + except nPYc.utilities._errorHandling.npycToolboxError: + pass # This is user warning, not an error so can be ignored self.diData = nPYc.MSDataset(path, fileType='Metaboscape', noFeatureParams=16, sheetName='Test Data (DI)') - self.diData.addSampleInfo(descriptionFormat='Filenames') + try: + self.diData.addSampleInfo(descriptionFormat='Filenames') + except nPYc.utilities._errorHandling.npycToolboxError: + pass # This is user warning, not an error so can be ignored def test_dimensions(self): @@ -2058,7 +2066,10 @@ def test_csv_import(self): path = os.path.join('..','..','npc-standard-project','Derived_Data', 'UnitTest1_PCSOP.069_Metaboscape_LC.csv') lcData = nPYc.MSDataset(path, fileType='Metaboscape', noFeatureParams=18) - lcData.addSampleInfo(descriptionFormat='Filenames') + try: + lcData.addSampleInfo(descriptionFormat='Filenames') + except nPYc.utilities._errorHandling.npycToolboxError: + pass # This is user warning, not an error so can be ignored assert_frame_equal(self.lcData.sampleMetadata, lcData.sampleMetadata) numpy.testing.assert_array_equal(self.lcData.intensityData, lcData.intensityData) @@ -2188,7 +2199,10 @@ class test_msdataset_addsampleinfo(unittest.TestCase): def setUp(self): self.msData = nPYc.MSDataset(os.path.join('..','..','npc-standard-project','Derived_Data','UnitTest1_PCSOP.069_QI.csv'), fileType='QI') - self.msData.addSampleInfo(descriptionFormat='Filenames') + try: + self.msData.addSampleInfo(descriptionFormat='Filenames') + except nPYc.utilities._errorHandling.npycToolboxError: + pass # This is user warning, not an error so can be ignored def test_msdataset_load_npc_lims(self): diff --git a/Tests/test_reports.py b/Tests/test_reports.py index 1e11a87..9cbc69d 100644 --- a/Tests/test_reports.py +++ b/Tests/test_reports.py @@ -41,7 +41,10 @@ def setUp(self): self.msData = nPYc.MSDataset( os.path.join('..', '..', 'npc-standard-project', 'Derived_Data', 'UnitTest1_PCSOP.069_QI.csv'), fileType='QI') - self.msData.addSampleInfo(descriptionFormat='Filenames') + try: + self.msData.addSampleInfo(descriptionFormat='Filenames') + except nPYc.utilities._errorHandling.npycToolboxError: + pass # This is user warning, not an error so can be ignored self.msData.sampleMetadata['Correction Batch'] = 1 self.msData.sampleMetadata['Run Order'] = [i for i in range(1, self.msData.noSamples + 1)] @@ -79,7 +82,10 @@ def setUp(self): self.data = nPYc.MSDataset( os.path.join('..', '..', 'npc-standard-project', 'Derived_Data', 'UnitTest1_PCSOP.069_QI.csv'), fileType='QI') - self.data.addSampleInfo(descriptionFormat='Filenames') + try: + self.data.addSampleInfo(descriptionFormat='Filenames') + except nPYc.utilities._errorHandling.npycToolboxError: + pass # This is user warning, not an error so can be ignored self.data.addSampleInfo(descriptionFormat='Raw Data', filePath=os.path.join('..', '..', 'npc-standard-project', 'Raw_Data', 'ms', 'parameters_data')) @@ -141,7 +147,7 @@ def test_report_samplesummary_postexclusion(self): assert sampleSummary['Acquired'].loc['Long-Term Reference', 'Total'] == 1 assert sampleSummary['Acquired'].loc['Serial Dilution', 'Total'] == 92 assert sampleSummary['Acquired'].loc['Blank', 'Total'] == 2 - assert 'Unspecified SampleType or AssayRole' not in sampleSummary['Acquired'].index + assert sampleSummary['Acquired'].loc['Unknown', 'Total'] == 0 # Acquired - Marked for exclusion assert sampleSummary['Acquired'].loc['All', 'Marked for Exclusion'] == 0 @@ -150,14 +156,16 @@ def test_report_samplesummary_postexclusion(self): assert sampleSummary['Acquired'].loc['Long-Term Reference', 'Marked for Exclusion'] == 0 assert sampleSummary['Acquired'].loc['Serial Dilution', 'Marked for Exclusion'] == 0 assert sampleSummary['Acquired'].loc['Blank', 'Marked for Exclusion'] == 0 + assert sampleSummary['Acquired'].loc['Unknown', 'Marked for Exclusion'] == 0 # Acquired - Already Excluded - assert sampleSummary['Acquired'].loc['All', 'Missing/Excluded'] == 3 - assert sampleSummary['Acquired'].loc['Study Sample', 'Missing/Excluded'] == 3 + assert sampleSummary['Acquired'].loc['All', 'Missing/Excluded'] == 5 + assert sampleSummary['Acquired'].loc['Study Sample', 'Missing/Excluded'] == 4 assert sampleSummary['Acquired'].loc['Study Reference', 'Missing/Excluded'] == 0 assert sampleSummary['Acquired'].loc['Long-Term Reference', 'Missing/Excluded'] == 0 assert sampleSummary['Acquired'].loc['Serial Dilution', 'Missing/Excluded'] == 0 assert sampleSummary['Acquired'].loc['Blank', 'Missing/Excluded'] == 0 + assert sampleSummary['Acquired'].loc['Unknown', 'Missing/Excluded'] == 1 class test_reports_nmr_generatereport(unittest.TestCase): @@ -466,6 +474,7 @@ def setUp(self): 'SampleType': [SampleType.StudySample, SampleType.StudySample, SampleType.StudySample], + 'SampleClass': ['Study Sample', 'Study Sample', 'Study Sample'], 'Dilution': [numpy.nan, numpy.nan, numpy.nan], 'Correction Batch': [numpy.nan, numpy.nan, numpy.nan], 'Subject ID': ['', '', ''], 'Sample ID': ['', '', ''], @@ -879,7 +888,10 @@ def test_reports_final_peakpanther(self): data = nPYc.MSDataset( os.path.join('..', '..', 'npc-standard-project', 'Derived_Data', 'UnitTest1_PCSOP.069_QI.csv'), fileType='QI') - data.addSampleInfo(descriptionFormat='Filenames') + try: + data.addSampleInfo(descriptionFormat='Filenames') + except nPYc.utilities._errorHandling.npycToolboxError: + pass # This is user warning, not an error so can be ignored data.addSampleInfo(descriptionFormat='Raw Data', filePath=os.path.join('..', '..', 'npc-standard-project', 'Raw_Data', 'ms', 'parameters_data')) diff --git a/nPYc/reports/_generateSampleReport.py b/nPYc/reports/_generateSampleReport.py index 3b8d613..8977f21 100644 --- a/nPYc/reports/_generateSampleReport.py +++ b/nPYc/reports/_generateSampleReport.py @@ -215,8 +215,8 @@ def _generateSampleReport(dataTrue, withExclusions=False, destinationPath=None, if SS_exclusions.shape[0] != 0: sampleSummary['StudySamples Exclusion Details'] = SS_exclusions - # Drop rows where no samples present for that datatype - sampleSummary['Acquired'].drop(sampleSummary['Acquired'].index[sampleSummary['Acquired']['Total'].values == 0], axis=0, inplace=True) + # Drop rows where no samples present for that datatype across any column + sampleSummary['Acquired'].drop(sampleSummary['Acquired'].index[sampleSummary['Acquired'].sum(axis=1) == 0], axis=0, inplace=True) # Update 'All', 'Missing/Excluded' to only reflect sample types present in data sampleSummary['Acquired'].loc['All', 'Missing/Excluded'] = sum(sampleSummary['Acquired']['Missing/Excluded'][1:])