def get_bibtex(this):
        from galaxy.managers.citations import CitationsManager

        citations = []
        for e in this.history.contents_iter():
            if e.creating_job.any_output_dataset_deleted is True or e.creating_job.any_output_dataset_collection_instances_deleted is True:
                continue

            b = CitationsManager(this.trans.app).citations_for_tool_ids([e.creating_job.tool_id])

            if b:
                bib = b[0].to_bibtex()
                if b[0].has_doi and re.search(r'title\s*=\s*\{.+', bib) is None:
                    try:
                        if isinstance(b[0], DoiCitation):
                            tmp = CitationsManager(this.trans.app).doi_cache.get_bibtex(b[0].doi())
                            bib = tmp
                        else:
                            doi = re.search(r'doi\s*=\s*\{(.+)\}', b).group(1)
                            tmp = CitationsManager(this.trans.app).doi_cache.get_bibtex(doi)
                            bib = tmp
                    except:
                        pass

                bib = bib.lstrip()
                if not bib in citations:
                    citations.append(bib)
                    this.bibtex = this.bibtex + "\n\n" + bib

        return {
            'bibtex': this.bibtex
        }
Beispiel #2
0
 def __init__(self, **kwd):
     log.debug("python path is: %s", ", ".join(sys.path))
     self.name = "tool_shed"
     # Read the tool_shed.ini configuration file and check for errors.
     self.config = config.Configuration(**kwd)
     self.config.check()
     configure_logging(self.config)
     self.application_stack = application_stack_instance()
     # Initialize the  Galaxy datatypes registry.
     self.datatypes_registry = galaxy.datatypes.registry.Registry()
     self.datatypes_registry.load_datatypes(self.config.root,
                                            self.config.datatypes_config)
     # Initialize the Tool Shed repository_types registry.
     self.repository_types_registry = tool_shed.repository_types.registry.Registry(
     )
     # Initialize the RepositoryGridFilterManager.
     self.repository_grid_filter_manager = RepositoryGridFilterManager()
     # Determine the Tool Shed database connection string.
     if self.config.database_connection:
         db_url = self.config.database_connection
     else:
         db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % self.config.database
     # Initialize the Tool Shed database and check for appropriate schema version.
     from galaxy.webapps.tool_shed.model.migrate.check import create_or_verify_database
     create_or_verify_database(db_url, self.config.database_engine_options)
     # Set up the Tool Shed database engine and ORM.
     from galaxy.webapps.tool_shed.model import mapping
     self.model = mapping.init(self.config.file_path, db_url,
                               self.config.database_engine_options)
     self.security = idencoding.IdEncodingHelper(
         id_secret=self.config.id_secret)
     # initialize the Tool Shed tag handler.
     self.tag_handler = CommunityTagHandler(self)
     # Initialize the Tool Shed tool data tables.  Never pass a configuration file here
     # because the Tool Shed should always have an empty dictionary!
     self.tool_data_tables = galaxy.tools.data.ToolDataTableManager(
         self.config.tool_data_path)
     self.genome_builds = GenomeBuilds(self)
     from galaxy import auth
     self.auth_manager = auth.AuthManager(self)
     # Citation manager needed to load tools.
     from galaxy.managers.citations import CitationsManager
     self.citations_manager = CitationsManager(self)
     # The Tool Shed makes no use of a Galaxy toolbox, but this attribute is still required.
     self.toolbox = tools.ToolBox([], self.config.tool_path, self)
     # Initialize the Tool Shed security agent.
     self.security_agent = self.model.security_agent
     # The Tool Shed makes no use of a quota, but this attribute is still required.
     self.quota_agent = galaxy.quota.NoQuotaAgent(self.model)
     # Initialize the baseline Tool Shed statistics component.
     self.shed_counter = self.model.shed_counter
     # Let the Tool Shed's HgwebConfigManager know where the hgweb.config file is located.
     self.hgweb_config_manager = self.model.hgweb_config_manager
     self.hgweb_config_manager.hgweb_config_dir = self.config.hgweb_config_dir
     # Initialize the repository registry.
     self.repository_registry = tool_shed.repository_registry.Registry(self)
     #  used for cachebusting -- refactor this into a *SINGLE* UniverseApplication base.
     self.server_starttime = int(time.time())
     log.debug("Tool shed hgweb.config file is: %s",
               self.hgweb_config_manager.hgweb_config)
