'Return the lists of installed tool dependencies and missing tool dependencies for a Tool Shed
repository that has been installed into Galaxy.'

def get_installed_and_missing_tool_dependencies_for_installed_repository(self, repository, all_tool_dependencies):

    if all_tool_dependencies:
        tool_dependencies = {}
        missing_tool_dependencies = {}
        for (td_key, val) in all_tool_dependencies.items():
            if (td_key in ['set_environment']):
                for (index, td_info_dict) in enumerate(val):
                    name = td_info_dict['name']
                    version = None
                    type = td_info_dict['type']
                    tool_dependency = tool_dependency_util.get_tool_dependency_by_name_type_repository(self.app, repository, name, type)
                    if tool_dependency:
                        td_info_dict['repository_id'] = repository.id
                        td_info_dict['tool_dependency_id'] = tool_dependency.id
                        if tool_dependency.status:
                            tool_dependency_status = str(tool_dependency.status)
                        else:
                            tool_dependency_status = 'Never    installed'
                        td_info_dict['status'] = tool_dependency_status
                        val[index] = td_info_dict
                        if (tool_dependency.status == self.app.install_model.ToolDependency.installation_status.INSTALLED):
                            tool_dependencies[td_key] = val
                        else:
                            missing_tool_dependencies[td_key] = val
            else:
                name = val['name']
                version = val['version']
                type = val['type']
                tool_dependency = tool_dependency_util.get_tool_dependency_by_name_version_type_repository(self.app, repository, name, version, type)
                if tool_dependency:
                    val['repository_id'] = repository.id
                    val['tool_dependency_id'] = tool_dependency.id
                    if tool_dependency.status:
                        tool_dependency_status = str(tool_dependency.status)
                    else:
                        tool_dependency_status = 'Never    installed'
                    val['status'] = tool_dependency_status
                    if (tool_dependency.status == self.app.install_model.ToolDependency.installation_status.INSTALLED):
                        tool_dependencies[td_key] = val
                    else:
                        missing_tool_dependencies[td_key] = val
    else:
        tool_dependencies = None
        missing_tool_dependencies = None
    return (tool_dependencies, missing_tool_dependencies)
