-
Notifications
You must be signed in to change notification settings - Fork 596
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
VS-361 Add GvsWithdrawSamples wdl #7765
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9a23a52
First cut at GvsWithdrawSamples.wdl
gbggrant 4f13f91
Fix quoting of in string.
gbggrant 8269a03
Fix quoting of string, again.
gbggrant 3114ea7
Trying to validate the number of rows updated.
gbggrant 78719b8
Trying to validate the number of rows updated.
gbggrant 1076700
Stupid typo
gbggrant a702540
Final?
gbggrant 2d304bc
Code review feedback
gbggrant b5c2469
Code review feedback
gbggrant 3399451
Remove my branch from dockstore.
gbggrant 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 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 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,85 @@ | ||
version 1.0 | ||
|
||
workflow GvsWithdrawSamples { | ||
|
||
input { | ||
String dataset_name | ||
String project_id | ||
|
||
Array[String] sample_names | ||
|
||
String? service_account_json_path | ||
} | ||
|
||
call WithdrawSamples { | ||
input: | ||
project_id = project_id, | ||
dataset_name = dataset_name, | ||
sample_names = sample_names, | ||
service_account_json_path = service_account_json_path | ||
} | ||
|
||
output { | ||
Int num_rows_updated = WithdrawSamples.num_rows_updated | ||
} | ||
} | ||
|
||
task WithdrawSamples { | ||
input { | ||
String project_id | ||
String dataset_name | ||
|
||
Array[String] sample_names | ||
|
||
String? service_account_json_path | ||
} | ||
|
||
String has_service_account_file = if (defined(service_account_json_path)) then 'true' else 'false' | ||
|
||
meta { | ||
description: "Withdraw Samples from GVS by marking them as 'withdrawn' in the sample_info table" | ||
volatile: true | ||
} | ||
|
||
command <<< | ||
set -e | ||
set -x | ||
|
||
# make sure that sample names were actually passed, warn and exit if empty | ||
num_samples=~{length(sample_names)} | ||
if [ $num_samples -eq 0 ]; then | ||
echo "No sample names passed. Exiting" | ||
exit 0 | ||
fi | ||
|
||
if [ ~{has_service_account_file} = 'true' ]; then | ||
gsutil cp ~{service_account_json_path} local.service_account.json | ||
gcloud auth activate-service-account --key-file=local.service_account.json | ||
fi | ||
|
||
echo "project_id = ~{project_id}" > ~/.bigqueryrc | ||
|
||
# perform actual update | ||
bq --project_id=~{project_id} query --format=csv --use_legacy_sql=false \ | ||
'UPDATE `~{dataset_name}.sample_info` SET withdrawn = CURRENT_TIMESTAMP() WHERE sample_name IN ("~{sep='\", \"' sample_names}")' > log_message.txt; | ||
|
||
cat log_message.txt | sed -e 's/Number of affected rows: //' > rows_updated.txt | ||
typeset -i rows_updated=$(cat rows_updated.txt) | ||
|
||
if [ $num_samples -ne $rows_updated ]; then | ||
echo "Error: Expected to update $num_samples rows - but only updated $rows_updated." | ||
exit 1 | ||
fi | ||
|
||
>>> | ||
runtime { | ||
docker: "us.gcr.io/broad-gatk/gatk:4.2.5.0" | ||
memory: "3.75 GB" | ||
disks: "local-disk 10 HDD" | ||
cpu: 1 | ||
} | ||
output { | ||
Int num_rows_updated = read_int("rows_updated.txt") | ||
} | ||
} | ||
|
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.
I really like having this check...I wish there was a cleaner way of doing this with the
bq
command line tool but if there is I haven't found it... 😞