Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Strand Lab
Strand Lab Cellxgene Gateway
Commits
76c1d9e8
Commit
76c1d9e8
authored
Mar 29, 2021
by
Alok Saldanha
Browse files
removed .csv suffix from annotation name
parent
586dc662
Changes
6
Hide whitespace changes
Inline
Side-by-side
cellxgene_gateway/items/file/fileitem.py
View file @
76c1d9e8
...
...
@@ -18,10 +18,11 @@ class FileItem(Item):
The Item superclass expects a 'name' and 'type'.
"""
def
__init__
(
self
,
subpath
:
str
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
subpath
:
str
,
ext
:
str
=
""
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
subpath
=
subpath
self
.
ext
=
ext
@
property
def
descriptor
(
self
)
->
str
:
return
os
.
path
.
join
(
self
.
subpath
,
self
.
name
).
strip
(
"/"
)
return
os
.
path
.
join
(
self
.
subpath
,
self
.
name
+
self
.
ext
).
strip
(
"/"
)
cellxgene_gateway/items/file/fileitem_source.py
View file @
76c1d9e8
...
...
@@ -150,9 +150,16 @@ class FileItemSource(ItemSource):
def
make_fileitem_from_path
(
self
,
filename
,
subpath
,
is_annotation
=
False
,
is_shallow
=
False
)
->
FileItem
:
if
is_annotation
and
filename
.
endswith
(
self
.
annotation_file_suffix
):
name
=
filename
[:
-
len
(
self
.
annotation_file_suffix
)]
ext
=
self
.
annotation_file_suffix
else
:
name
=
filename
ext
=
""
item
=
FileItem
(
subpath
=
subpath
,
name
=
filename
,
name
=
name
,
ext
=
ext
,
type
=
ItemType
.
annotation
if
is_annotation
else
ItemType
.
h5ad
,
)
...
...
tests/items/__init__.py
0 → 100644
View file @
76c1d9e8
tests/items/file/__init__.py
0 → 100644
View file @
76c1d9e8
tests/items/file/test_fileitem_source.py
0 → 100644
View file @
76c1d9e8
import
tempfile
import
unittest
from
cellxgene_gateway.items.file.fileitem_source
import
FileItemSource
class
TestFileItemSource
(
unittest
.
TestCase
):
def
test_make_fileitem_from_path_GIVEN_annotation_file_THEN_name_lacks_csv
(
self
):
source
=
FileItemSource
(
tempfile
.
gettempdir
(),
"local"
)
item
=
source
.
make_fileitem_from_path
(
"customanno.csv"
,
"someh5ad_annotations"
,
True
)
self
.
assertEqual
(
item
.
name
,
"customanno"
)
self
.
assertEqual
(
item
.
descriptor
,
"someh5ad_annotations/customanno.csv"
)
def
test_make_fileitem_from_path_GIVEN_h5ad_file_THEN_returns_name
(
self
):
source
=
FileItemSource
(
tempfile
.
gettempdir
(),
"local"
)
item
=
source
.
make_fileitem_from_path
(
"someanalysis.h5ad"
,
"studydir"
)
self
.
assertEqual
(
item
.
name
,
"someanalysis.h5ad"
)
self
.
assertEqual
(
item
.
descriptor
,
"studydir/someanalysis.h5ad"
)
tests/test_cache_entry.py
View file @
76c1d9e8
...
...
@@ -10,7 +10,7 @@ from cellxgene_gateway.items.file.fileitem_source import FileItemSource
from
cellxgene_gateway.items.item
import
ItemType
key
=
CacheKey
(
FileItem
(
"/czi/"
,
"pbmc3k.h5ad"
,
ItemType
.
h5ad
),
FileItem
(
"/czi/"
,
name
=
"pbmc3k.h5ad"
,
type
=
ItemType
.
h5ad
),
FileItemSource
(
"/tmp"
,
"local"
),
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment