Warning

This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

Source code for galaxy.tools.toolbox.lineages.factory

from .stock import StockLineage
from .tool_shed import ToolShedLineage


def remove_version_from_guid( guid ):
    """
    Removes version from toolshed-derived tool_id(=guid).
    """
    if "/repos/" not in guid:
        return None
    last_slash = guid.rfind('/')
    return guid[:last_slash]


[docs]class LineageMap(object): """ Map each unique tool id to a lineage object. """
[docs] def __init__(self, app): self.lineage_map = {} self.app = app
[docs] def register(self, tool, from_toolshed=False): tool_id = tool.id versionless_tool_id = remove_version_from_guid( tool_id ) if from_toolshed: lineage = ToolShedLineage.from_tool(self.app, tool) else: lineage = StockLineage.from_tool( tool ) if versionless_tool_id and versionless_tool_id not in self.lineage_map: self.lineage_map[versionless_tool_id] = lineage if tool_id not in self.lineage_map: self.lineage_map[tool_id] = lineage return self.lineage_map[tool_id]
[docs] def get(self, tool_id): if tool_id not in self.lineage_map: lineage = ToolShedLineage.from_tool_id( self.app, tool_id ) if lineage: self.lineage_map[tool_id] = lineage return self.lineage_map.get(tool_id, None)
[docs] def get_versionless(self, tool_id): versionless_tool_id = remove_version_from_guid(tool_id) return self.lineage_map.get(versionless_tool_id, None)
__all__ = ("LineageMap", )