diff --git a/pom.xml b/pom.xml index ac23039d..7a485d02 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ Collection of non-Vaadin, non-Liferay utilities. 4.0.0 Core Utilities Library - 1.11.0 + 1.12.0-SNAPSHOT https://github.com/qbicsoftware/core-utils-lib jar @@ -127,7 +127,7 @@ data-model-lib life.qbic - 2.18.0 + 2.19.0 org.mockito diff --git a/src/main/groovy/life/qbic/utils/MaxQuantParser.groovy b/src/main/groovy/life/qbic/utils/MaxQuantParser.groovy index 084d9f0a..aed1088f 100644 --- a/src/main/groovy/life/qbic/utils/MaxQuantParser.groovy +++ b/src/main/groovy/life/qbic/utils/MaxQuantParser.groovy @@ -118,16 +118,14 @@ class MaxQuantParser implements DatasetParser { rootChildren.each { currentChild -> if (currentChild.containsKey("children")) { //folder - parseCombinedInformation(map) + parseTxtFolder(map) } else if (currentChild.containsKey("fileType")) { //file - switch (currentChild.get("name")) { - case "mqpar.xml": - insertAsProperty(map, currentChild, RequiredRootFileKeys.RUN_PARAMETERS.getKeyName()) - break - case "sample_ids.txt": - insertAsProperty(map, currentChild, RequiredRootFileKeys.SAMPLE_ID.getKeyName()) - break + String name = currentChild.get("name") + if(name.equals("mqpar.xml")) { + insertAsProperty(map, currentChild, RequiredRootFileKeys.RUN_PARAMETERS.getKeyName()) + } else if(name.endsWith("sample_ids.txt")) { + insertAsProperty(map, currentChild, RequiredRootFileKeys.SAMPLE_ID.getKeyName()) } } } @@ -137,26 +135,17 @@ class MaxQuantParser implements DatasetParser { * Method which adapts the parsed content of the txt directory in place to the expected file structure. * @see {valid datastructure example} * - * After parsing the files of the txt directory are contained in the children property of the combined directory, which itself is contained in the root directory. + * After parsing, the files of the txt directory are contained in the children property of the root directory. * The underlying datastructure however expects a mapping of the expected files as a Map entry in the root directory. * @param maxQuantInformation a nested map representing the parsed fileTree structure * @since 1.9.0 */ - private static void parseCombinedInformation(Map maxQuantInformation) { + private static void parseTxtFolder(Map maxQuantInformation) { List rootFolderInformation = maxQuantInformation.get("children") as List - def combinedFolderInformation def txtFolderInformation - def summaryFolderInformation rootFolderInformation.findAll { map -> - if (map.get("name") == "combined") { - combinedFolderInformation = map.get("children") - } - } - if (combinedFolderInformation) { - combinedFolderInformation.findAll { map -> - if (map.get("name") == "txt") { - txtFolderInformation = map.get("children") as List - } + if (map.get("name") == "txt") { + txtFolderInformation = map.get("children") as List } } if (txtFolderInformation) { @@ -181,19 +170,11 @@ class MaxQuantParser implements DatasetParser { insertAsProperty(maxQuantInformation, child, RequiredTxtFileKeys.PROTEIN_GROUPS.getKeyName()) break default: - if(child.get("name") == "summary") summaryFolderInformation = child.get("children") as List //ignoring other children break } } } - if(summaryFolderInformation){ - summaryFolderInformation.each{ Map child -> - if (child.get("name").toString().matches("summary_[0-9]{4}.*")) { - insertAsProperty(maxQuantInformation, child, RequiredTxtFileKeys.SUMMARY.getKeyName()) - } - } - } } /** diff --git a/src/test/groovy/life/qbic/utils/MaxQuantParserSpec.groovy b/src/test/groovy/life/qbic/utils/MaxQuantParserSpec.groovy index 8fdc2267..c2bfe703 100644 --- a/src/test/groovy/life/qbic/utils/MaxQuantParserSpec.groovy +++ b/src/test/groovy/life/qbic/utils/MaxQuantParserSpec.groovy @@ -32,35 +32,29 @@ class MaxQuantParserSpec extends Specification { assert maxQuantRunResult.runParameters.getRelativePath() == "./mqpar.xml" assert maxQuantRunResult.runParameters.getName()== "mqpar.xml" - assert maxQuantRunResult.sampleIds.getRelativePath() == "./sample_ids.txt" - assert maxQuantRunResult.sampleIds.getName()== "sample_ids.txt" + assert maxQuantRunResult.sampleIds.getRelativePath() == "./QABCD_sample_ids.txt" + assert maxQuantRunResult.sampleIds.getName()== "QABCD_sample_ids.txt" - //Files in ./combined/txt/ can be parsed - assert maxQuantRunResult.allPeptides.getRelativePath() == "./combined/txt/allPeptides.txt" + //Files in ./txt/ can be parsed + assert maxQuantRunResult.allPeptides.getRelativePath() == "./txt/allPeptides.txt" assert maxQuantRunResult.allPeptides.getName()== "allPeptides.txt" - assert maxQuantRunResult.evidence.getRelativePath() == "./combined/txt/evidence.txt" + assert maxQuantRunResult.evidence.getRelativePath() == "./txt/evidence.txt" assert maxQuantRunResult.evidence.getName()== "evidence.txt" - assert maxQuantRunResult.experimentalDesignTemplate.getRelativePath() == "./combined/txt/experimentalDesignTemplate.txt" - assert maxQuantRunResult.experimentalDesignTemplate.getName()== "experimentalDesignTemplate.txt" - - assert maxQuantRunResult.parameters.getRelativePath() == "./combined/txt/parameters.txt" + assert maxQuantRunResult.parameters.getRelativePath() == "./txt/parameters.txt" assert maxQuantRunResult.parameters.getName()== "parameters.txt" - assert maxQuantRunResult.peptides.getRelativePath() == "./combined/txt/peptides.txt" + assert maxQuantRunResult.peptides.getRelativePath() == "./txt/peptides.txt" assert maxQuantRunResult.peptides.getName()== "peptides.txt" - assert maxQuantRunResult.proteinGroups.getRelativePath() == "./combined/txt/proteinGroups.txt" + assert maxQuantRunResult.proteinGroups.getRelativePath() == "./txt/proteinGroups.txt" assert maxQuantRunResult.proteinGroups.getName()== "proteinGroups.txt" - - assert maxQuantRunResult.summary.getRelativePath() == "./combined/txt/summary/summary_1234.pdf" - assert maxQuantRunResult.summary.getName()== "summary_1234.pdf" } def "parsing an invalid file structure throws DatasetValidationException"() { given: - def pathToDirectory = Paths.get(exampleDirectoriesRoot, "fails/missing_combined_directory") + def pathToDirectory = Paths.get(exampleDirectoriesRoot, "fails/missing_txt_directory") when: maxQuantParser.parseFrom(pathToDirectory) then: diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_combined_directory/mqpar.xml b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/QABCD_sample_ids.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_combined_directory/mqpar.xml rename to src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/QABCD_sample_ids.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/sample_ids.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/sample_ids.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/combined/txt/evidence.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/txt/evidence.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/combined/txt/evidence.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/txt/evidence.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/combined/txt/parameters.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/txt/parameters.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/combined/txt/parameters.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/txt/parameters.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/combined/txt/peptides.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/txt/peptides.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/combined/txt/peptides.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/txt/peptides.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/combined/txt/proteinGroups.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/txt/proteinGroups.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/combined/txt/proteinGroups.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/txt/proteinGroups.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/experimentalDesignTemplate.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/experimentalDesignTemplate.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/summary_1234.pdf b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/summary_1234.pdf deleted file mode 100644 index e69de29b..00000000 diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/allPeptides.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/txt/allPeptides.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/allPeptides.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/txt/allPeptides.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/evidence.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/txt/evidence.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/evidence.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/txt/evidence.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/parameters.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/txt/parameters.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/parameters.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/txt/parameters.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/peptides.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/txt/peptides.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/peptides.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/txt/peptides.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/proteinGroups.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/txt/proteinGroups.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/combined/txt/proteinGroups.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_root_files_directory/txt/proteinGroups.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_combined_directory/sample_ids.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_txt_directory/QABCD_sample_ids.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_combined_directory/sample_ids.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_txt_directory/QABCD_sample_ids.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/combined/txt/experimentalDesignTemplate.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_txt_directory/mqpar.xml similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/combined/txt/experimentalDesignTemplate.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_txt_directory/mqpar.xml diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/combined/txt/summary_1234.pdf b/src/test/resources/dummyFileSystem/maxquant-run-output/validates/QABCD_sample_ids.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/fails/missing_file_in_txt_directory/combined/txt/summary_1234.pdf rename to src/test/resources/dummyFileSystem/maxquant-run-output/validates/QABCD_sample_ids.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/experimentalDesignTemplate.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/experimentalDesignTemplate.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/summary/summary_1234.pdf b/src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/summary/summary_1234.pdf deleted file mode 100644 index e69de29b..00000000 diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/validates/sample_ids.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/validates/sample_ids.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/allPeptides.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/validates/txt/allPeptides.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/allPeptides.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/validates/txt/allPeptides.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/evidence.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/validates/txt/evidence.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/evidence.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/validates/txt/evidence.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/parameters.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/validates/txt/parameters.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/parameters.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/validates/txt/parameters.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/peptides.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/validates/txt/peptides.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/peptides.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/validates/txt/peptides.txt diff --git a/src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/proteinGroups.txt b/src/test/resources/dummyFileSystem/maxquant-run-output/validates/txt/proteinGroups.txt similarity index 100% rename from src/test/resources/dummyFileSystem/maxquant-run-output/validates/combined/txt/proteinGroups.txt rename to src/test/resources/dummyFileSystem/maxquant-run-output/validates/txt/proteinGroups.txt