4
4
import json
5
5
from contextlib import closing
6
6
from pathlib import Path
7
+ from datetime import datetime
7
8
8
9
from tdta .utils import read_project_config
9
10
from cas .model import (CellTypeAnnotation , Annotation , Labelset , AnnotationTransfer , AutomatedAnnotation , Review )
@@ -35,12 +36,13 @@ def export_cas_data(sqlite_db: str, output_file: str, dataset_cache_folder: str
35
36
parse_labelset_data (cta , sqlite_db , table_name )
36
37
elif table_name == "annotation_transfer" :
37
38
parse_annotation_transfer_data (cta , sqlite_db , table_name )
38
- elif table_name == "review" :
39
- parse_review_data (cta , sqlite_db , table_name )
39
+ # elif table_name == "review":
40
+ # # don't export reviews to the CAS json for now
41
+ # parse_review_data(cta, sqlite_db, table_name)
40
42
41
43
project_config = read_project_config (Path (output_file ).parent .absolute ())
42
44
43
- if "matrix_file_id" in project_config :
45
+ if project_config and "matrix_file_id" in project_config :
44
46
matrix_file_id = str (project_config ["matrix_file_id" ]).strip ()
45
47
anndata = resolve_matrix_file (matrix_file_id , dataset_cache_folder )
46
48
labelsets = cta .labelsets .copy ()
@@ -163,6 +165,7 @@ def parse_annotation_transfer_data(cta, sqlite_db, table_name):
163
165
else :
164
166
filtered_annotations [0 ].transferred_annotations = [at ]
165
167
168
+
166
169
def parse_review_data (cta , sqlite_db , table_name ):
167
170
"""
168
171
Reads 'Annotation Review' table data into the CAS object
@@ -180,8 +183,10 @@ def parse_review_data(cta, sqlite_db, table_name):
180
183
filtered_annotations = [a for a in cta .annotations
181
184
if a .cell_set_accession == row [columns .index ("target_node_accession" )]]
182
185
if filtered_annotations :
183
- ar = Review ("" , "" , "" , "" , "" )
186
+ ar = Review (None , "" , "" , "" )
184
187
auto_fill_object_from_row (ar , columns , row )
188
+ if ar .datestamp and isinstance (ar .datestamp , str ):
189
+ ar .datestamp = datetime .strptime (ar .datestamp , '%Y-%m-%dT%H:%M:%S.%fZ' )
185
190
if filtered_annotations [0 ].reviews :
186
191
filtered_annotations [0 ].reviews .append (ar )
187
192
else :
0 commit comments