'Parse the received repository_dependencies dictionary that is associated with a repository being
installed into Galaxy for the first time and attempt to determine repository dependencies that are
already installed and those that are not.'

def get_installed_and_missing_repository_dependencies_for_new_or_updated_install(self, repo_info_tuple):

    missing_repository_dependencies = {}
    installed_repository_dependencies = {}
    missing_rd_tups = []
    installed_rd_tups = []
    (description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, repository_dependencies, tool_dependencies) = repository_util.get_repo_info_tuple_contents(repo_info_tuple)
    if repository_dependencies:
        description = repository_dependencies['description']
        root_key = repository_dependencies['root_key']
        for (key, rd_tups) in repository_dependencies.items():
            if (key in ['description', 'root_key']):
                continue
            for rd_tup in rd_tups:
                (tool_shed, name, owner, changeset_revision, prior_installation_required, only_if_compiling_contained_td) = common_util.parse_repository_dependency_tuple(rd_tup)
                tmp_clone_url = common_util.generate_clone_url_from_repo_info_tup(self.app, rd_tup)
                tmp_repo_info_tuple = (None, tmp_clone_url, changeset_revision, None, owner, None, None)
                (repository, installed_changeset_revision) = repository_util.repository_was_previously_installed(self.app, tool_shed, name, tmp_repo_info_tuple, from_tip=False)
                if repository:
                    new_rd_tup = [tool_shed, name, owner, changeset_revision, prior_installation_required, only_if_compiling_contained_td, repository.id, repository.status]
                    if (repository.status == self.install_model.ToolShedRepository.installation_status.INSTALLED):
                        if (new_rd_tup not in installed_rd_tups):
                            installed_rd_tups.append(new_rd_tup)
                    elif (not util.asbool(only_if_compiling_contained_td)):
                        if (new_rd_tup not in missing_rd_tups):
                            missing_rd_tups.append(new_rd_tup)
                else:
                    new_rd_tup = [tool_shed, name, owner, changeset_revision, prior_installation_required, only_if_compiling_contained_td, None, 'Never    installed']
                    if (not util.asbool(only_if_compiling_contained_td)):
                        if (new_rd_tup not in missing_rd_tups):
                            missing_rd_tups.append(new_rd_tup)
    if installed_rd_tups:
        installed_repository_dependencies['root_key'] = root_key
        installed_repository_dependencies[root_key] = installed_rd_tups
        installed_repository_dependencies['description'] = description
    if missing_rd_tups:
        missing_repository_dependencies['root_key'] = root_key
        missing_repository_dependencies[root_key] = missing_rd_tups
        missing_repository_dependencies['description'] = description
    return (installed_repository_dependencies, missing_repository_dependencies)
