Skip to content

Commit

Permalink
updated addSampleInfo from filenames to list any failing samples and …
Browse files Browse the repository at this point in the history
…remove existing columns
  • Loading branch information
carolinesands committed Aug 1, 2024
1 parent 250ca43 commit aa0b032
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion nPYc/objects/_msDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,17 @@ def _getSampleMetadataFromFilename(self, filenameSpec):

# Merge metadata back into the sampleInfo table.
# first remove duplicate columns (from _dataset _init_)
if 'Study' in self.sampleMetadata.columns: self.sampleMetadata.drop(['Study'], axis=1, inplace=True)
if 'Chromatography' in self.sampleMetadata.columns: self.sampleMetadata.drop(['Chromatography'], axis=1, inplace=True)
if 'Ionisation' in self.sampleMetadata.columns: self.sampleMetadata.drop(['Ionisation'], axis=1, inplace=True)
if 'Instrument' in self.sampleMetadata.columns: self.sampleMetadata.drop(['Instrument'], axis=1, inplace=True)
if 'Re-Run' in self.sampleMetadata.columns: self.sampleMetadata.drop(['Re-Run'], axis=1, inplace=True)
if 'Suplemental Injections' in self.sampleMetadata.columns: self.sampleMetadata.drop(['Suplemental Injections'], axis=1, inplace=True)
if 'SampleClass' in self.sampleMetadata.columns: self.sampleMetadata.drop(['SampleClass'], axis=1, inplace=True)
if 'Skipped' in self.sampleMetadata.columns: self.sampleMetadata.drop(['Skipped'], axis=1, inplace=True)
if 'Matrix' in self.sampleMetadata.columns: self.sampleMetadata.drop(['Matrix'], axis=1, inplace=True)
if 'Well' in self.sampleMetadata.columns: self.sampleMetadata.drop(['Well'], axis=1, inplace=True)
if 'Plate' in self.sampleMetadata.columns: self.sampleMetadata.drop(['Plate'], axis=1, inplace=True)
if 'AssayRole' in self.sampleMetadata.columns: self.sampleMetadata.drop(['AssayRole'], axis=1, inplace=True)
if 'SampleType' in self.sampleMetadata.columns: self.sampleMetadata.drop(['SampleType'], axis=1, inplace=True)
if 'Sample Base Name' in self.sampleMetadata.columns: self.sampleMetadata.drop(['Sample Base Name'], axis=1,
Expand All @@ -1431,7 +1442,8 @@ def _getSampleMetadataFromFilename(self, filenameSpec):

# Return failure message if information not able to be inferred for any sample
if (self.sampleMetadata['Sample Base Name'].isnull().values.any()):
raise npycToolboxError('Inferring information from filenames failed for some samples, check and amend `filenameSpec` as appropriate and re-run')
raise npycToolboxError('Inferring information from filenames failed for some samples, check and amend `filenameSpec` as appropriate and re-run or exclude sample else nPYc-Toolbox functionality may be compromised',
table=self.sampleMetadata.loc[self.sampleMetadata['Sample Base Name'].isnull(), ['Sample File Name', 'Sample Base Name']])


def _inferBatches(self, gapLength=24):
Expand Down

0 comments on commit aa0b032

Please sign in to comment.