-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor Base Schema to not require Donor/Specimen/Sample #878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
51ef77f
Remove Donor, Specimen, and Sample from Analysis Data Classes in SONG
Azher2Ali 38a8547
Reverting the changes related to latest develop
Azher2Ali 7158328
Resolving conflicts and reverting changes to fileUpdateRequest.json
Azher2Ali a512322
Merge pull request #869 from overture-stack/refactor/remove-donor-spe…
Azher2Ali 258e013
Remove Donor, Specimen, and Samples from Base Schema and Allow in Dyn…
Azher2Ali 7da7be2
Remove Donor-Related Entities from StudyController and Search APIs
Azher2Ali 161d8d0
Merge pull request #870 from overture-stack/refactor/remove-donor-spe…
Azher2Ali 516ccea
Merge pull request #873 from overture-stack/refactor/remove-donor-spe…
Azher2Ali fa644ec
Add External Validation Rules for Analysis Properties Based on Dynami…
Azher2Ali f4f376f
Resolving the build issues and updating the PR with missing files
Azher2Ali ffde783
Changes related to feedback
Azher2Ali fe20ec7
Changes to ValidationService related to externalValiation
Azher2Ali fe0883f
Changes related to the feedback comments
Azher2Ali 2065205
Migrate file_types to options column in analysis_schema
Azher2Ali 57e83af
External valdiation URL template for study and value tokens
joneubank a09c88e
Retrieve all options data with analysis type
joneubank 6fd36b1
Remove sneaky throws from buildSchema with JSON parsing failure case
joneubank dd4c9f8
Merge pull request #877 from overture-stack/feature/external-validati…
joneubank 26ee1cf
Fix paginated data lookup by removing stored procedure reference to f…
joneubank 8ba45d8
Schema registrations sets options values correctly (#879)
joneubank e0b96be
Change schema option name to plural `externalValidations`
joneubank 19d9e32
Docs grammar improvements and update property to externalValidations
joneubank b74d0e0
Remove blank lines
joneubank eb0f328
Options property description improvements
joneubank File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Custom Analysis Schemas | ||
|
||
## Minimal Example | ||
|
||
```json | ||
{ | ||
"name": "minimalExample", | ||
"options":{}, | ||
"schema":{ | ||
"type": "object", | ||
"required":[ | ||
"experiment" | ||
], | ||
"properties":{ | ||
"experiment":{} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
The `options` property defines extra validations for this analysis schema, such as restrictions on file types and checks on the data with an external service. The `options` property is not required. Similarly, each property in `options` is also optional. If no value is provided for one of the `options` properties, a default configuration will be used for the analysis. If this is an update to an existing analysis type, you can omit any option and its value will be maintained from the previous version. | ||
|
||
```json | ||
{ | ||
"fileTypes":["bam", "cram"], | ||
"externalValidations":[ | ||
{ | ||
"url": "http://localhost:8099/", | ||
"jsonPath": "experiment.someId" | ||
} | ||
] | ||
}, | ||
``` | ||
|
||
If you want to remove the previous value of an option so that this validation is no longer required, for instance removing the restriction on file types so that any file type could be provided, you should provide an empty list for that option. | ||
|
||
In the example below, both `fileTypes` and `externalValidations` properties are set to empty arrays, which means that these validations will not be applied to submitted analysis: | ||
|
||
```json | ||
{ | ||
"options": { | ||
"fileTypes": [], | ||
"externalValidations": [] | ||
} | ||
} | ||
``` | ||
|
||
### File Types | ||
|
||
`options.fileTypes` can be provided an array of strings. These represent the file types (file extensions) that are allowed to be uploaded for this type of analysis. | ||
|
||
If an empty array is provided, then any file type will be allowed. If an array of file types is provided, then an analysis will be invalid if it contains files of a type not listed. | ||
|
||
```json | ||
{ | ||
"options": { | ||
"fileTypes": ["bam","cram"] | ||
} | ||
} | ||
``` | ||
|
||
### External Validation | ||
|
||
External validations configure Song to check a value in the analysis against an external service by sending an HTTP GET request to a configurable URL. The service should respond with a 2XX status message to indicate the value "is valid". | ||
|
||
As an example, if the project clinical data is being managed in a separate service, we can add an external validation to the donor id field of our custom scheme. This will send the donor id to the external service which can confirm that we have previously registered that donor. | ||
|
||
This might look like the following: | ||
|
||
```json | ||
{ | ||
"url": "http://example.com/{study}/donor/{value}", | ||
"jsonPath": "experiment.donorId" | ||
} | ||
``` | ||
|
||
The URL provided is a template, with two variables that will be replaced during validation. Song will replace the token `{value}` with the value read from the analysis at the property as defined in the `jsonPath`. Song will also replace the token `{study}` with the study ID for the Analysis. | ||
|
||
Continuing the above example, if the following analysis was submitted: | ||
|
||
```json | ||
{ | ||
"studyId": "ABC123", | ||
"analysisType": { | ||
"name": "minimalExample" | ||
}, | ||
"files": [ | ||
{ | ||
"dataType": "text", | ||
"fileName": "file1.txt", | ||
"fileSize": 123, | ||
"fileType": "txt", | ||
"fileAccess": "open", | ||
"fileMd5sum": "595f44fec1e92a71d3e9e77456ba80d1" | ||
} | ||
], | ||
"experiment": { | ||
"donorId": "id01" | ||
} | ||
} | ||
``` | ||
|
||
Song would attempt to validate the donorId by sending a validation request to `http://example.com/ABC123/donor/id01`. | ||
|
||
The URL parsing allows using either the `{study}` or `{value}` placeholders multiple times (e.g. `http://example.com/{study}-{value}/{value}`), each instance will be interpolated accordingly. | ||
|
||
> [!Warning] | ||
> The URL may cause errors in Song if it contains any tokens matching the `{word}` format other than `{study}` and `{value}` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,31 +54,13 @@ public class SearchCommand extends Command { | |
/** Long Switch Constants */ | ||
private static final String FILE_ID_SWITCH = "--file-id"; | ||
|
||
private static final String SAMPLE_ID_SWITCH = "--sample-id"; | ||
private static final String SPECIMEN_ID_SWITCH = "--specimen-id"; | ||
private static final String DONOR_ID_SWITCH = "--donor-id"; | ||
private static final String ANALYSIS_ID_SWITCH = "--analysis-id"; | ||
|
||
@Parameter( | ||
names = {F_SWITCH, FILE_ID_SWITCH}, | ||
required = false) | ||
private String fileId; | ||
|
||
@Parameter( | ||
names = {SA_SWITCH, SAMPLE_ID_SWITCH}, | ||
required = false) | ||
private String sampleId; | ||
|
||
@Parameter( | ||
names = {SP_SWITCH, SPECIMEN_ID_SWITCH}, | ||
required = false) | ||
private String specimenId; | ||
|
||
@Parameter( | ||
names = {D_SWITCH, DONOR_ID_SWITCH}, | ||
required = false) | ||
private String donorId; | ||
|
||
@Parameter( | ||
names = {A_SWITCH, ANALYSIS_ID_SWITCH}, | ||
required = false) | ||
|
@@ -92,8 +74,7 @@ public void run() throws IOException { | |
val status = checkRules(); | ||
if (!status.hasErrors()) { | ||
if (isIdSearchMode()) { | ||
status.outputPrettyJson( | ||
songApi.idSearch(config.getStudyId(), sampleId, specimenId, donorId, fileId)); | ||
status.outputPrettyJson(songApi.idSearch(config.getStudyId(), fileId)); | ||
} else if (isAnalysisSearchMode()) { | ||
status.outputPrettyJson(songApi.getAnalysis(config.getStudyId(), analysisId)); | ||
} else { | ||
|
@@ -108,18 +89,15 @@ private boolean isAnalysisSearchMode() { | |
} | ||
|
||
private boolean isIdSearchMode() { | ||
return nonNull(fileId) || nonNull(sampleId) || nonNull(specimenId) || nonNull(donorId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
return nonNull(fileId); | ||
} | ||
|
||
private Status checkRules() { | ||
val fileTerm = createParamTerm(F_SWITCH, FILE_ID_SWITCH, fileId, Objects::nonNull); | ||
val sampleTerm = createParamTerm(SA_SWITCH, SAMPLE_ID_SWITCH, sampleId, Objects::nonNull); | ||
val specimenTerm = createParamTerm(SP_SWITCH, SPECIMEN_ID_SWITCH, specimenId, Objects::nonNull); | ||
val donorTerm = createParamTerm(D_SWITCH, DONOR_ID_SWITCH, donorId, Objects::nonNull); | ||
val analysisIdTerm = | ||
createParamTerm(A_SWITCH, ANALYSIS_ID_SWITCH, analysisId, Objects::nonNull); | ||
|
||
val idSearchMode = createModeRule(ID_MODE, fileTerm, sampleTerm, specimenTerm, donorTerm); | ||
val idSearchMode = createModeRule(ID_MODE, fileTerm); | ||
val analysisSearchMode = createModeRule(ANALYSIS_MODE, analysisIdTerm); | ||
val ruleProcessor = createRuleProcessor(idSearchMode, analysisSearchMode); | ||
return ruleProcessor.check(); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
song-core/src/main/java/bio/overture/song/core/model/AnalysisTypeOptions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
package bio.overture.song.core.model; | ||
|
||
import java.util.List; | ||
import lombok.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class AnalysisTypeOptions { | ||
private List<String> fileTypes; | ||
private List<ExternalValidation> externalValidations; | ||
} |
14 changes: 0 additions & 14 deletions
14
song-core/src/main/java/bio/overture/song/core/model/CompositeSample.java
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
song-core/src/main/java/bio/overture/song/core/model/Donor.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love it. very helpful description 👍