Skip to content

Commit

Permalink
fixed MSExperimentSampleDataFormat validation
Browse files Browse the repository at this point in the history
  • Loading branch information
VinzentRisch committed Jan 17, 2025
1 parent a090206 commit 6de90b9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions q2_ms/types/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,12 @@ def _validate_(self, level):

class MSExperimentSampleDataFormat(model.TextFileFormat):
def _validate(self):
header_exp = ["sample_name", "sample_group", "spectraOrigin"]

header_obs = pd.read_csv(str(self), sep="\t", nrows=0).columns.tolist()

if header_exp != header_obs:
if len(header_obs) != 3 or header_obs[2] != "spectraOrigin":
raise ValidationError(
"Header does not match MSExperimentSampleDataFormat. It must "
"consist of the following columns:\n"
+ ", ".join(header_exp)
"Header does not match MSExperimentSampleDataFormat. It must consist "
"of three columns where the third column is called 'spectraOrigin':"
+ "\n\nFound instead:\n"
+ ", ".join(header_obs)
)
Expand Down

0 comments on commit 6de90b9

Please sign in to comment.