Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Add check to see if sample ID is available in metadata file exactly o…
Browse files Browse the repository at this point in the history
…nce or report an error when annotating H5AD file with sample info.

Add check to see if sample ID is available in metadata file exactly once
or report an error when annotating H5AD file with sample info.
  • Loading branch information
ghuls committed Jul 27, 2020
1 parent bc16a94 commit c2c3041
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/utils/bin/sc_h5ad_annotate_by_sample_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@
raise Exception("VSN ERROR: The meta data TSV file expects a header with a required 'id' column.")

if args.type == "sample":
for (column_name, column_data) in metadata[metadata.id == SAMPLE_NAME].iteritems():
sample_info = metadata[metadata.id == SAMPLE_NAME]

if len(sample_info) == 0:
raise Exception(f"VSN ERROR: The meta data TSV file does not contain sample ID '{SAMPLE_NAME}'.")
elif len(sample_info) > 1:
raise Exception(f"VSN ERROR: The meta data TSV file contains more than one line with sample ID '{SAMPLE_NAME}'.")

for (column_name, column_data) in sample_info.iteritems():
adata.obs[column_name] = column_data.values[0]
else:
raise Exception("VSN ERROR: This meta data type {} is not implemented".format(args.type))
Expand Down

0 comments on commit c2c3041

Please sign in to comment.