Exemplo n.º 1
0
    def _covert_to_cwl_format(val):
        file_obj = copy.deepcopy(val)
        location = file_obj.pop('location', None)
        if location:
            try:
                file_db_object = FileProcessor.get_file_obj(location)
            except FileHelperException as e:
                raise PortProcessorException('File %s not found' % location)
            path = file_db_object.path
            path_obj = Path(path)
            checksum = FileProcessor.get_file_checksum(file_db_object)
            if checksum:
                file_obj['checksum'] = checksum
            size = FileProcessor.get_file_size(file_db_object)
            if size:
                file_obj['size'] = size
            file_obj['basename'] = path_obj.name
            file_obj['nameext'] = path_obj.suffix
            file_obj['nameroot'] = path_obj.stem
            file_obj['path'] = path
        secondary_files = file_obj.pop('secondaryFiles', [])
        secondary_files_value = PortProcessor.process_files(
            secondary_files, PortAction.CONVERT_TO_CWL_FORMAT)
        if secondary_files_value:
            file_obj['secondaryFiles'] = secondary_files_value

        return file_obj
Exemplo n.º 2
0
 def _convert_to_path(val):
     file_obj = copy.deepcopy(val)
     location = file_obj.pop("location", None)
     if not location and val.get("contents"):
         logger.debug("Processing file literal %s", str(val))
         return val
     try:
         path = FileProcessor.get_file_path(location)
     except FileHelperException as e:
         raise PortProcessorException("File %s not found" % location)
     secondary_files = file_obj.pop("secondaryFiles", [])
     secondary_files_value = PortProcessor.process_files(secondary_files, PortAction.CONVERT_TO_PATH)
     if secondary_files_value:
         file_obj["secondaryFiles"] = secondary_files_value
     file_obj["path"] = path
     return file_obj
Exemplo n.º 3
0
 def _process_file(file_obj, action, **kwargs):
     if action == PortAction.CONVERT_TO_BID:
         return PortProcessor._update_location_to_bid(file_obj, kwargs.get('file_list'))
     if action == PortAction.FIX_DB_VALUES:
         return PortProcessor._fix_locations_in_db(file_obj, kwargs.get('file_list'))
     if action == PortAction.CONVERT_TO_PATH:
         return PortProcessor._convert_to_path(file_obj)
     if action == PortAction.CONVERT_TO_CWL_FORMAT:
         return PortProcessor._covert_to_cwl_format(file_obj)
     if action == PortAction.REGISTER_OUTPUT_FILES:
         return PortProcessor._register_file(file_obj,
                                             kwargs.get('size'),
                                             kwargs.get('group_id'),
                                             kwargs.get('metadata'),
                                             kwargs.get('file_list'))
     if action == PortAction.SEND_AS_NOTIFICATION:
         return PortProcessor._send_as_notification(file_obj, kwargs.get('job_group'))
     else:
         raise PortProcessorException('Unknown PortProcessor action: %s' % action)
Exemplo n.º 4
0
 def _process_file(file_obj, action, **kwargs):
     if action == PortAction.CONVERT_TO_BID:
         return PortProcessor._update_location_to_bid(file_obj, kwargs.get("file_list"))
     if action == PortAction.FIX_DB_VALUES:
         return PortProcessor._fix_locations_in_db(file_obj, kwargs.get("file_list"))
     if action == PortAction.CONVERT_TO_PATH:
         return PortProcessor._convert_to_path(file_obj)
     if action == PortAction.CONVERT_TO_CWL_FORMAT:
         return PortProcessor._covert_to_cwl_format(file_obj)
     if action == PortAction.REGISTER_OUTPUT_FILES:
         return PortProcessor._register_file(
             file_obj, kwargs.get("size"), kwargs.get("group_id"), kwargs.get("metadata"), kwargs.get("file_list")
         )
     if action == PortAction.SEND_AS_NOTIFICATION:
         return PortProcessor._send_as_notification(file_obj, kwargs.get("job_group"))
     if action == PortAction.NEXTFLOW_TEMPLATE:
         return file_obj["path"]
     else:
         raise PortProcessorException("Unknown PortProcessor action: %s" % action)