-
Notifications
You must be signed in to change notification settings - Fork 590
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
Curate input arrays to skip already ingested sample data [VS-246] #7862
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
99a0be0
dockstore
rsasch 9af2ca2
first stab
rsasch 5b14575
Merge branch 'ah_var_store' into rsa_skip_samples
rsasch 102cd89
escape backticks
rsasch 77f13a0
fix logic
rsasch f5c4f42
first stab with python
rsasch deec99d
whoops, wrong sample_map
rsasch 4135ef5
add numpy to requirements.txt
rsasch bb87dc1
name the files consistently
rsasch f0bd8a4
more syncing of file names
rsasch 9cf3791
Merge branch 'ah_var_store' into rsa_skip_samples
rsasch 96c7519
add file validation
rsasch ac6f2e1
more cleanup and PR feedback
rsasch 767d174
Merge branch 'ah_var_store' into rsa_skip_samples
rsasch afa90cd
PR feedback
rsasch d24ce87
Merge branch 'ah_var_store' into rsa_skip_samples
rsasch 8ae8a6f
add test for curate_input_array_test_files
rsasch 6f1c93e
Merge branch 'ah_var_store' into rsa_skip_samples
rsasch 40b71ad
PR feedback
rsasch f565850
use localized inputs
rsasch c8a6046
one more typo
rsasch 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
73 changes: 73 additions & 0 deletions
73
scripts/variantstore/wdl/extract/curate_input_array_files.py
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,73 @@ | ||
# -*- coding: utf-8 -*- | ||
import numpy as np | ||
from contextlib import contextmanager | ||
import argparse | ||
|
||
SAMPLE_MAP_TO_BE_LOADED_FILE_SUFFIX = "samples_to_be_loaded_map_file" | ||
SAMPLE_NAME_FILE_SUFFIX = "sample_name_list_file" | ||
VCF_FILE_SUFFIX = "vcf_list_file" | ||
VCF_INDEX_FILE_SUFFIX = "vcf_index_list_file" | ||
|
||
@contextmanager | ||
rsasch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def handle_file_error(file_name): | ||
try: | ||
yield | ||
except: | ||
print(f"ERROR: required file named '{file_name}' does not exist.") | ||
rsasch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
def curate_input_arrays(sample_map_to_be_loaded_file_name, | ||
sample_name_list_file_name, | ||
vcf_list_file_name, | ||
vcf_index_list_file_name, | ||
output_files): | ||
sample_map_to_be_loaded_array = vcf_array = vcf_indexes_array = sample_names_array = [] | ||
with handle_file_error(sample_map_to_be_loaded_file_name): | ||
sample_map_to_be_loaded_array = np.loadtxt(sample_map_to_be_loaded_file_name, dtype=str, delimiter=",") | ||
with handle_file_error(vcf_list_file_name): | ||
vcf_array = np.loadtxt(vcf_list_file_name, dtype=str) | ||
with handle_file_error(vcf_index_list_file_name): | ||
vcf_indexes_array = np.loadtxt(vcf_index_list_file_name, dtype=str) | ||
with handle_file_error(sample_name_list_file_name): | ||
sample_names_array = np.loadtxt(sample_name_list_file_name, dtype=str) | ||
rows_to_delete = [] | ||
|
||
# use input_sample_names_array to figure out which index "rows" to delete | ||
for i in range(len(sample_names_array)): | ||
if sample_names_array[i] not in sample_map_to_be_loaded_array: | ||
rows_to_delete.append(i) | ||
|
||
# re-create input arrays using array of "rows" to delete | ||
vcf_array = [vcf_array[i] for i in range(len(vcf_array)) if i not in rows_to_delete] | ||
vcf_indexes_array = [vcf_indexes_array[i] for i in range(len(vcf_indexes_array)) if | ||
i not in rows_to_delete] | ||
sample_names_array = [sample_names_array[i] for i in range(len(sample_names_array)) if | ||
i not in rows_to_delete] | ||
|
||
if output_files: | ||
print(f"Creating 'output_{SAMPLE_NAME_FILE_SUFFIX}', 'output_{VCF_FILE_SUFFIX}' and 'output_{VCF_INDEX_FILE_SUFFIX}'.") | ||
np.savetxt(f"output_{SAMPLE_NAME_FILE_SUFFIX}", sample_names_array, fmt='%s') | ||
np.savetxt(f"output_{VCF_FILE_SUFFIX}", vcf_array, fmt='%s') | ||
np.savetxt(f"output_{VCF_INDEX_FILE_SUFFIX}", vcf_indexes_array, fmt='%s') | ||
else: | ||
d = dict(); | ||
d['sample_names_array'] = sample_names_array | ||
d['vcf_array'] = vcf_array | ||
d['vcf_indexes_array'] = vcf_indexes_array | ||
return d | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(allow_abbrev=False, description='Curate GvsImportGenomes arrays to remove duplicate samples') | ||
|
||
parser.add_argument('--sample_map_to_be_loaded_file_name',type=str, help='name of sample_map file', required=False, default=f"input_{SAMPLE_MAP_TO_BE_LOADED_FILE_SUFFIX}") | ||
parser.add_argument('--sample_name_list_file_name',type=str, help='name of sample name list file', required=False, default=f"input_{SAMPLE_NAME_FILE_SUFFIX}") | ||
parser.add_argument('--vcf_list_file_name',type=str, help='name of VCF list file', required=False, default=f"input_{VCF_FILE_SUFFIX}") | ||
parser.add_argument('--vcf_index_list_file_name',type=str, help='name of VCF index list file', required=False, default=f"input_{VCF_INDEX_FILE_SUFFIX}") | ||
parser.add_argument('--output_files',type=bool, help='true (default): outputs are files; false: outputs are arrays', required=False, default=True) | ||
args = parser.parse_args() | ||
|
||
curate_input_arrays(args.sample_map_to_be_loaded_file_name, | ||
args.sample_name_list_file_name, | ||
args.vcf_list_file_name, | ||
args.vcf_index_list_file_name, | ||
args.output_files) |
10 changes: 10 additions & 0 deletions
10
scripts/variantstore/wdl/extract/curate_input_array_test_files/input_sample_name_list_file
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,10 @@ | ||
ERS4367795 | ||
ERS4367796 | ||
ERS4367797 | ||
ERS4367798 | ||
ERS4367799 | ||
ERS4367800 | ||
ERS4367801 | ||
ERS4367803 | ||
ERS4367804 | ||
ERS4367805 |
8 changes: 8 additions & 0 deletions
8
...ariantstore/wdl/extract/curate_input_array_test_files/input_samples_to_be_loaded_map_file
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,8 @@ | ||
sample_id,sample_name | ||
9,ERS4367804 | ||
7,ERS4367801 | ||
4,ERS4367798 | ||
6,ERS4367800 | ||
10,ERS4367805 | ||
2,ERS4367796 | ||
1,ERS4367795 |
10 changes: 10 additions & 0 deletions
10
scripts/variantstore/wdl/extract/curate_input_array_test_files/input_vcf_index_list_file
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,10 @@ | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/702cdbf7-0666-4ee5-b889-91ba0ffa90bd/call-Reblock/HG00405.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/59ee6ce9-b8d0-4e39-8cc7-8908c6daf87c/call-Reblock/HG00408.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/22604e48-c97b-4709-bb0c-aeeef2891177/call-Reblock/HG00418.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/16c7c3a2-aa82-42ca-904f-8f0eebc21507/call-Reblock/attempt-2/HG00420.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/ee0fbdc6-4d59-4733-a40b-e3fd51b8daea/call-Reblock/HG00423.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/1acc4d0b-812d-4539-9a3b-841c3413d057/call-Reblock/HG00427.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/47091691-f665-4a2c-bc6a-b4b5d57fa222/call-Reblock/HG00429.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/26523d6c-5bae-4486-915d-f4ee3a969420/call-Reblock/HG00444.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/117697bf-fe61-4c18-85c3-162c706c9037/call-Reblock/attempt-2/HG00447.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/d5dbd8dc-bbd1-484a-b4ea-94c02ed896d0/call-Reblock/HG00450.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi |
10 changes: 10 additions & 0 deletions
10
scripts/variantstore/wdl/extract/curate_input_array_test_files/input_vcf_list_file
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,10 @@ | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/702cdbf7-0666-4ee5-b889-91ba0ffa90bd/call-Reblock/HG00405.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/59ee6ce9-b8d0-4e39-8cc7-8908c6daf87c/call-Reblock/HG00408.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/22604e48-c97b-4709-bb0c-aeeef2891177/call-Reblock/HG00418.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/16c7c3a2-aa82-42ca-904f-8f0eebc21507/call-Reblock/attempt-2/HG00420.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/ee0fbdc6-4d59-4733-a40b-e3fd51b8daea/call-Reblock/HG00423.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/1acc4d0b-812d-4539-9a3b-841c3413d057/call-Reblock/HG00427.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/47091691-f665-4a2c-bc6a-b4b5d57fa222/call-Reblock/HG00429.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/26523d6c-5bae-4486-915d-f4ee3a969420/call-Reblock/HG00444.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/117697bf-fe61-4c18-85c3-162c706c9037/call-Reblock/attempt-2/HG00447.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/d5dbd8dc-bbd1-484a-b4ea-94c02ed896d0/call-Reblock/HG00450.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz |
7 changes: 7 additions & 0 deletions
7
...riantstore/wdl/extract/curate_input_array_test_files/output_sample_name_list_file_correct
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,7 @@ | ||
ERS4367795 | ||
ERS4367796 | ||
ERS4367798 | ||
ERS4367800 | ||
ERS4367801 | ||
ERS4367804 | ||
ERS4367805 |
7 changes: 7 additions & 0 deletions
7
...variantstore/wdl/extract/curate_input_array_test_files/output_vcf_index_list_file_correct
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,7 @@ | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/702cdbf7-0666-4ee5-b889-91ba0ffa90bd/call-Reblock/HG00405.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/59ee6ce9-b8d0-4e39-8cc7-8908c6daf87c/call-Reblock/HG00408.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/16c7c3a2-aa82-42ca-904f-8f0eebc21507/call-Reblock/attempt-2/HG00420.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/1acc4d0b-812d-4539-9a3b-841c3413d057/call-Reblock/HG00427.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/47091691-f665-4a2c-bc6a-b4b5d57fa222/call-Reblock/HG00429.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/117697bf-fe61-4c18-85c3-162c706c9037/call-Reblock/attempt-2/HG00447.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi | ||
gs://fc-e2f6ffa2-4033-4517-98fc-889bee4cc7a6/5e6b194b-5f69-40f2-a6de-f4f3f80ce05a/ReblockGVCF/d5dbd8dc-bbd1-484a-b4ea-94c02ed896d0/call-Reblock/HG00450.haplotypeCalls.er.raw.vcf.gz.rb.g.vcf.gz.tbi |
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.
Nit:
Might be clearer as: