mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-10-09 19:50:55 +08:00
#14 added custom method to create data dirs
This commit is contained in:
@@ -28,12 +28,13 @@ def get_key(path):
|
||||
if trimmed.endswith('.h5ad') and data_file_exists(trimmed):
|
||||
# 1) somedir/dataset.h5ad: a dataset
|
||||
return CacheKey(trimmed, trimmed, None)
|
||||
elif trimmed.endswith('.csv') and data_file_exists(trimmed):
|
||||
elif trimmed.endswith('.csv'):
|
||||
|
||||
# 2) somedir/dataset_annotations/saldaal1-T5HMVBNV.csv : an actual annotaitons file.
|
||||
# 2) somedir/dataset_annotations/saldaal1-T5HMVBNV.csv : an actual annotations file.
|
||||
annotations_dir = os.path.split(trimmed)[0]
|
||||
dataset = make_h5ad(annotations_dir)
|
||||
if data_file_exists(dataset):
|
||||
data_dir_ensure(annotations_dir)
|
||||
return CacheKey(trimmed, dataset, trimmed)
|
||||
elif trimmed.endswith('_annotations') and data_dir_exists(trimmed):
|
||||
# 3) somedir/dataset_annotations: an annotation directory. The corresponding h5ad must exist, but the directory may not.
|
||||
@@ -74,6 +75,10 @@ def data_dir_exists(dataset):
|
||||
file_path = os.path.join(env.cellxgene_data, dataset)
|
||||
validate_is_dir(file_path)
|
||||
return True
|
||||
def data_dir_ensure(dataset):
|
||||
file_path = os.path.join(env.cellxgene_data, dataset)
|
||||
if not os.path.exists(file_path):
|
||||
os.makedirs(file_path)
|
||||
|
||||
def get_file_path(key):
|
||||
dataset = key.dataset
|
||||
@@ -82,12 +87,9 @@ def get_file_path(key):
|
||||
return file_path
|
||||
|
||||
def get_annotation_file_path(key):
|
||||
print(f"getting annotaiton_file_path for {key.annotation_file}")
|
||||
if key.annotation_file is None:
|
||||
return None
|
||||
if key.annotation_file == '':
|
||||
return ''
|
||||
file_path = os.path.join(env.cellxgene_data, key.annotation_file)
|
||||
print(f"getting annotaiton_file_path for {key}, file_path {file_path}")
|
||||
validate_is_file(file_path)
|
||||
return file_path
|
||||
|
||||
Reference in New Issue
Block a user