Skip to content
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

Print the characteristics of samples provided #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions bin/check_sample_exist.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def main():
description='query Biosamples accessions from a file')
arg_parser.add_argument('--accession_file', required=True,
help='file containing the list of accession to query')
arg_parser.add_argument('--charac_to_query', nargs='*',
help='If set, print out the samples and the values specified')
args = arg_parser.parse_args()

log_cfg.add_stdout_handler()
Expand All @@ -42,12 +44,17 @@ def main():
for sample_accession in open_file:
sample_accession = sample_accession.strip()
try:
response = communicator.follows_link('samples', join_url=sample_accession)
json_data = communicator.follows_link('samples', join_url=sample_accession)
except ValueError:
print(f'{sample_accession} does not exist or is private')
continue
if response:
print(f'{sample_accession} exist and is public')
if json_data:
output = [f'{sample_accession} exist and is public: ']
if args.charac_to_query:
for charac in args.charac_to_query:
if charac not in json_data.get("characteristics", {}):
output.append(f'{charac}: {json_data.get("characteristics", {}).get(charac)}')
print(' '.join(output))


if __name__ == "__main__":
Expand Down
Loading