diff --git a/pom.xml b/pom.xml
index 2821011..b72b514 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,12 +12,19 @@
UTF-8
1.0.2
2.0.28
+ 2.0.31-SNAPSHOT
1.2.0
2.3.1
1.3.15
+ 1.0.7
+
+ cpdetector
+ cpdetector
+ ${cpdetector}
+
de.mpc.pia
pia
@@ -55,7 +62,11 @@
com.sun.xml.bind
jaxb-xjc
-
+
+
+ net.sourceforge.cpdetector
+ cpdetector
+
@@ -270,6 +281,17 @@
nexus-ebi-snapshot-repo
http://www.ebi.ac.uk/Tools/maven/repos/content/groups/ebi-snapshots/
+
+ nexus-ebi-intact-repo
+ https://www.ebi.ac.uk/intact/maven/nexus/content/repositories/ebi-repo/
+
+
+
+ genesis-maven2-repository
+ Genesis maven2 repository
+ http://genesis.ugent.be/maven2
+ default
+
pst-release
EBI Nexus Repository
diff --git a/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/SubmissionToolValidator.java b/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/SubmissionToolValidator.java
index 4f346a7..28c419f 100644
--- a/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/SubmissionToolValidator.java
+++ b/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/SubmissionToolValidator.java
@@ -4,6 +4,7 @@
import org.apache.log4j.Logger;
import uk.ac.ebi.pride.toolsuite.px_validator.utils.IReport;
+import java.io.File;
import java.util.*;
import static uk.ac.ebi.pride.toolsuite.px_validator.utils.Utility.*;
@@ -30,8 +31,14 @@ public static void main(String[] args) {
if (args.length > 0) {
if (cmd.hasOption(ARG_VALIDATION)) {
IReport report = Validator.startValidation(cmd);
- if (report != null)
- log.info(report.toString());
+ if (report != null) {
+ if(cmd.hasOption(ARG_REPORTFILE)){
+ File outputFile = cmd.hasOption(ARG_REPORTFILE) ? new File(cmd.getOptionValue(ARG_REPORTFILE)) : null;
+ outputReport(report, outputFile);
+ }else {
+ log.info(report.toString());
+ }
+ }
} else {
log.error("Did not find validation command from arguments ");
Arrays.stream(args).forEach(log::error);
diff --git a/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/Validator.java b/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/Validator.java
index 7964292..18a15d4 100644
--- a/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/Validator.java
+++ b/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/Validator.java
@@ -84,7 +84,7 @@ private static List getFilesToValidate(File file) {
* @param cmd the command line arguments.
* @return List of peak files.
*/
- private static List getPeakFiles(CommandLine cmd) {
+ public static List getPeakFiles(CommandLine cmd) {
List peakFiles = new ArrayList<>();
if (cmd.hasOption(ARG_PEAK) || cmd.hasOption(ARG_PEAKS)) {
String[] peakFilesString = cmd.hasOption(ARG_PEAK) ? cmd.getOptionValues(ARG_PEAK)
diff --git a/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/utils/Report.java b/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/utils/Report.java
index 0a0bb3f..c6ac77e 100644
--- a/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/utils/Report.java
+++ b/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/utils/Report.java
@@ -34,7 +34,7 @@ public String toString() {
for(Map.Entry er: errors)
error.append(er.getKey().toString()).append(" == Level Error: ").append(er.getValue()).append(" ==\n");
if(errors.isEmpty()){
- error.append("No errors found -- OK").append("\n");
+ error.append("Errors found: None").append("\n");
}
return error.toString();
}
diff --git a/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/utils/ResultReport.java b/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/utils/ResultReport.java
index b86f0a2..b5c6214 100644
--- a/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/utils/ResultReport.java
+++ b/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/utils/ResultReport.java
@@ -8,6 +8,7 @@ public class ResultReport extends Report {
private int numberOfProteins;
private int numberOfPeptides;
private int numberOfPSMs;
+ private int numberOfPeakFiles;
public ResultReport() {
@@ -25,10 +26,15 @@ public void setNumberOfPSMs(int numberOfPSMs) {
this.numberOfPSMs = numberOfPSMs;
}
+ public void setNumberOfPeakFiles(int numberOfPeakFiles) {
+ this.numberOfPeakFiles = numberOfPeakFiles;
+ }
+
@Override
public String toString() {
- return super.toString() + "\nIdentification results Report: \nNumber of reported proteins -- " + numberOfProteins + "\n" +
- "Number of reported peptides -- " + numberOfPeptides + "\n" +
- "Number of reported PSMs -- " + numberOfPSMs + "\n";
+ return super.toString() + "Number of reported proteins : " + numberOfProteins + "\n" +
+ "Number of reported peptides : " + numberOfPeptides + "\n" +
+ "Number of reported PSMs : " + numberOfPSMs + "\n" +
+ "Number of peak files : " + numberOfPeakFiles + "\n";
}
}
diff --git a/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/utils/Utility.java b/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/utils/Utility.java
index 52c4b55..31b91cb 100644
--- a/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/utils/Utility.java
+++ b/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/utils/Utility.java
@@ -104,4 +104,29 @@ public static File createNewTempFile(File file) {
}
return tempFile;
}
+
+ public static void outputReport(IReport report, File reportFile){
+ log.info(report.toString());
+ if (reportFile!=null) {
+ try {
+ log.info("Writing report to: " + reportFile.getAbsolutePath());
+ java.nio.file.Files.write(reportFile.toPath(), report.toString().getBytes());
+ } catch (IOException ioe) {
+ log.error("Problem when writing report file: ", ioe);
+ }
+ }
+ }
+
+ public static String getRealFileName(String fileName) {
+ String name = fileName;
+
+ if (name.contains("/") || name.contains("\\")) {
+ String[] parts = name.split("/");
+ name = parts[parts.length - 1];
+ parts = name.split("\\\\");
+ name = parts[parts.length - 1];
+ }
+
+ return name;
+ }
}
diff --git a/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/validators/MzIdValidator.java b/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/validators/MzIdValidator.java
index 80b2ee0..4122598 100644
--- a/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/validators/MzIdValidator.java
+++ b/src/main/java/uk/ac/ebi/pride/toolsuite/px_validator/validators/MzIdValidator.java
@@ -2,8 +2,10 @@
import de.mpc.pia.intermediate.compiler.PIASimpleCompiler;
import de.mpc.pia.intermediate.compiler.parser.InputFileParserFactory;
+import de.mpc.pia.modeller.PIAModeller;
import org.apache.commons.cli.CommandLine;
import org.xml.sax.SAXException;
+import uk.ac.ebi.jmzidml.model.mzidml.SpectraData;
import uk.ac.ebi.pride.data.validation.ValidationMessage;
import uk.ac.ebi.pride.tools.ErrorHandlerIface;
import uk.ac.ebi.pride.tools.GenericSchemaValidator;
@@ -13,11 +15,15 @@
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
public class MzIdValidator implements Validator{
private File file;
+ private List peakFiles;
private static final String MZID_SCHEMA = "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/psi-pi/mzIdentML1.1.0.xsd";
public static Validator getInstance(CommandLine cmd) throws Exception {
@@ -35,6 +41,7 @@ private MzIdValidator(CommandLine cmd) throws Exception{
}else{
throw new IOException("In order to validate a mzid file the argument -mzid should be provided");
}
+ peakFiles = uk.ac.ebi.pride.toolsuite.px_validator.Validator.getPeakFiles(cmd);
}
@Override
@@ -50,13 +57,23 @@ public IReport validate() {
piaCompiler.buildClusterList();
piaCompiler.buildIntermediateStructure();
+ List spectrumFiles = getPeakFiles(piaCompiler);
+ List peakFilesError = validatePeakFiles(spectrumFiles);
+ if(peakFilesError.size() > 0){
+ for(String error: peakFilesError){
+ report.addException(new IOException(error), ValidationMessage.Type.ERROR);
+ }
+ }
+
int numProteins = piaCompiler.getNrAccessions();
int numPeptides = piaCompiler.getNrPeptides();
int numPSMs = piaCompiler.getNrPeptideSpectrumMatches();
+ int numPeakFiles = spectrumFiles.size();
((ResultReport) report).setNumberOfPeptides(numPeptides);
((ResultReport) report).setNumberOfProteins(numProteins);
((ResultReport) report).setNumberOfPSMs(numPSMs);
+ ((ResultReport) report).setNumberOfPeakFiles(numPeakFiles);
return report;
}
@@ -77,4 +94,47 @@ private static IReport validateMzidSchema(File mzIdentML) {
}
return report;
}
+
+ private List getPeakFiles(PIASimpleCompiler piaCompiler){
+ PIAModeller piaModeller = null;
+ try {
+ if (piaCompiler.getAllPeptideSpectrumMatcheIDs() != null
+ && !piaCompiler.getAllPeptideSpectrumMatcheIDs().isEmpty()) {
+ File inferenceTempFile = File.createTempFile("assay", ".tmp");
+ piaCompiler.writeOutXML(inferenceTempFile);
+ piaCompiler.finish();
+ piaModeller = new PIAModeller(inferenceTempFile.getAbsolutePath());
+
+ if (inferenceTempFile.exists()) {
+ inferenceTempFile.deleteOnExit();
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ piaModeller.getSpectraData();
+
+ return piaModeller.getSpectraData()
+ .entrySet().stream().map(Map.Entry::getValue)
+ .collect(Collectors.toList());
+ }
+
+ private List validatePeakFiles(List spectraDataFiles){
+ List peakFileErrors = new ArrayList<>();
+
+ for(File peakFile: this.peakFiles){
+ boolean isFound = false;
+ for (SpectraData spectraData : spectraDataFiles) {
+ String filename = Utility.getRealFileName(spectraData.getLocation());
+ if(filename.equals(peakFile.getName())){
+ isFound = true;
+ break;
+ }
+ }
+ if(!isFound){
+ peakFileErrors.add(peakFile.getName() + " does not found as a reference in MzIdentML");
+ }
+ }
+ return peakFileErrors;
+ }
}