Skip to content

Commit

Permalink
Merge pull request #320 from qbicsoftware/development
Browse files Browse the repository at this point in the history
Prepare version 2.19.0
  • Loading branch information
wow-such-code authored May 17, 2022
2 parents 9ba17e7 + eb55db6 commit 3f8db0d
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 24 deletions.
Binary file modified doc/figures/MaxQuant_Data_Structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>life.qbic</groupId>
<artifactId>data-model-lib</artifactId>
<version>2.18.0</version>
<version>2.19.0-SNAPSHOT</version>
<name>data-model-lib</name>
<url>http://github.com/qbicsoftware/data-model-lib</url>
<description>Data models. A collection of QBiC's central data models and DTOs. </description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,18 @@ final class MaxQuantRunResult {
private final static Set maxQuantFileTypes = [
FQDN_FILES + ".AllPeptides",
FQDN_FILES + ".Evidence",
FQDN_FILES + ".ExperimentalDesignTemplate",
FQDN_FILES + ".Parameters",
FQDN_FILES + ".Peptides",
FQDN_FILES + ".ProteinGroups",
FQDN_FILES + ".RunParameters",
GENERAL_FILES + ".SampleIds",
FQDN_FILES + ".Summary"
]

private final AllPeptides allPeptides

private final Evidence evidence

@Deprecated
private final ExperimentalDesignTemplate experimentalDesignTemplate