Beispiel #3
0
 def __init__(self, **kwd):
     print >> sys.stderr, "python path is: " + ", ".join(sys.path)
     self.name = "tool_shed"
     # Read the tool_shed_wsgi.ini configuration file and check for errors.
     self.config = config.Configuration(**kwd)
     self.config.check()
     config.configure_logging(self.config)
     # Initialize the  Galaxy datatypes registry.
     self.datatypes_registry = galaxy.datatypes.registry.Registry()
     self.datatypes_registry.load_datatypes(self.config.root,
                                            self.config.datatypes_config)
     # Initialize the Tool Shed repository_types registry.
     self.repository_types_registry = tool_shed.repository_types.registry.Registry(
     )
     # Initialize the RepositoryGridFilterManager.
     self.repository_grid_filter_manager = RepositoryGridFilterManager()
     # Determine the Tool Shed database connection string.
     if self.config.database_connection:
         db_url = self.config.database_connection
     else:
         db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % self.config.database
     # Initialize the Tool Shed database and check for appropriate schema version.
     from galaxy.webapps.tool_shed.model.migrate.check import create_or_verify_database
     create_or_verify_database(db_url, self.config.database_engine_options)
     # Set up the Tool Shed database engine and ORM.
     from galaxy.webapps.tool_shed.model import mapping
     self.model = mapping.init(self.config.file_path, db_url,
                               self.config.database_engine_options)
     # Initialize the Tool SHed security helper.
     self.security = security.SecurityHelper(
         id_secret=self.config.id_secret)
     # initialize the Tool Shed tag handler.
     self.tag_handler = CommunityTagHandler()
     # Initialize the Tool Shed tool data tables.  Never pass a configuration file here
     # because the Tool Shed should always have an empty dictionary!
     self.tool_data_tables = galaxy.tools.data.ToolDataTableManager(
         self.config.tool_data_path)
     self.genome_builds = GenomeBuilds(self)
     # Citation manager needed to load tools.
     from galaxy.managers.citations import CitationsManager
     self.citations_manager = CitationsManager(self)
     # The Tool Shed makes no use of a Galaxy toolbox, but this attribute is still required.
     self.toolbox = tools.ToolBox([], self.config.tool_path, self)
     # Initialize the Tool Shed security agent.
     self.security_agent = self.model.security_agent
     # The Tool Shed makes no use of a quota, but this attribute is still required.
     self.quota_agent = galaxy.quota.NoQuotaAgent(self.model)
     # TODO: Add OpenID support
     self.openid_providers = OpenIDProviders()
     # Initialize the baseline Tool Shed statistics component.
     self.shed_counter = self.model.shed_counter
     # Let the Tool Shed's HgwebConfigManager know where the hgweb.config file is located.
     self.hgweb_config_manager = self.model.hgweb_config_manager
     self.hgweb_config_manager.hgweb_config_dir = self.config.hgweb_config_dir
     # Initialize the repository registry.
     self.repository_registry = tool_shed.repository_registry.Registry(self)
     print >> sys.stderr, "Tool shed hgweb.config file is: ", self.hgweb_config_manager.hgweb_config
Beispiel #4
0
    def _configure_toolbox(self):
        if not isinstance(self, BasicSharedApp):
            raise Exception("Must inherit from BasicSharedApp")

        self.citations_manager = CitationsManager(self)
        self.biotools_metadata_source = get_galaxy_biotools_metadata_source(
            self.config)

        self.dynamic_tools_manager = DynamicToolManager(self)
        self._toolbox_lock = threading.RLock()
        self.toolbox = tools.ToolBox(self.config.tool_configs,
                                     self.config.tool_path, self)
        galaxy_root_dir = os.path.abspath(self.config.root)
        file_path = os.path.abspath(self.config.file_path)
        app_info = AppInfo(
            galaxy_root_dir=galaxy_root_dir,
            default_file_path=file_path,
            tool_data_path=self.config.tool_data_path,
            shed_tool_data_path=self.config.shed_tool_data_path,
            outputs_to_working_directory=self.config.
            outputs_to_working_directory,
            container_image_cache_path=self.config.container_image_cache_path,
            library_import_dir=self.config.library_import_dir,
            enable_mulled_containers=self.config.enable_mulled_containers,
            container_resolvers_config_file=self.config.
            container_resolvers_config_file,
            container_resolvers_config_dict=self.config.container_resolvers,
            involucro_path=self.config.involucro_path,
            involucro_auto_init=self.config.involucro_auto_init,
            mulled_channels=self.config.mulled_channels,
        )
        mulled_resolution_cache = None
        if self.config.mulled_resolution_cache_type:
            cache_opts = {
                "cache.type": self.config.mulled_resolution_cache_type,
                "cache.data_dir": self.config.mulled_resolution_cache_data_dir,
                "cache.lock_dir": self.config.mulled_resolution_cache_lock_dir,
                "cache.expire": self.config.mulled_resolution_cache_expire,
            }
            mulled_resolution_cache = CacheManager(
                **parse_cache_config_options(cache_opts)).get_cache(
                    'mulled_resolution')
        self.container_finder = containers.ContainerFinder(
            app_info, mulled_resolution_cache=mulled_resolution_cache)
        self._set_enabled_container_types()
        index_help = getattr(self.config, "index_tool_help", True)
        self.toolbox_search = ToolBoxSearch(
            self.toolbox,
            index_dir=self.config.tool_search_index_dir,
            index_help=index_help)
