コード例 #1
0
ファイル: Splitter.py プロジェクト: alexwaldrop/GAP
    def add_output(self, split_id, key, value, is_path=True, **kwargs):

        # Check that split id exists
        if split_id not in self.output:
            logging.error(
                "In module %s, cannot add output of type '%s' to undeclared split with id '%s'!"
                % (self.module_id, key, split_id))
            raise RuntimeError(
                "Splitter attempted to add output to undeclared split!")

        # Check that output type hasn't already been set
        if key in self.output[split_id]:
            logging.error(
                "In module %s, the output key '%s' is defined multiple times in same split (split_id: %s)!"
                % (self.module_id, key, split_id))
            raise RuntimeError(
                "Output key '%s' has been defined multiple times within the same split!"
                % key)

        # Convert paths to GAPFiles if they haven't already been converted
        if is_path and not isinstance(value, GAPFile) and value is not None:
            file_id = "%s.%s.%s" % (self.module_id, split_id, key)
            self.output[split_id][key] = GAPFile(file_id,
                                                 file_type=key,
                                                 path=value,
                                                 **kwargs)
        # Otherwise just set the value
        else:
            self.output[split_id][key] = value
コード例 #2
0
 def __make_gap_files(self):
     # Convert path strings to GAPFile objects
     for path_type, paths in self.paths.items():
         # More than one path of same type
         if isinstance(paths, list):
             for i in range(len(paths)):
                 file_id = "%s_%s_%s" % (self.name, path_type, i)
                 self.paths[path_type][i] = GAPFile(file_id,
                                                    path_type,
                                                    paths[i],
                                                    sample_name=self.name)
         # One path of a given type
         else:
             file_id = "%s_%s_1" % (self.name, path_type)
             self.paths[path_type] = GAPFile(file_id,
                                             path_type,
                                             paths,
                                             sample_name=self.name)
コード例 #3
0
 def __init_resource_files(self):
     # Parse resources listed in configs and convert to config objects
     # Return dictionary of resource objects indexed by resource name
     resources = {}
     for resource_id, resource_data in self.config["Path"].items():
         path = resource_data.pop("path")
         resource_type = resource_data.pop("resource_type")
         resources[resource_id] = GAPFile(resource_id, resource_type, path,
                                          **resource_data)
     return resources
コード例 #4
0
 def __init_resource_files(self):
     # Parse resources available to docker image
     # Return dictionary of resource objects indexed by resource name
     resources = {}
     for resource_id, resource_data in self.config.items():
         path = resource_data.pop("path")
         resource_type = resource_data.pop("resource_type")
         resources[resource_id] = GAPFile(resource_id, resource_type, path,
                                          **resource_data)
         resources[resource_id].flag("docker")
     return resources
コード例 #5
0
ファイル: Module.py プロジェクト: alexwaldrop/GAP
    def add_output(self, key, value, is_path=True, **kwargs):
        if key in self.output:
            logging.error(
                "In module %s, the output key '%s' is defined multiple time!" %
                (self.module_id, key))
            raise RuntimeError(
                "Output key '%s' has been defined multiple times!" % key)

        if is_path and not isinstance(value, GAPFile) and value is not None:
            # Convert paths to GAPFiles if they haven't already been converted
            file_id = "%s.%s" % (self.module_id, key)
            value = GAPFile(file_id, file_type=key, path=value, **kwargs)

        self.output[key] = value
コード例 #6
0
ファイル: Module.py プロジェクト: labdave/CloudConductor
    def generate_gapfile(self, key, value, **kwargs):
        # Generate file id
        file_id = "%s.%s" % (self.module_id, key)

        return GAPFile(file_id, file_type=key, path=value, **kwargs)