001/* 002 * Copyright 2019 Leibniz-Institut für Analytische Wissenschaften – ISAS – e.V.. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package de.isas.mztab2.io.validators; 017 018import de.isas.mztab2.model.Assay; 019import de.isas.mztab2.model.Metadata; 020import java.util.LinkedList; 021import java.util.List; 022import java.util.SortedMap; 023import uk.ac.ebi.pride.jmztab2.utils.errors.LogicalErrorType; 024import uk.ac.ebi.pride.jmztab2.utils.errors.MZTabError; 025import uk.ac.ebi.pride.jmztab2.utils.parser.MZTabParserContext; 026 027/** 028 * Validates that the quantification method section is present in metadata. 029 * 030 * @author nilshoffmann 031 */ 032public class AssayValidator implements MetadataValidator<Metadata> { 033 034 @Override 035 public List<MZTabError> validateRefine(Metadata metadata, MZTabParserContext parserContext) { 036 SortedMap<Integer, Assay> assayMap = parserContext.getAssayMap(); 037 List<MZTabError> errorList = new LinkedList<>(); 038 if (assayMap.isEmpty()) { 039 errorList.add(new MZTabError( 040 LogicalErrorType.NotDefineInMetadata, -1, 041 Metadata.Properties.assay + "")); 042 } 043 044 for (Integer id : assayMap.keySet()) { 045 if (assayMap.get(id). 046 getMsRunRef() == null || assayMap.get(id). 047 getMsRunRef().isEmpty()) { 048 errorList.add(new MZTabError( 049 LogicalErrorType.NotDefineInMetadata, -1, 050 Metadata.Properties.assay + "[" + id + "]-" + Assay.Properties.msRunRef)); 051 } 052 } 053 return errorList; 054 } 055 056}