private final Parameters parameters
Expand All @@ -54,8 +53,10 @@ final class MaxQuantRunResult {

private final SampleIds sampleIds

@Deprecated
private final Summary summary

@Deprecated
MaxQuantRunResult(AllPeptides allPeptides, Evidence evidence, ExperimentalDesignTemplate experimentalDesignTemplate, Parameters parameters, Peptides peptides, ProteinGroups proteinGroups, RunParameters runParameters, SampleIds sampleIds, Summary summary) {
this.allPeptides = Objects.requireNonNull(allPeptides, "allPeptides must not be null.")
this.evidence = Objects.requireNonNull(evidence, "evidence must not be null.")
Expand All @@ -68,9 +69,19 @@ final class MaxQuantRunResult {
this.summary = Objects.requireNonNull(summary, "summary must not be null.")
}

MaxQuantRunResult(AllPeptides allPeptides, Evidence evidence, Parameters parameters, Peptides peptides, ProteinGroups proteinGroups, RunParameters runParameters, SampleIds sampleIds) {
this.allPeptides = Objects.requireNonNull(allPeptides, "allPeptides must not be null.")
this.evidence = Objects.requireNonNull(evidence, "evidence must not be null.")
this.parameters = Objects.requireNonNull(parameters, "parameters must not be null.")
this.peptides = Objects.requireNonNull(peptides, "peptides must not be null.")
this.proteinGroups = Objects.requireNonNull(proteinGroups, "proteinGroups must not be null.")
this.runParameters = Objects.requireNonNull(runParameters, "runParameters must not be null.")
this.sampleIds = Objects.requireNonNull(sampleIds, "sampleIds must not be null.")
}

/**
* Static factory method that creates a new maxQuantRunResult instance from the bioinformatic pipeline output.
* See this @{link <a href="https://github.com/qbicsoftware/data-model-lib/blob/master/src/test/resources/examples/resultset/maxquant/valid-resultset-example.json">example</a>}
* Static factory method that creates a new maxQuantRunResult instance from the MaxQuant output.
* See this @{link <a href="https://github.com/qbicsoftware/data-model-lib/blob/master/src/test/resources/examples/resultset/maxquant/valid-resultset-example_latest.json">example</a>}
* for a JSON representation of a valid map structure
*
* @param Map maxQuantRunOutput
Expand All @@ -82,27 +93,23 @@ final class MaxQuantRunResult {
//Check if the required folders are in the root directory
Objects.requireNonNull(maxQuantRunOutput.get("allPeptides"), "The provided directory must contain a allPeptides.txt file.")
Objects.requireNonNull(maxQuantRunOutput.get("evidence"), "The provided directory must contain a evidence.txt file.")
Objects.requireNonNull(maxQuantRunOutput.get("experimentalDesignTemplate"), "The provided directory must contain a experimentalDesignTemplate.txt file.")
Objects.requireNonNull(maxQuantRunOutput.get("parameters"), "The provided directory must contain a parameters.txt file.")
Objects.requireNonNull(maxQuantRunOutput.get("peptides"), "The provided directory must contain a peptides.txt file.")
Objects.requireNonNull(maxQuantRunOutput.get("proteinGroups"), "The provided directory must contain a proteinGroups.txt file.")
Objects.requireNonNull(maxQuantRunOutput.get("runParameters"), "The provided director must contain a runParameters.xml file.")
Objects.requireNonNull(maxQuantRunOutput.get("sampleIds"), "The provided directory must contain a sampleIds.txt file.")
Objects.requireNonNull(maxQuantRunOutput.get("summary"), "The provided directory must contain a summary.pdf file.")

//Get Files from Root Directory
AllPeptides allPeptides = parseFile(maxQuantRunOutput.get("allPeptides") as Map) as AllPeptides
Evidence evidence = parseFile(maxQuantRunOutput.get("evidence") as Map) as Evidence
ExperimentalDesignTemplate experimentalDesignTemplate = parseFile(maxQuantRunOutput.get("experimentalDesignTemplate") as Map) as ExperimentalDesignTemplate
Parameters parameters = parseFile(maxQuantRunOutput.get("parameters") as Map) as Parameters
Peptides peptides = parseFile(maxQuantRunOutput.get("peptides") as Map) as Peptides
ProteinGroups proteinGroups = parseFile(maxQuantRunOutput.get("proteinGroups") as Map) as ProteinGroups
RunParameters runParameters = parseFile(maxQuantRunOutput.get("runParameters") as Map) as RunParameters
SampleIds sampleIds = parseFile(maxQuantRunOutput.get("sampleIds") as Map) as SampleIds
Summary summary = parseFile(maxQuantRunOutput.get("summary") as Map) as Summary

//Create new MaxQuantRunResult object with parsed information
return new MaxQuantRunResult(allPeptides, evidence, experimentalDesignTemplate, parameters, peptides, proteinGroups, runParameters, sampleIds, summary)
return new MaxQuantRunResult(allPeptides, evidence, parameters, peptides, proteinGroups, runParameters, sampleIds)
}

/**
Expand All @@ -128,6 +135,7 @@ final class MaxQuantRunResult {
* @return an ExperimentalDesignTemplate file generated by MaxQuant
* @since 2.10.0
*/
@Deprecated
ExperimentalDesignTemplate getExperimentalDesignTemplate() {
return experimentalDesignTemplate
}
Expand Down Expand Up @@ -182,6 +190,7 @@ final class MaxQuantRunResult {
* @return a Summary file generated by MaxQuant
* @since 2.10.0
*/
@Deprecated
Summary getSummary() {
return summary
}
Expand Down
8 changes: 2 additions & 6 deletions src/main/resources/schemas/maxquant-result-set.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
{
"properties": {
"name": {
"pattern": "sample_ids"
"pattern": "Q\\w{4}_sample_ids"
},
"fileType": {
"pattern": "txt"
Expand Down Expand Up @@ -143,23 +143,19 @@
"properties": {
"allPeptides": {"$ref": "#/definitions/allPeptides"},
"evidence": {"$ref": "#/definitions/evidence"},
"experimentalDesignTemplate": {"$ref": "#/definitions/experimentalDesignTemplate"},
"parameters": {"$ref": "#/definitions/parameters"},
"peptides": {"$ref": "#/definitions/peptides"},
"proteinGroups": {"$ref": "#/definitions/proteinGroups"},
"runParameters": {"$ref": "#/definitions/runParameters"},
"sampleIds": {"$ref": "#/definitions/sampleIds"},
"summary": {"$ref": "#/definitions/summary"}
},
"required": [
"allPeptides",
"evidence",
"experimentalDesignTemplate",
"parameters",
"peptides",
"proteinGroups",
"runParameters",
"sampleIds",
"summary"
"sampleIds"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class MaxQuantRunResultSpec extends Specification {
Map invalidDataStructure

def setupSpec() {
InputStream validStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("examples/resultset/maxquant/valid-resultset-example.json")
InputStream validStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("examples/resultset/maxquant/valid-resultset-example_latest.json")
validDataStructure = (Map) new JsonSlurper().parse(validStream)
validStream.close()

InputStream invalidStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("examples/resultset/maxquant/invalid-resultset-example.json")
InputStream invalidStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("examples/resultset/maxquant/no-sampleid-resultset-example.json")
invalidDataStructure = (Map) new JsonSlurper().parse(invalidStream)
invalidStream.close()
}
Expand All @@ -48,24 +48,20 @@ class MaxQuantRunResultSpec extends Specification {
final MaxQuantRunResult maxQuantRunResult = MaxQuantRunResult.createFrom(validExample)
AllPeptides allPeptides = maxQuantRunResult.allPeptides
Evidence evidence = maxQuantRunResult.evidence
ExperimentalDesignTemplate experimentalDesignTemplate = maxQuantRunResult.experimentalDesignTemplate
Parameters parameters = maxQuantRunResult.parameters
Peptides peptides = maxQuantRunResult.peptides
ProteinGroups proteinGroups = maxQuantRunResult.proteinGroups
RunParameters runParameters = maxQuantRunResult.runParameters
SampleIds sampleIds = maxQuantRunResult.sampleIds
Summary summary = maxQuantRunResult.summary
then:

allPeptides.name == "allPeptides.txt"
evidence.name == "evidence.txt"
experimentalDesignTemplate.name == "experimentalDesignTemplate.txt"
parameters.name == "parameters.txt"
peptides.name == "peptides.txt"
proteinGroups.name == "proteinGroups.txt"
runParameters.name == "mqpar.xml"
sampleIds.name == "sample_ids.txt"
summary.name == "summary_1234.pdf"
sampleIds.name == "Q0010_sample_ids.txt"
}

def "Invalid fileTree will return a NullPointerException"() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package life.qbic.datamodel.maxquant

import groovy.json.JsonSlurper
import org.everit.json.schema.Schema
import org.everit.json.schema.ValidationException
import org.everit.json.schema.loader.SchemaClient
Expand Down Expand Up @@ -35,7 +36,7 @@ class MaxQuantOutputSpec extends Specification {

and:
String validMaxQuantOutput = this.class.getClassLoader()
.getResourceAsStream("examples/resultset/maxquant/valid-resultset-example.json")
.getResourceAsStream("examples/resultset/maxquant/valid-resultset-example_latest.json")
.text

and:
Expand Down Expand Up @@ -101,4 +102,52 @@ class MaxQuantOutputSpec extends Specification {
then:
thrown(ValidationException)
}

def "Validating the outdated schema v2 shall raise a validation exception"() {
given:
def stream = MaxQuantOutput.getSchemaAsStream()

and:
String wrongMaxQuantOutput = this.class.getClassLoader()
.getResourceAsStream("examples/resultset/maxquant/old_valid-resultset-example.json")
.text

and:
SchemaLoader schemaLoader = SchemaLoader.builder()
.schemaClient(SchemaClient.classPathAwareClient())
.schemaJson(new JSONObject(new JSONTokener(stream)))
.resolutionScope("classpath://schemas/")
.build()
Schema schema = schemaLoader.load().build()

when:
schema.validate(new JSONObject(wrongMaxQuantOutput))

then:
thrown(ValidationException)
}

def "An invalid project code in the sample ids file shall raise a validation exception"() {
given:
def stream = MaxQuantOutput.getSchemaAsStream()

and:
String missingMaxQuantOutput = this.class.getClassLoader()
.getResourceAsStream("examples/resultset/maxquant/invalid-project-resultset-example.json")
.text

and:
SchemaLoader schemaLoader = SchemaLoader.builder()
.schemaClient(SchemaClient.classPathAwareClient())
.schemaJson(new JSONObject(new JSONTokener(stream)))
.resolutionScope("classpath://schemas/")
.build()
Schema schema = schemaLoader.load().build()

when:
schema.validate(new JSONObject(missingMaxQuantOutput))

then:
thrown(ValidationException)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"allPeptides": {
"name": "allPeptides.txt",
"fileType": "txt",
"path": "./txt/allPeptides.txt"
},
"evidence": {
"name": "evidence.txt",
"fileType": "txt",
"path": "./txt/evidence.txt"
},
"parameters": {
"name": "parameters.txt",
"fileType": "txt",
"path": "./txt/parameters.txt"
},
"peptides": {
"name": "peptides.txt",
"fileType": "txt",
"path": "./txt/peptides.txt"
},
"proteinGroups": {
"name": "proteinGroups.txt",
"fileType": "txt",
"path": "./txt/proteinGroups.txt"
},
"runParameters": {
"name": "mqpar.xml",
"fileType": "xml",
"path": "./mqpar.xml"
},
"sampleIds": {
"name": "0010_sample_ids.txt",
"fileType": "txt",
"path": "./0010_sample_ids.txt"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"allPeptides": {
"name": "allPeptides.txt",
"fileType": "txt",
"path": "./txt/allPeptides.txt"
},
"evidence": {
"name": "evidence.txt",
"fileType": "txt",
"path": "./txt/evidence.txt"
},
"parameters": {
"name": "parameters.txt",
"fileType": "txt",
"path": "./txt/parameters.txt"
},
"peptides": {
"name": "peptides.txt",
"fileType": "txt",
"path": "./txt/peptides.txt"
},
"proteinGroups": {
"name": "proteinGroups.txt",
"fileType": "txt",
"path": "./txt/proteinGroups.txt"
},
"runParameters": {
"name": "mqpar.xml",
"fileType": "xml",
"path": "./mqpar.xml"
},
"sampleIds": {
"name": "Q0010_sample_ids.txt",
"fileType": "txt",
"path": "./Q0010_sample_ids.txt"
}
}

0 comments on commit 3f8db0d

Please sign in to comment.