Skip to content

Commit

Permalink
Merge pull request #102 from qbicsoftware/development
Browse files Browse the repository at this point in the history
Prepare version 1.12.0
  • Loading branch information
wow-such-code authored May 18, 2022
2 parents 713598b + b03c886 commit a821337
Show file tree
Hide file tree
Showing 27 changed files with 21 additions and 46 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<description>Collection of non-Vaadin, non-Liferay utilities.</description>
<modelVersion>4.0.0</modelVersion>
<name>Core Utilities Library</name>
<version>1.11.0</version>
<version>1.12.0-SNAPSHOT</version>
<url>https://github.com/qbicsoftware/core-utils-lib</url>
<packaging>jar</packaging>
<properties>
Expand Down Expand Up @@ -127,7 +127,7 @@
<dependency>
<artifactId>data-model-lib</artifactId>
<groupId>life.qbic</groupId>
<version>2.18.0</version>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
Expand Down
39 changes: 10 additions & 29 deletions src/main/groovy/life/qbic/utils/MaxQuantParser.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,14 @@ class MaxQuantParser implements DatasetParser<MaxQuantRunResult> {
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())
}
}
}
Expand All @@ -137,26 +135,17 @@ class MaxQuantParser implements DatasetParser<MaxQuantRunResult> {
* Method which adapts the parsed content of the txt directory in place to the expected file structure.
* @see {<a href="https://github.com/qbicsoftware/data-model-lib/blob/master/src/test/resources/examples/resultset/maxquant/valid-resultset-example.json">valid datastructure example</a>}
*
* 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<Map> rootFolderInformation = maxQuantInformation.get("children") as List<Map>
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<Map>
}
if (map.get("name") == "txt") {
txtFolderInformation = map.get("children") as List<Map>
}
}
if (txtFolderInformation) {
Expand All @@ -181,19 +170,11 @@ class MaxQuantParser implements DatasetParser<MaxQuantRunResult> {
insertAsProperty(maxQuantInformation, child, RequiredTxtFileKeys.PROTEIN_GROUPS.getKeyName())
break
default:
if(child.get("name") == "summary") summaryFolderInformation = child.get("children") as List<Map>
//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())
}
}
}
}

/**
Expand Down
24 changes: 9 additions & 15 deletions src/test/groovy/life/qbic/utils/MaxQuantParserSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.

0 comments on commit a821337

Please sign in to comment.