Skip to content

Commit

Permalink
2.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
selva439 committed Jan 7, 2022
1 parent 01a6f0e commit 2b2d987
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 47 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PX Submission Tool is a desktop application to submit the data to proteomeXchang

# Quick Download

[<img src="https://raw.githubusercontent.com/PRIDE-Toolsuite/pride-inspector/master/wiki/download.png">](https://github.com/PRIDE-Archive/px-submission-tool/releases/download/2.5.3/px-submission-tool-2.5.3.zip)
[<img src="https://raw.githubusercontent.com/PRIDE-Toolsuite/pride-inspector/master/wiki/download.png">](https://github.com/PRIDE-Archive/px-submission-tool/releases/download/2.5.3/px-submission-tool-2.5.4.zip)

Please unzip and run `px-submission-tool-<version number>.jar` file!

Expand Down
108 changes: 62 additions & 46 deletions src/main/java/uk/ac/ebi/pride/gui/task/FileScanAndValidationTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand All @@ -53,8 +52,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

/**
* Validate all the files selected in the file selection step
Expand Down Expand Up @@ -113,6 +110,18 @@ protected DataFileValidationMessage doInBackground() throws Exception {
boolean mzTabFilesHaveBeenProvided = !mzTabDataFiles.isEmpty();

boolean noRawFile = submission.getDataFileByType(ProjectFileType.RAW).isEmpty();

List<DataFile> mzMlFiles = submission.getDataFilesByFormat(MassSpecFileFormat.INDEXED_MZML);

if (noRawFile && !mzMlFiles.isEmpty()) {
mzMlFiles.stream().forEach(mzMlFile -> {
mzMlFile.setFileType(ProjectFileType.RAW);
submission.removeDataFile(mzMlFile);
});
submission.addDataFiles(mzMlFiles);
noRawFile = false;
}

boolean noSearchFile = submission.getDataFileByType(ProjectFileType.SEARCH).isEmpty();

List<DataFile> resultDataFiles = submission.getDataFileByType(ProjectFileType.RESULT);
Expand Down Expand Up @@ -296,11 +305,12 @@ protected DataFileValidationMessage doInBackground() throws Exception {
}

boolean isSdrfFound = false;
for (DataFile dataFile : submission.getDataFiles()) {
if (dataFile.getFileType().equals(ProjectFileType.EXPERIMENTAL_DESIGN)) {
for(DataFile dataFile : submission.getDataFiles()){
if(dataFile.getFileType().equals(ProjectFileType.EXPERIMENTAL_DESIGN)){
isSdrfFound = true;
Set<ValidationError> errors = Main.validate(dataFile.getFilePath(), true);
if (errors.size() != 0) {
Set<ValidationError> errors = Main.validate(dataFile.getFilePath(),true);
if(errors.size() !=0){
logger.error("Error in file " + dataFile.getFileName());
return new DataFileValidationMessage(ValidationState.ERROR, WarningMessageGenerator.getInvalidSDRFFileWarning());
}
}
Expand Down Expand Up @@ -403,7 +413,8 @@ private Map<DataFile, Set<String>> checkMzTabFileReferences(List<DataFile> mzTab
String errorEntry = "";
if (mzTabFile.getMzTabDocument().getMetaData().getMsRunEntry(msRunIndex).getLocation() != null) {
String referencedFile = FilenameUtils.getName(mzTabFile.getMzTabDocument().getMetaData().getMsRunEntry(msRunIndex).getLocation().toString());
if (!dataFiles.keySet().contains(referencedFile.toLowerCase())) {

if (!dataFiles.keySet().stream().anyMatch(dataFile -> dataFile.contains(referencedFile.toLowerCase()))) {
// Flag the error
errorFlagged = true;
// The referenced file is not part of the submission files
Expand All @@ -417,7 +428,11 @@ private Map<DataFile, Set<String>> checkMzTabFileReferences(List<DataFile> mzTab
} else {
// The file is in the list of files part of the current submission process
// Check that the referenced file is a Peak List / RAW file
ProjectFileType referencedDataFileType = dataFiles.get(referencedFile.toLowerCase()).getFileType();
DataFile referencedDataFile = dataFiles.get(referencedFile.toLowerCase());
if (referencedDataFile == null) {
referencedDataFile = dataFiles.get(referencedFile.toLowerCase() + ".gz");
}
ProjectFileType referencedDataFileType = referencedDataFile.getFileType();
if (referencedDataFileType != ProjectFileType.PEAK && referencedDataFileType != ProjectFileType.RAW) {
// Flag the error
errorFlagged = true;
Expand All @@ -430,6 +445,8 @@ private Map<DataFile, Set<String>> checkMzTabFileReferences(List<DataFile> mzTab
errorEntry = "NON-Peak List/RAW referenced file '"
+ referencedFile
+ "', is NOT ALLOWED";
} else {
mzTabFile.addFileMapping(referencedDataFile);
}
}
} else {
Expand Down Expand Up @@ -521,7 +538,6 @@ private void scanForFileMappings() {
if (peakFiles.size() == 1) {
addFileMapping(resultOrSearchFiles, peakFiles.iterator().next());
}

}

private void addFileMapping(List<DataFile> resultOrSearchFiles, DataFile dataFile) {
Expand Down Expand Up @@ -645,42 +661,42 @@ private QuickValidationResult runQuickValidation(List<DataFile> dataFiles) {
*/
private boolean isValidRawCompressedFile(DataFile dataFile) {
boolean isValid = true;
int rawFileCount = 0;

String ext = FileUtil.getFileExtension(dataFile.getFile());

try {
if (ext != null) {
if ("zip".equalsIgnoreCase(ext)) {
ZipFile zipFile = new ZipFile(dataFile.getFile());
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements() && rawFileCount <= 1) {
ZipEntry entry = entries.nextElement();
if (!entry.isDirectory()) {
String fileName = entry.getName();
String fileExtension = FileUtil.getFileExtension(fileName);
if (fileExtension != null) {
if (fileExtension.toUpperCase().equals("RAW")) {
rawFileCount++;
}
} else {
isValid = false;
break;
}
}
}

} // gzip can compress only single file, therefore, we do not need to check gzip
}
} catch (IOException e) {
isValid = false;
e.printStackTrace();
}

if ((rawFileCount > 1)) {
isValid = false;
logger.error("Multiple .RAW files found in " + dataFile.getFile().getName() + ". Please unzip them and upload individually");
}
// int rawFileCount = 0;
//
// String ext = FileUtil.getFileExtension(dataFile.getFile());
//
// try {
// if (ext != null) {
// if ("zip".equalsIgnoreCase(ext)) {
// ZipFile zipFile = new ZipFile(dataFile.getFile());
// Enumeration<? extends ZipEntry> entries = zipFile.entries();
// while (entries.hasMoreElements() && rawFileCount <= 1) {
// ZipEntry entry = entries.nextElement();
// if (!entry.isDirectory()) {
// String fileName = entry.getName();
// String fileExtension = FileUtil.getFileExtension(fileName);
// if (fileExtension != null) {
// if (fileExtension.toUpperCase().equals("RAW")) {
// rawFileCount++;
// }
// } else {
// isValid = false;
// break;
// }
// }
// }
//
// } // gzip can compress only single file, therefore, we do not need to check gzip
// }
// } catch (IOException e) {
// isValid = false;
// e.printStackTrace();
// }
//
// if ((rawFileCount > 1)) {
// isValid = false;
// logger.error("Multiple .RAW files found in " + dataFile.getFile().getName() + ". Please unzip them and upload individually");
// }
return isValid;
}

Expand Down

0 comments on commit 2b2d987

Please sign in to comment.