Пример #1
0
    def __check_aligner_valid(self):
        """
		If aligner was specified in input args, check that it is valid and fill in the appropriate parameter
		If aligner arg not correct, throw an exception

		"""
        self.__get_aligner_info()
        available_aligners = self.builder_params.get('available_aligners')
        default_aligner = self.builder_params.get('default_aligner')

        # if no aligner specified in commandline:
        if not self.builder_params.get('aligner'):
            logging.info('Setting aligner to default: %s', default_aligner)
            self.builder_params.reset_param('aligner', default_aligner)
        elif self.builder_params.get('aligner') not in available_aligners:
            logging.error('Incorrect aligner: %s',
                          self.builder_params.get('aligner'))
            logging.error('Available aligners: %s', available_aligners)
            raise IncorrectAlignerException(
                "Unavailable aligner specified.  Check log and correct as necessary."
            )

        # now check that this aligner has a config file.  Does not check that the aligner+genome is OK.
        # That is done when the aligner is invoked.
        chosen_genome = self.builder_params.get('genome')
        aligner = self.builder_params.get('aligner')
        aligner_specific_dir = os.path.join(
            self.builder_params.get('aligners_dir'), aligner)
        logging.info(
            'Searching (but not parsing) for aligner configuration file in: %s',
            aligner_specific_dir)
        util_methods.locate_config(aligner_specific_dir)

        # create a component for the aligner:
        self.all_components.append(Component(aligner, aligner_specific_dir))
Пример #2
0
    def __read_pipeline_config(self):

        # Read the pipeline-level config file
        config_filepath = util_methods.locate_config(
            self.builder_params.get('pipeline_home'))
        logging.info("Default pipeline configuration file is: %s",
                     config_filepath)
        return cfg_parser.read_config(config_filepath)
Пример #3
0
    def __get_aligner_info(self):
        """
		Finds and parses the aligner configuration file-- this only indicates which aligners
		are available and which are default.  Nothing specific to a particular aligner.
		"""
        aligner_cfg = util_methods.locate_config(
            self.builder_params.get('aligners_dir'))
        self.builder_params.add(cfg_parser.read_config(aligner_cfg))
Пример #4
0
    def __get_available_components(self):
        """
		
		"""
        components_dir = self.builder_params.get('components_dir')
        config_filepath = util_methods.locate_config(components_dir)

        # get the plugin parameters-- i.e. each component needs to have a script and entry method to call.
        plugin_parameters = cfg_parser.read_config(config_filepath,
                                                   'plugin_params')
        self.builder_params.add(plugin_parameters)
        entry_module = plugin_parameters[
            'entry_module']  #the script filename (minus the .py extension)
        entry_method = plugin_parameters['entry_method']

        logging.info(
            "Search for available components with configuration file at: %s",
            config_filepath)
        available_components = cfg_parser.read_config(config_filepath,
                                                      'plugins')

        # the paths in the dictionary above are relative to the components_dir-- prepend that directory name for the full path
        available_components = {
            k: os.path.join(components_dir, available_components[k])
            for k in available_components.keys()
        }

        # check that the plugin components have the required structure
        self.available_components = {}
        for k in available_components.keys():
            if util_methods.component_structure_valid(available_components[k],
                                                      entry_module,
                                                      entry_method):
                self.available_components[k] = available_components[k]

        logging.info('Available components: ')
        logging.info(pretty_print(self.available_components))

        # get the specifications for the standard components and the analysis components
        self.standard_components = [
            c for c in cfg_parser.read_config(config_filepath,
                                              'standard_plugins').values()[0]
            if c in self.available_components.keys()
        ]
        self.analysis_components = [
            c for c in cfg_parser.read_config(config_filepath,
                                              'analysis_plugins').values()[0]
            if c in self.available_components.keys()
        ]
        logging.info('Standard components: %s', self.standard_components)
        logging.info('Analysis components: %s', self.analysis_components)
Пример #5
0
    def __check_project_config(self):
        """
		Reads a project configuration file-- this configuration file lays out how a typical project is arranged in terms of file hierarchy,
		naming of fastq files, etc.  Parameters are added to the builder_params object
		"""
        # Read the project-level config file
        if not self.builder_params.get('project_configuration_file'):
            default_filepath = util_methods.locate_config(
                self.builder_params.get('project_configurations_dir'),
                'default')
            self.builder_params.reset_param('project_configuration_file',
                                            default_filepath)

        config_filepath = self.builder_params.get('project_configuration_file')
        logging.info("Project configuration file is: %s", config_filepath)
        self.builder_params.add(cfg_parser.read_config(config_filepath))
Пример #6
0
    def __check_genome_valid(self):
        """
		Ensure that the desired genome is acceptable.  If not, throw an exception
		If the appropriate genome is found, read-in the genome parameters (e.g. path to GTF file, etc)
		"""
        genomes_dir = self.builder_params.get('genomes_dir')
        selected_genome = self.builder_params.get('genome')
        try:
            config_filepath = util_methods.locate_config(genomes_dir)
            self.builder_params.add(
                cfg_parser.read_config(config_filepath, selected_genome))

        except Exception as ex:
            logging.error(
                'Caught exception while looking for genome configuration file: '
            )
            logging.error(ex.message)
            logging.error('Incorrect genome: %s', selected_genome)
            logging.error('See available genomes in : %s', genomes_dir)
            raise IncorrectGenomeException(
                "Incorrect or unconfigured genome specified.  Check log and correct as necessary."
            )