From bb07cc8412f4859e1396fa832917e086e1692590 Mon Sep 17 00:00:00 2001 From: julianu Date: Thu, 30 Nov 2023 12:10:48 +0100 Subject: [PATCH 1/4] adding error handling of not existing file --- .../parser/InputFileParserFactory.java | 56 +++++++++++++++---- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/InputFileParserFactory.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/InputFileParserFactory.java index c0118f1d..21624155 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/InputFileParserFactory.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/InputFileParserFactory.java @@ -1,11 +1,15 @@ package de.mpc.pia.intermediate.compiler.parser; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import de.mpc.pia.intermediate.compiler.PIACompiler; +import de.mpc.pia.intermediate.compiler.parser.searchengines.CometCSVFileParser; import de.mpc.pia.intermediate.compiler.parser.searchengines.MascotDatFileParser; import de.mpc.pia.intermediate.compiler.parser.searchengines.TandemFileParser; import de.mpc.pia.intermediate.compiler.parser.searchengines.ThermoMSFFileParser; @@ -14,10 +18,41 @@ public class InputFileParserFactory { /** logger for this class */ - private static final Logger LOGGER = Logger.getLogger(InputFileParserFactory.class); + private static final Logger LOGGER = LogManager.getLogger(); public enum InputFileTypes { + /** + * the input file is a Tide TXT file + */ + COMET_CSV_INPUT { + @Override + public String getFileSuffix() { + return "csv"; + } + + @Override + public String getFileTypeName() { + return "Comet CSV"; + } + + @Override + public String getFileTypeShort() { + return "comet"; + } + + @Override + public boolean checkFileType(String fileName) { + return CometCSVFileParser.checkFileType(fileName); + } + + @Override + public boolean parseFile(String name, String fileName, + PIACompiler compiler, String additionalInfoFileName) { + return CometCSVFileParser.getDataFromCometCSVFile(name, fileName, compiler); + } + }, + /** * the input file is a FASTA database file */ @@ -441,27 +476,28 @@ public static List getAvailableTypeShorts() { public static boolean getDataFromFile(String name, String fileName, PIACompiler compiler, String additionalInfoFileName, String fileType) { + + if (!Files.exists(Path.of(fileName))) { + LOGGER.error("'{}' does not exist, or is not accessible", fileName); + return false; + } if (fileType == null) { InputFileTypes type = getFileTypeByContent(fileName); if (type != null) { - LOGGER.info('\'' + fileName + "' seems to be a " + - type.getFileTypeName()+" file"); + LOGGER.info("'{}' seems to be a {} file", fileName, type.getFileTypeName()); return type.parseFile(name, fileName, compiler, additionalInfoFileName); } - LOGGER.error("File '" + fileName + "' could not be parsed, " + - "fileType could not be guessed, please specify."); + LOGGER.error("File '{}' could not be parsed, fileType could not be guessed, please specify.", fileName); } else { InputFileTypes type = getFileTypeByShortName(fileType); if (type != null) { - LOGGER.info('\'' + fileName + "' should be a " + - type.getFileTypeName()+" file"); + LOGGER.info("'{}' should be a {} file", fileName, type.getFileTypeName()); return type.parseFile(name, fileName, compiler, additionalInfoFileName); } - LOGGER.error("File '" + fileName + "' could not be parsed, fileType '" + - fileType + "' unknown."); + LOGGER.error("File '{}' could not be parsed, fileType '{}' unknown.", fileName, fileType); } return false; } From 5cf9a7ebd64bfd6851d393734613f6eafe49473e Mon Sep 17 00:00:00 2001 From: julianu Date: Thu, 30 Nov 2023 12:31:17 +0100 Subject: [PATCH 2/4] updating dependencies --- pom.xml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 67e629ba..0ac92d73 100644 --- a/pom.xml +++ b/pom.xml @@ -39,9 +39,10 @@ UTF-8 - 2.20.0 - 4.13.1 - 4.1 + 2.22.0 + 4.13.2 + 4.4 + 1.11.0 1.2.11 3.0.8 2.1.8 @@ -51,24 +52,21 @@ 1.13.0 5.0.41 7.0.2 - 2.8.9 - 4.6.3 + 2.10.1 + 4.7.5 1.0.392 - 3.41.2.2 + 3.44.1.0 2.12.2 + + + 1.4.13 + 2.16.0 + 5.2.5 0.0.1-SNAPSHOT 0.0.1-SNAPSHOT 0.0.1-SNAPSHOT - - - 1.10.0 - - - 1.2.11 - 2.13.3 - 5.2.2 From f1cd3af86dc38a3ce4eadaf4a52d441c7bd7feaf Mon Sep 17 00:00:00 2001 From: julianu Date: Thu, 30 Nov 2023 12:51:21 +0100 Subject: [PATCH 3/4] comet tsv file parsing not implemented yet --- .../parser/InputFileParserFactory.java | 34 +------------------ 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/InputFileParserFactory.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/InputFileParserFactory.java index 21624155..cbdd9b95 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/InputFileParserFactory.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/InputFileParserFactory.java @@ -9,7 +9,7 @@ import org.apache.logging.log4j.Logger; import de.mpc.pia.intermediate.compiler.PIACompiler; -import de.mpc.pia.intermediate.compiler.parser.searchengines.CometCSVFileParser; +import de.mpc.pia.intermediate.compiler.parser.searchengines.CometTSVFileParser; import de.mpc.pia.intermediate.compiler.parser.searchengines.MascotDatFileParser; import de.mpc.pia.intermediate.compiler.parser.searchengines.TandemFileParser; import de.mpc.pia.intermediate.compiler.parser.searchengines.ThermoMSFFileParser; @@ -21,38 +21,6 @@ public class InputFileParserFactory { private static final Logger LOGGER = LogManager.getLogger(); public enum InputFileTypes { - - /** - * the input file is a Tide TXT file - */ - COMET_CSV_INPUT { - @Override - public String getFileSuffix() { - return "csv"; - } - - @Override - public String getFileTypeName() { - return "Comet CSV"; - } - - @Override - public String getFileTypeShort() { - return "comet"; - } - - @Override - public boolean checkFileType(String fileName) { - return CometCSVFileParser.checkFileType(fileName); - } - - @Override - public boolean parseFile(String name, String fileName, - PIACompiler compiler, String additionalInfoFileName) { - return CometCSVFileParser.getDataFromCometCSVFile(name, fileName, compiler); - } - }, - /** * the input file is a FASTA database file */ From 4ec1ce5c8cd997ad9fb9dc01fd9617c896561c46 Mon Sep 17 00:00:00 2001 From: julianu Date: Thu, 30 Nov 2023 12:58:09 +0100 Subject: [PATCH 4/4] removing unused import --- .../pia/intermediate/compiler/parser/InputFileParserFactory.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/InputFileParserFactory.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/InputFileParserFactory.java index cbdd9b95..4d81d277 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/InputFileParserFactory.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/InputFileParserFactory.java @@ -9,7 +9,6 @@ import org.apache.logging.log4j.Logger; import de.mpc.pia.intermediate.compiler.PIACompiler; -import de.mpc.pia.intermediate.compiler.parser.searchengines.CometTSVFileParser; import de.mpc.pia.intermediate.compiler.parser.searchengines.MascotDatFileParser; import de.mpc.pia.intermediate.compiler.parser.searchengines.TandemFileParser; import de.mpc.pia.intermediate.compiler.parser.searchengines.ThermoMSFFileParser;