@@ -23,7 +23,12 @@ def to_name_string(annotation_unit: AnnotationUnit):
2323 """
2424 Returns the annotation unit's genomic_unit and corresponding dataset.
2525 """
26- return f"{ annotation_unit .get_genomic_unit ().ljust (30 )} { annotation_unit .get_dataset_name ().ljust (60 )} "
26+ if not annotation_unit .version_calculated ():
27+ return f"{ annotation_unit .get_genomic_unit ().ljust (30 )} { annotation_unit .get_dataset_name ().ljust (105 )} "
28+
29+ name_and_version = f"{ annotation_unit .get_genomic_unit ().ljust (30 )} { annotation_unit .get_dataset_name ().ljust (45 )} "
30+
31+ return f"{ name_and_version } { annotation_unit .get_dataset_source ().ljust (30 )} { str (annotation_unit .version ).ljust (30 )} "
2732
2833
2934def annotation_log_label ():
@@ -34,21 +39,24 @@ def annotation_log_label():
3439 return 'Annotation' .ljust (15 )
3540
3641
37- def format_annotation_logging (annotation_unit : AnnotationUnit , dataset = "" ):
42+ def format_annotation_logging (annotation_unit : AnnotationUnit , note = "" ):
3843 """
3944 Provides a formatted string for logging that is consistent with
4045 annotation unit's genomic_unit and corresponding dataset to the console
4146 The string is padded to make the logs uniform and easier to read.
4247 """
43- if dataset != "" :
44- annotation_unit_string = f"{ annotation_unit .get_genomic_unit ().ljust (30 )} { dataset .ljust (60 )} "
45- else :
46- annotation_unit_string = to_name_string (annotation_unit )
48+ annotation_unit_log_string = ""
4749
4850 if "" != annotation_unit .analysis_name :
49- annotation_unit_string += f"'{ annotation_unit .analysis_name } '" .ljust (20 )
51+ annotation_unit_log_string += f"'{ annotation_unit .analysis_name } '" .ljust (20 )
52+
53+ if annotation_unit is not None :
54+ annotation_unit_log_string += f"{ to_name_string (annotation_unit )} "
55+
56+ if note != "" :
57+ annotation_unit_log_string += f"{ note .ljust (60 )} "
5058
51- return f"{ annotation_log_label ()} { annotation_unit_string } "
59+ return f"{ annotation_log_label ()} { annotation_unit_log_string } "
5260
5361
5462class AnnotationQueue :
@@ -104,7 +112,7 @@ def process_tasks(
104112 analysis_collection : AnalysisCollection
105113 ):
106114 """Processes items that have been added to the queue"""
107- logger .info ("%s Processing annotation tasks queue ..." , annotation_log_label ())
115+ logger .info ("%s Processing annotation tasks queue..." , annotation_log_label ())
108116
109117 processor = AnnotationProcess (annotation_queue , genomic_unit_collection , analysis_collection )
110118
@@ -167,12 +175,31 @@ def process_annotation_unit(self, annotation_unit: AnnotationUnit):
167175 annotation task can be created. If the annotation unit is ready to annotate, it will be submitted to run
168176 on the task execeutor thread pool.
169177 """
170- if not annotation_unit .version_exists ():
178+
179+ possible_manifest_entry = self .retrieve_manifest_entry_if_exist (annotation_unit )
180+ if possible_manifest_entry is not None and not annotation_unit .version_calculated ():
181+ manifest_annotation_unit = self ._create_temporary_annotation_unit (
182+ annotation_unit .genomic_unit , possible_manifest_entry , annotation_unit .analysis_name ,
183+ annotation_unit .is_transcript_dataset ()
184+ )
185+ if not self .genomic_unit_collection .annotation_exist (manifest_annotation_unit ):
186+ logger .error (
187+ '%s Manifest Annotation Does Not Exist...' , format_annotation_logging (manifest_annotation_unit )
188+ )
189+ logger .error (
190+ '%s Remove Manifest Entry Manually...' , format_annotation_logging (manifest_annotation_unit )
191+ )
192+ else :
193+ logger .info ('%s Manifest Annotation Exists...' , format_annotation_logging (manifest_annotation_unit ))
194+ return
195+
196+ if not annotation_unit .version_calculated ():
171197 self .handle_annotation_unit_version_calcuation (annotation_unit )
172198 return
173199
174200 if self .genomic_unit_collection .annotation_exist (annotation_unit ):
175201 logger .info ('%s Annotation Exists...' , format_annotation_logging (annotation_unit ))
202+ self .analysis_collection .add_dataset_to_manifest (annotation_unit .analysis_name , annotation_unit )
176203 return
177204
178205 if annotation_unit .has_dependencies ():
@@ -201,6 +228,7 @@ def on_task_complete(self, future):
201228 """
202229 task = self .annotation_task_futures [future ]
203230 annotation_unit = task .annotation_unit
231+ logger .info ('%s Task Executed...' , format_annotation_logging (annotation_unit ))
204232
205233 try :
206234 task_process_result = future .result ()
@@ -216,14 +244,11 @@ def on_task_complete(self, future):
216244 self .queue .put (annotation_unit )
217245 else :
218246 for annotation in task .extract (task_process_result ):
219- logger .info (
220- '%s Saving %s...' ,
221- format_annotation_logging (annotation_unit ,
222- annotation_unit .get_dataset_name ()), annotation ['value' ]
223- )
247+ logger .info ('%s Saving %s...' , format_annotation_logging (annotation_unit ), annotation ['value' ])
224248
225249 self .genomic_unit_collection .annotate_genomic_unit (annotation_unit .genomic_unit , annotation )
226250 self .analysis_collection .add_dataset_to_manifest (annotation_unit .analysis_name , annotation_unit )
251+ logger .info ('%s Complete...' , format_annotation_logging (annotation_unit ))
227252
228253 except FileNotFoundError as error :
229254 logger .error ('%s Exception [%s] Not Found [%s]' , format_annotation_logging (annotation_unit ), error , task )
@@ -275,6 +300,12 @@ def set_version_in_cache(self, version_cache_id: str, version):
275300 """Sets the version to be cached in the version cache"""
276301 self .version_cache [version_cache_id ] = version
277302
303+ def retrieve_manifest_entry_if_exist (self , annotation_unit : AnnotationUnit ):
304+ """Queries the collection for an annotation unit's manifest entry. If none exists None is returned."""
305+ return self .analysis_collection .get_manifest_dataset_config (
306+ annotation_unit .analysis_name , annotation_unit .get_genomic_unit (), annotation_unit .get_dataset_name ()
307+ )
308+
278309 def handle_annotation_unit_version_calcuation (self , annotation_unit ):
279310 """
280311 Processes the annotation unit to derive the annotation unit's calculated version according to the configuration.
@@ -284,25 +315,24 @@ def handle_annotation_unit_version_calcuation(self, annotation_unit):
284315 version_cache_id = version_task .get_version_cache_id ()
285316
286317 if not self .is_version_cache_setup (version_cache_id ):
287- logger .info ('%s Creating Task To Version...' , format_annotation_logging (annotation_unit ))
318+ logger .info ('%s Creating Calculate Version Task ...' , format_annotation_logging (annotation_unit ))
288319 self .setup_version_cache (version_cache_id )
289320 self .queue_task_in_tasks_worker (version_task )
290321 return
291322
292323 if self .is_version_cached (version_cache_id ):
293324 cached_version = self .version_cache [version_cache_id ]
294325 annotation_unit .set_latest_version (cached_version )
295- logger .info (
296- '%s Version Gathered from Cache %s...' , format_annotation_logging (annotation_unit ), cached_version
297- )
326+ logger .info ('%s Version From Cache %s...' , format_annotation_logging (annotation_unit ), cached_version )
298327 self .queue .put (annotation_unit )
299328
300329 def handle_annotation_unit_dependencies (self , annotation_unit : AnnotationUnit ):
301330 """Retrieves the an annotation unit's dependencies if they exist."""
331+
302332 missing_dependencies = annotation_unit .get_missing_dependencies ()
303333 for missing_dataset_name in missing_dependencies :
304334 analysis_manifest_dataset = self .analysis_collection .get_manifest_dataset_config (
305- annotation_unit .analysis_name , missing_dataset_name
335+ annotation_unit .analysis_name , annotation_unit . get_genomic_unit (), missing_dataset_name
306336 )
307337
308338 if analysis_manifest_dataset is None :
@@ -321,7 +351,7 @@ def handle_annotation_unit_dependencies(self, annotation_unit: AnnotationUnit):
321351
322352 if annotation_unit .if_transcript_needs_provisioning ():
323353 transcript_id_manifest_dataset = self .analysis_collection .get_manifest_dataset_config (
324- annotation_unit .analysis_name , "transcript_id"
354+ annotation_unit .analysis_name , annotation_unit . get_genomic_unit (), "transcript_id"
325355 )
326356
327357 if transcript_id_manifest_dataset is not None :
@@ -337,9 +367,14 @@ def handle_annotation_unit_dependencies(self, annotation_unit: AnnotationUnit):
337367 if transcript_id_dataset_saved :
338368 annotation_unit .set_transcript_provisioned (True )
339369
340- def _create_temporary_annotation_unit (self , genomic_unit , manifest_dataset , analysis_name ):
370+ def _create_temporary_annotation_unit (
371+ self , genomic_unit , manifest_dataset , analysis_name : str , transcript_dataset : bool = False
372+ ):
341373 """Private helper method to create a temporary annotation unit for finding within repository"""
342374 temporary = AnnotationUnit (genomic_unit , manifest_dataset , analysis_name )
343375 temporary .set_latest_version (manifest_dataset ['version' ])
344376
377+ if transcript_dataset :
378+ temporary .dataset ['transcript' ] = True
379+
345380 return temporary
0 commit comments