Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Metadata Assay name and Study name validation. #87

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import uk.ac.ebi.pride.jmztab2.utils.parser.MZTabParserContext;

/**
* Validates that the quantification method section is present in metadata.
* Validates that the assay section is present in metadata.
*
* @author nilshoffmann
*/
Expand All @@ -42,6 +42,11 @@ public List<MZTabError> validateRefine(Metadata metadata, MZTabParserContext par
}

for (Integer id : assayMap.keySet()) {
if (assayMap.get(id).getName() == null || assayMap.get(id).getName().isBlank()) {
errorList.add(new MZTabError(
LogicalErrorType.NotDefineInMetadata, -1,
Metadata.Properties.assay + "[" + id + "]" + "\t<" + Assay.Properties.name + ">"));
}
if (assayMap.get(id).
getMsRunRef() == null || assayMap.get(id).
getMsRunRef().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,19 @@ public List<MZTabError> validateRefine(Metadata metadata, MZTabParserContext par
if (sv == null) {
errorList.add(new MZTabError(
LogicalErrorType.NotDefineInMetadata, -1,
Metadata.Properties.studyVariable + "[" + id + "]" + "\t" + "<NAME>"));
Metadata.Properties.studyVariable + "[" + id + "]" + "\t<" + StudyVariable.Properties.name + ">"));
} else {
if (sv.getName() == null) {
errorList.add(new MZTabError(
LogicalErrorType.NotDefineInMetadata, -1,
Metadata.Properties.studyVariable + "[" + id + "]" + "\t" + "<NAME>"));
Metadata.Properties.studyVariable + "[" + id + "]" + "\t<" + StudyVariable.Properties.name + ">"));
} else {
if (sv.getName().equals("undefined")) {
if (undefinedDefined) {
errorList.add(new MZTabError(
LogicalErrorType.UndefinedStudyVariableNameOnceOnly, -1,
Metadata.Properties.studyVariable + "[" + id + "]" + "\t" + "<NAME>"));
Metadata.Properties.studyVariable + "[" + id + "]" + "\t<" + StudyVariable.Properties.name
+ ">"));
} else {
undefinedDefined = true;
}
Expand All @@ -76,7 +77,7 @@ public List<MZTabError> validateRefine(Metadata metadata, MZTabParserContext par
getDescription() == null) {
errorList.add(new MZTabError(
LogicalErrorType.NotDefineInMetadata, -1,
Metadata.Properties.studyVariable + "[" + id + "]-" + StudyVariable.Properties.description + "\t" + "<DESCRIPTION>"));
Metadata.Properties.studyVariable + "[" + id + "]-" + StudyVariable.Properties.description));
}
if (sv.
getAssayRefs() == null || sv.getAssayRefs().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ public void testValidateRefineNullAssay() {
assertEquals(expResult.size(), result.size());
assertEquals(expResult.get(0).toString(), result.get(0).toString());
}

@Test
public void testValidateMissingName() {
Metadata metadata = new Metadata();
metadata.addAssayItem(new Assay().id(1));
MZTabParserContext parserContext = new MZTabParserContext();
AssayValidator instance = new AssayValidator();
List<MZTabError> expResult = Arrays.asList(new MZTabError(
LogicalErrorType.NotDefineInMetadata, -1,
Metadata.Properties.assay + ""));
List<MZTabError> result = instance.validateRefine(metadata, parserContext);
assertEquals(expResult.size(), result.size());
assertEquals(expResult.get(0).toString(), result.get(0).toString());
}

/**
* Test of validateRefine method for assay requiring a linked ms run, of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ public void testTwoStudyVariableMultipleAssaysMissingNamesAndMissingDescription(
List<MZTabError> expResult = Arrays.asList(
new MZTabError(
LogicalErrorType.NotDefineInMetadata, -1,
Metadata.Properties.studyVariable + "[" + 1 + "]" + "\t" + "<NAME>"),
Metadata.Properties.studyVariable + "[" + 1 + "]" + "\t<" + StudyVariable.Properties.name+">"),
new MZTabError(
LogicalErrorType.NotDefineInMetadata, -1,
Metadata.Properties.studyVariable + "[" + 2 + "]" + "\t" + "<NAME>"),
Metadata.Properties.studyVariable + "[" + 2 + "]" + "\t<" + StudyVariable.Properties.name+">"),
new MZTabError(
LogicalErrorType.NotDefineInMetadata, -1,
Metadata.Properties.studyVariable + "[" + 2 + "]-" + StudyVariable.Properties.description + "\t" + "<DESCRIPTION>")
Metadata.Properties.studyVariable + "[" + 2 + "]-" + StudyVariable.Properties.description)
);
List<MZTabError> result = instance.validateRefine(metadata, parserContext);
assertEquals(expResult.size(), result.size());
Expand Down Expand Up @@ -134,7 +134,7 @@ public void testTwoStudyVariableMultipleAssaysMultipleUndefinedStudyVariables()
List<MZTabError> expResult = Arrays.asList(
new MZTabError(
LogicalErrorType.UndefinedStudyVariableNameOnceOnly, -1,
Metadata.Properties.studyVariable + "[" + 2 + "]" + "\t" + "<NAME>")
Metadata.Properties.studyVariable + "[" + 2 + "]" + "\t<" + StudyVariable.Properties.name+">")
);
List<MZTabError> result = instance.validateRefine(metadata, parserContext);
assertEquals(expResult.size(), result.size());
Expand Down
Loading