Beispiel #5
0
    def _configure_toolbox( self ):
        # Initialize the tools, making sure the list of tool configs includes the reserved migrated_tools_conf.xml file.
        tool_configs = self.config.tool_configs
        if self.config.migrated_tools_config not in tool_configs:
            tool_configs.append( self.config.migrated_tools_config )

        from galaxy.managers.citations import CitationsManager
        self.citations_manager = CitationsManager( self )

        from galaxy import tools
        self.toolbox = tools.ToolBox( tool_configs, self.config.tool_path, self )
        self.reindex_tool_search()

        from galaxy.tools.deps import containers
        galaxy_root_dir = os.path.abspath(self.config.root)
        file_path = os.path.abspath(getattr(self.config, "file_path"))
        app_info = containers.AppInfo(
            galaxy_root_dir,
            default_file_path=file_path,
            outputs_to_working_directory=self.config.outputs_to_working_directory,
            container_image_cache_path=self.config.container_image_cache_path,
        )
        self.container_finder = containers.ContainerFinder(app_info)
Beispiel #6
0
 def __init__(self, **kwd) -> None:
     super().__init__()
     self[BasicApp] = self
     log.debug("python path is: %s", ", ".join(sys.path))
     self.name = "tool_shed"
     # will be overwritten when building WSGI app
     self.is_webapp = False
     # Read the tool_shed.ini configuration file and check for errors.
     self.config: Any = config.Configuration(**kwd)
     self.config.check()
     configure_logging(self.config)
     self.application_stack = application_stack_instance()
     # Initialize the  Galaxy datatypes registry.
     self.datatypes_registry = galaxy.datatypes.registry.Registry()
     self.datatypes_registry.load_datatypes(self.config.root,
                                            self.config.datatypes_config)
     # Initialize the Tool Shed repository_types registry.
     self.repository_types_registry = tool_shed.repository_types.registry.Registry(
     )
     # Initialize the RepositoryGridFilterManager.
     self.repository_grid_filter_manager = RepositoryGridFilterManager()
     # Determine the Tool Shed database connection string.
     if self.config.database_connection:
         db_url = self.config.database_connection
     else:
         db_url = f"sqlite:///{self.config.database}?isolation_level=IMMEDIATE"
     # Initialize the Tool Shed database and check for appropriate schema version.
     from tool_shed.webapp.model.migrate.check import create_or_verify_database
     create_or_verify_database(db_url, self.config.database_engine_options)
     # Set up the Tool Shed database engine and ORM.
     from tool_shed.webapp.model import mapping
     model: mapping.ToolShedModelMapping = mapping.init(
         self.config.file_path, db_url, self.config.database_engine_options)
     self.model = model
     self.security = idencoding.IdEncodingHelper(
         id_secret=self.config.id_secret)
     self._register_singleton(idencoding.IdEncodingHelper, self.security)
     self._register_singleton(SharedModelMapping, model)
     self._register_singleton(mapping.ToolShedModelMapping, model)
     self._register_singleton(scoped_session, self.model.context)
     self._register_singleton(UserManager, UserManager)
     # initialize the Tool Shed tag handler.
     self.tag_handler = CommunityTagHandler(self)
     # Initialize the Tool Shed tool data tables.  Never pass a configuration file here
     # because the Tool Shed should always have an empty dictionary!
     self.tool_data_tables = galaxy.tools.data.ToolDataTableManager(
         self.config.tool_data_path)
     self.genome_builds = GenomeBuilds(self)
     self.auth_manager = self._register_singleton(
         auth.AuthManager, auth.AuthManager(self.config))
     # Citation manager needed to load tools.
     self.citations_manager = self._register_singleton(
         CitationsManager, CitationsManager(self))
     self.use_tool_dependency_resolution = False
     # Initialize the Tool Shed security agent.
     self.security_agent = model.security_agent
     # The Tool Shed makes no use of a quota, but this attribute is still required.
     self.quota_agent = self._register_singleton(QuotaAgent, NoQuotaAgent())
     # Initialize the baseline Tool Shed statistics component.
     self.shed_counter = model.shed_counter
     # Let the Tool Shed's HgwebConfigManager know where the hgweb.config file is located.
     self.hgweb_config_manager = hgweb_config_manager
     self.hgweb_config_manager.hgweb_config_dir = self.config.hgweb_config_dir
     # Initialize the repository registry.
     self.repository_registry = tool_shed.repository_registry.Registry(self)
     #  used for cachebusting -- refactor this into a *SINGLE* UniverseApplication base.
     self.server_starttime = int(time.time())
     log.debug("Tool shed hgweb.config file is: %s",
               self.hgweb_config_manager.hgweb_config)