Skip to content

Commit a7c4ed5

Browse files
Merge pull request #130 from qbicsoftware/development
Release 1.17.0
2 parents 3bc7789 + a602faf commit a7c4ed5

File tree

9 files changed

+42
-3
lines changed

9 files changed

+42
-3
lines changed

src/main/groovy/life/qbic/utils/MaxQuantParser.groovy

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class MaxQuantParser implements DatasetParser<MaxQuantRunResult> {
118118
rootChildren.each { currentChild ->
119119
if (currentChild.containsKey("children")) {
120120
//folder
121-
parseTxtFolder(map)
121+
parseSubFolders(map)
122122
} else if (currentChild.containsKey("fileType")) {
123123
//file
124124
String name = currentChild.get("name")
@@ -132,18 +132,26 @@ class MaxQuantParser implements DatasetParser<MaxQuantRunResult> {
132132
}
133133

134134
/**
135-
* Method which adapts the parsed content of the txt directory in place to the expected file structure.
135+
* Method which adapts the parsed content of the txt directory in place to the expected file structure. This directory can be inside an optional 'combined' directory
136136
* @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>}
137137
*
138138
* After parsing, the files of the txt directory are contained in the children property of the root directory.
139139
* The underlying datastructure however expects a mapping of the expected files as a Map entry in the root directory.
140140
* @param maxQuantInformation a nested map representing the parsed fileTree structure
141141
* @since 1.9.0
142142
*/
143-
private static void parseTxtFolder(Map maxQuantInformation) {
143+
private static void parseSubFolders(Map maxQuantInformation) {
144144
List<Map> rootFolderInformation = maxQuantInformation.get("children") as List<Map>
145145
def txtFolderInformation
146146
rootFolderInformation.findAll { map ->
147+
if (map.get("name") == "combined") {
148+
def combinedFolderInformation = map.get("children") as List<Map>
149+
combinedFolderInformation.findAll() { innerMap ->
150+
if (innerMap.get("name") == "txt") {
151+
txtFolderInformation = innerMap.get("children") as List<Map>
152+
}
153+
}
154+
}
147155
if (map.get("name") == "txt") {
148156
txtFolderInformation = map.get("children") as List<Map>
149157
}

src/test/groovy/life/qbic/utils/MaxQuantParserSpec.groovy

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,37 @@ class MaxQuantParserSpec extends Specification {
5252
assert maxQuantRunResult.proteinGroups.getName()== "proteinGroups.txt"
5353
}
5454

55+
def "parsing the old file structure with combined folder returns a maxQuantRunResult object"() {
56+
given: "A valid maxQuant run output data structure"
57+
def pathToDirectory = Paths.get(exampleDirectoriesRoot, "validates2")
58+
when: "we parse this valid structure"
59+
MaxQuantRunResult maxQuantRunResult = maxQuantParser.parseFrom(pathToDirectory)
60+
then: "we expect no exception should be thrown"
61+
assert maxQuantRunResult instanceof MaxQuantRunResult
62+
//Root files can be parsed
63+
assert maxQuantRunResult.runParameters.getRelativePath() == "./mqpar.xml"
64+
assert maxQuantRunResult.runParameters.getName()== "mqpar.xml"
65+
66+
assert maxQuantRunResult.sampleIds.getRelativePath() == "./QABCD_sample_ids.txt"
67+
assert maxQuantRunResult.sampleIds.getName()== "QABCD_sample_ids.txt"
68+
69+
//Files in ./txt/ can be parsed
70+
assert maxQuantRunResult.allPeptides.getRelativePath() == "./combined/txt/allPeptides.txt"
71+
assert maxQuantRunResult.allPeptides.getName()== "allPeptides.txt"
72+
73+
assert maxQuantRunResult.evidence.getRelativePath() == "./combined/txt/evidence.txt"
74+
assert maxQuantRunResult.evidence.getName()== "evidence.txt"
75+
76+
assert maxQuantRunResult.parameters.getRelativePath() == "./combined/txt/parameters.txt"
77+
assert maxQuantRunResult.parameters.getName()== "parameters.txt"
78+
79+
assert maxQuantRunResult.peptides.getRelativePath() == "./combined/txt/peptides.txt"
80+
assert maxQuantRunResult.peptides.getName()== "peptides.txt"
81+
82+
assert maxQuantRunResult.proteinGroups.getRelativePath() == "./combined/txt/proteinGroups.txt"
83+
assert maxQuantRunResult.proteinGroups.getName()== "proteinGroups.txt"
84+
}
85+
5586
def "parsing an invalid file structure throws DatasetValidationException"() {
5687
given:
5788
def pathToDirectory = Paths.get(exampleDirectoriesRoot, "fails/missing_txt_directory")

src/test/resources/dummyFileSystem/maxquant-run-output/validates2/QABCD_sample_ids.txt

Whitespace-only changes.

src/test/resources/dummyFileSystem/maxquant-run-output/validates2/combined/txt/allPeptides.txt

Whitespace-only changes.

src/test/resources/dummyFileSystem/maxquant-run-output/validates2/combined/txt/evidence.txt

Whitespace-only changes.

src/test/resources/dummyFileSystem/maxquant-run-output/validates2/combined/txt/parameters.txt

Whitespace-only changes.

src/test/resources/dummyFileSystem/maxquant-run-output/validates2/combined/txt/peptides.txt

Whitespace-only changes.

src/test/resources/dummyFileSystem/maxquant-run-output/validates2/combined/txt/proteinGroups.txt

Whitespace-only changes.

src/test/resources/dummyFileSystem/maxquant-run-output/validates2/mqpar.xml

Whitespace-only changes.

0 commit comments

Comments
 (0)