def installed_tool_list(self):
     """
     gets a tool list from the toolclient
     :return:
     """
     tool_client = ToolClient(self.gi)
     return tool_client.get_tools()
 def installed_tool_list(self):
     """
     gets a tool list from the toolclient
     :return:
     """
     tool_client = ToolClient(self.gi)
     return tool_client.get_tools()
Ejemplo n.º 3
0
    def retrieve_tools_from_instance(cls, instance):

        galaxy_instance = GalaxyInstance(url=instance.url)
        tool_client = ToolClient(galaxy_instance)
        for element in tool_client.get_tools():
            if element['model_class'] == 'Tool':

                tool_name = element['id']
                if '/' in tool_name:
                    tool_name = tool_name.split('/')[-2]

                tool = Tool.query.filter_by(name=tool_name).first()
                if tool is None:
                    tool = Tool(name=tool_name)
                    db.session.add(tool)

                tool.description = element['description']
                tool.display_name = element['name']
                if 'link' in element:
                    link = element.get('link', None)
                    link_start = link.find('/tool_runner')
                    if link_start != -1:
                        tool.link = link[link_start:]

                for edam_opetation_id in element.get('edam_operations', []):
                    edam_operation = EDAMOperation.get_from_id(
                        edam_opetation_id, allow_creation=True)
                    if edam_operation is not None and edam_operation not in tool.edam_operations:
                        tool.edam_operations.append(edam_operation)

                if 'tool_shed_repository' in element:
                    tool_version = ToolVersion.query\
                                              .filter_by(name=tool_name)\
                                              .filter_by(changeset=element['tool_shed_repository']['changeset_revision'])\
                                              .filter_by(tool_shed=element['tool_shed_repository']['tool_shed'])\
                                              .filter_by(owner=element['tool_shed_repository']['owner'])\
                                              .first()
                else:
                    tool_version = ToolVersion.query\
                                              .filter_by(name=tool_name)\
                                              .filter_by(version=element['version'])\
                                              .filter_by(tool_shed=None)\
                                              .filter_by(owner=None)\
                                              .first()
                if tool_version is None:
                    tool_version = ToolVersion(name=tool_name,
                                               version=element['version'])
                    db.session.add(tool_version)

                if 'tool_shed_repository' in element:
                    tool_version.changeset = element['tool_shed_repository'][
                        'changeset_revision']
                    tool_version.tool_shed = element['tool_shed_repository'][
                        'tool_shed']
                    tool_version.owner = element['tool_shed_repository'][
                        'owner']

                if instance not in tool_version.instances:
                    tool_version.instances.append(instance)

                if tool_version not in tool.versions:
                    tool.versions.append(tool_version)

                db.session.commit()
Ejemplo n.º 4
0
def get_tools(gi):
    tool_client = ToolClient(gi)
    return tool_client.get_tools()
Ejemplo n.º 5
0
    def retrieve_tools_from_instance(cls, instance):

        galaxy_instance = GalaxyInstance(url=instance.url)
        tool_client = ToolClient(galaxy_instance)
        for element in tool_client.get_tools():
            if element['model_class'] == 'Tool':

                tool_name = element['id']
                if '/' in tool_name:
                    tool_name = tool_name.split('/')[-2]

                try:
                    tool = Tool.objects.get(name=tool_name)
                except Tool.DoesNotExist:
                    tool = Tool(name=tool_name)

                tool.description = element['description']
                tool.display_name = element['name']

                for edam_opetation_id in element['edam_operations']:
                    edam_operation = EDAMOperation.get_from_id(
                        edam_opetation_id, allow_creation=True)
                    if edam_operation is not None and edam_operation not in tool.edam_operations:
                        tool.edam_operations.append(edam_operation)

                try:
                    if 'tool_shed_repository' in element:
                        tool_version = ToolVersion.objects.get(
                            name=tool_name,
                            changeset=element['tool_shed_repository']
                            ['changeset_revision'],
                            tool_shed=element['tool_shed_repository']
                            ['tool_shed'],
                            owner=element['tool_shed_repository']['owner'])
                    else:
                        tool_version = ToolVersion.objects.get(
                            name=tool_name,
                            version=element['version'],
                            tool_shed=None,
                            owner=None)
                except ToolVersion.DoesNotExist:
                    tool_version = ToolVersion(name=tool_name,
                                               version=element['version'])

                if 'tool_shed_repository' in element:
                    tool_version.changeset = element['tool_shed_repository'][
                        'changeset_revision']
                    tool_version.tool_shed = element['tool_shed_repository'][
                        'tool_shed']
                    tool_version.owner = element['tool_shed_repository'][
                        'owner']

                if instance not in tool_version.instances:
                    tool_version.instances.append(instance)

                tool_version.save()

                if tool_version not in tool.versions:
                    tool.versions.append(tool_version)

                tool.save()