{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Mutagenicity:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : True\n",
      "is_directed : False\n",
      "dataset_size : 4337\n",
      "ave_graph_size : 30.3177311506\n",
      "min_graph_size : 4\n",
      "max_graph_size : 417\n",
      "ave_graph_edge_num : 30.7694258704\n",
      "min_graph_edge_num : 3\n",
      "max_graph_edge_num : 112\n",
      "ave_graph_degree : 3.75651371916\n",
      "min_graph_degree : 3\n",
      "max_graph_degree : 4\n",
      "node_label_num : 14\n",
      "edge_label_num : 3\n",
      "node_attr_dim : False\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n",
      "\n",
      "AIDS:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : True\n",
      "is_directed : False\n",
      "dataset_size : 2000\n",
      "ave_graph_size : 15.6925\n",
      "min_graph_size : 2\n",
      "max_graph_size : 95\n",
      "ave_graph_edge_num : 16.195\n",
      "min_graph_edge_num : 1\n",
      "max_graph_edge_num : 103\n",
      "ave_graph_degree : 3.322\n",
      "min_graph_degree : 1\n",
      "max_graph_degree : 6\n",
      "node_label_num : 38\n",
      "edge_label_num : 3\n",
      "node_attr_dim : 4\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n",
      "\n",
      "FIRSTMM_DB:\n",
      "substructures : {'non linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 41\n",
      "ave_graph_size : 1377.26829268\n",
      "min_graph_size : 134\n",
      "max_graph_size : 5037\n",
      "ave_graph_edge_num : 3074.09756098\n",
      "min_graph_edge_num : 320\n",
      "max_graph_edge_num : 10888\n",
      "ave_graph_degree : 7.85365853659\n",
      "min_graph_degree : 6\n",
      "max_graph_degree : 10\n",
      "node_label_num : 5\n",
      "edge_label_num : 0\n",
      "node_attr_dim : 1\n",
      "edge_attr_dim : 2\n",
      "class_number : 11\n",
      "\n",
      "\n",
      "MSRC9:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 221\n",
      "ave_graph_size : 40.5791855204\n",
      "min_graph_size : 25\n",
      "max_graph_size : 55\n",
      "ave_graph_edge_num : 97.9366515837\n",
      "min_graph_edge_num : 53\n",
      "max_graph_edge_num : 145\n",
      "ave_graph_degree : 10.1583710407\n",
      "min_graph_degree : 8\n",
      "max_graph_degree : 16\n",
      "node_label_num : 10\n",
      "edge_label_num : 0\n",
      "node_attr_dim : False\n",
      "edge_attr_dim : False\n",
      "class_number : 8\n",
      "\n",
      "\n",
      "MSRC21:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 563\n",
      "ave_graph_size : 77.5204262877\n",
      "min_graph_size : 51\n",
      "max_graph_size : 141\n",
      "ave_graph_edge_num : 198.323268206\n",
      "min_graph_edge_num : 121\n",
      "max_graph_edge_num : 405\n",
      "ave_graph_degree : 11.4156305506\n",
      "min_graph_degree : 8\n",
      "max_graph_degree : 23\n",
      "node_label_num : 22\n",
      "edge_label_num : 0\n",
      "node_attr_dim : False\n",
      "edge_attr_dim : False\n",
      "class_number : 20\n",
      "\n",
      "\n",
      "SYNTHETIC:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 300\n",
      "ave_graph_size : 100.0\n",
      "min_graph_size : 100\n",
      "max_graph_size : 100\n",
      "ave_graph_edge_num : 196.0\n",
      "min_graph_edge_num : 196\n",
      "max_graph_edge_num : 196\n",
      "ave_graph_degree : 8.0\n",
      "min_graph_degree : 8\n",
      "max_graph_degree : 8\n",
      "node_label_num : 8\n",
      "edge_label_num : 0\n",
      "node_attr_dim : 1\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n",
      "\n",
      "BZR:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 405\n",
      "ave_graph_size : 35.750617284\n",
      "min_graph_size : 13\n",
      "max_graph_size : 57\n",
      "ave_graph_edge_num : 38.3580246914\n",
      "min_graph_edge_num : 13\n",
      "max_graph_edge_num : 60\n",
      "ave_graph_degree : 3.86419753086\n",
      "min_graph_degree : 3\n",
      "max_graph_degree : 4\n",
      "node_label_num : 10\n",
      "edge_label_num : 0\n",
      "node_attr_dim : 3\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n",
      "\n",
      "COX2:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 467\n",
      "ave_graph_size : 41.2248394004\n",
      "min_graph_size : 32\n",
      "max_graph_size : 56\n",
      "ave_graph_edge_num : 43.4453961456\n",
      "min_graph_edge_num : 34\n",
      "max_graph_edge_num : 59\n",
      "ave_graph_degree : 4.0\n",
      "min_graph_degree : 4\n",
      "max_graph_degree : 4\n",
      "node_label_num : 8\n",
      "edge_label_num : 0\n",
      "node_attr_dim : 3\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n",
      "\n",
      "DHFR:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 756\n",
      "ave_graph_size : 42.4272486772\n",
      "min_graph_size : 20\n",
      "max_graph_size : 71\n",
      "ave_graph_edge_num : 44.544973545\n",
      "min_graph_edge_num : 21\n",
      "max_graph_edge_num : 73\n",
      "ave_graph_degree : 3.95502645503\n",
      "min_graph_degree : 3\n",
      "max_graph_degree : 4\n",
      "node_label_num : 9\n",
      "edge_label_num : 0\n",
      "node_attr_dim : 3\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n",
      "\n",
      "ENZYMES:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 600\n",
      "ave_graph_size : 32.6333333333\n",
      "min_graph_size : 2\n",
      "max_graph_size : 126\n",
      "ave_graph_edge_num : 62.1366666667\n",
      "min_graph_edge_num : 1\n",
      "max_graph_edge_num : 149\n",
      "ave_graph_degree : 6.08666666667\n",
      "min_graph_degree : 1\n",
      "max_graph_degree : 9\n",
      "node_label_num : 3\n",
      "edge_label_num : 0\n",
      "node_attr_dim : 18\n",
      "edge_attr_dim : False\n",
      "class_number : 6\n",
      "\n",
      "\n",
      "PROTEINS:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 1113\n",
      "ave_graph_size : 39.0575022462\n",
      "min_graph_size : 4\n",
      "max_graph_size : 620\n",
      "ave_graph_edge_num : 72.8158131177\n",
      "min_graph_edge_num : 5\n",
      "max_graph_edge_num : 1049\n",
      "ave_graph_degree : 5.79424977538\n",
      "min_graph_degree : 3\n",
      "max_graph_degree : 25\n",
      "node_label_num : 3\n",
      "edge_label_num : 0\n",
      "node_attr_dim : 1\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n",
      "\n",
      "PROTEINS_full:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 1113\n",
      "ave_graph_size : 39.0575022462\n",
      "min_graph_size : 4\n",
      "max_graph_size : 620\n",
      "ave_graph_edge_num : 72.8158131177\n",
      "min_graph_edge_num : 5\n",
      "max_graph_edge_num : 1049\n",
      "ave_graph_degree : 5.79424977538\n",
      "min_graph_degree : 3\n",
      "max_graph_degree : 25\n",
      "node_label_num : 3\n",
      "edge_label_num : 0\n",
      "node_attr_dim : 29\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n",
      "\n",
      "D&D:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 1178\n",
      "ave_graph_size : 284.31663837\n",
      "min_graph_size : 30\n",
      "max_graph_size : 5748\n",
      "ave_graph_edge_num : 715.658743633\n",
      "min_graph_edge_num : 63\n",
      "max_graph_edge_num : 14267\n",
      "ave_graph_degree : 9.50933786078\n",
      "min_graph_degree : 6\n",
      "max_graph_degree : 19\n",
      "node_label_num : 82\n",
      "edge_label_num : 0\n",
      "node_attr_dim : False\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n",
      "\n",
      "MUTAG:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : True\n",
      "is_directed : False\n",
      "dataset_size : 188\n",
      "ave_graph_size : 17.9308510638\n",
      "min_graph_size : 10\n",
      "max_graph_size : 28\n",
      "ave_graph_edge_num : 19.7925531915\n",
      "min_graph_edge_num : 10\n",
      "max_graph_edge_num : 33\n",
      "ave_graph_degree : 3.00531914894\n",
      "min_graph_degree : 3\n",
      "max_graph_degree : 4\n",
      "node_label_num : 7\n",
      "edge_label_num : 11\n",
      "node_attr_dim : False\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n",
      "\n",
      "Alkane:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 150\n",
      "ave_graph_size : 8.87333333333\n",
      "min_graph_size : 1\n",
      "max_graph_size : 10\n",
      "ave_graph_edge_num : 7.87333333333\n",
      "min_graph_edge_num : 0\n",
      "max_graph_edge_num : 9\n",
      "ave_graph_degree : 3.36\n",
      "min_graph_degree : 0\n",
      "max_graph_degree : 4\n",
      "node_label_num : 2\n",
      "edge_label_num : 1\n",
      "node_attr_dim : False\n",
      "edge_attr_dim : False\n",
      "class_number : 123\n",
      "\n",
      "\n",
      "Acyclic:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 183\n",
      "ave_graph_size : 8.15300546448\n",
      "min_graph_size : 3\n",
      "max_graph_size : 11\n",
      "ave_graph_edge_num : 7.15300546448\n",
      "min_graph_edge_num : 2\n",
      "max_graph_edge_num : 10\n",
      "ave_graph_degree : 2.80327868852\n",
      "min_graph_degree : 2\n",
      "max_graph_degree : 4\n",
      "node_label_num : 3\n",
      "edge_label_num : 1\n",
      "node_attr_dim : False\n",
      "edge_attr_dim : False\n",
      "class_number : 148\n",
      "\n",
      "\n",
      "MAO:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : True\n",
      "is_directed : False\n",
      "dataset_size : 68\n",
      "ave_graph_size : 18.3823529412\n",
      "min_graph_size : 11\n",
      "max_graph_size : 27\n",
      "ave_graph_edge_num : 19.6323529412\n",
      "min_graph_edge_num : 12\n",
      "max_graph_edge_num : 29\n",
      "ave_graph_degree : 3.0\n",
      "min_graph_degree : 3\n",
      "max_graph_degree : 3\n",
      "node_label_num : 3\n",
      "edge_label_num : 4\n",
      "node_attr_dim : False\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n",
      "\n",
      "PAH:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : False\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 94\n",
      "ave_graph_size : 20.7021276596\n",
      "min_graph_size : 10\n",
      "max_graph_size : 28\n",
      "ave_graph_edge_num : 24.4255319149\n",
      "min_graph_edge_num : 11\n",
      "max_graph_edge_num : 34\n",
      "ave_graph_degree : 3.01063829787\n",
      "min_graph_degree : 3\n",
      "max_graph_degree : 4\n",
      "node_label_num : 1\n",
      "edge_label_num : 1\n",
      "node_attr_dim : False\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n",
      "\n",
      "NCI1:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 4110\n",
      "ave_graph_size : 29.8654501217\n",
      "min_graph_size : 3\n",
      "max_graph_size : 111\n",
      "ave_graph_edge_num : 32.3\n",
      "min_graph_edge_num : 2\n",
      "max_graph_edge_num : 119\n",
      "ave_graph_degree : 3.33600973236\n",
      "min_graph_degree : 2\n",
      "max_graph_degree : 4\n",
      "node_label_num : 37\n",
      "edge_label_num : 0\n",
      "node_attr_dim : False\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "NCI109:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : False\n",
      "is_directed : False\n",
      "dataset_size : 4127\n",
      "ave_graph_size : 29.6811243034\n",
      "min_graph_size : 4\n",
      "max_graph_size : 111\n",
      "ave_graph_edge_num : 32.1308456506\n",
      "min_graph_edge_num : 3\n",
      "max_graph_edge_num : 119\n",
      "ave_graph_degree : 3.34383329295\n",
      "min_graph_degree : 2\n",
      "max_graph_degree : 5\n",
      "node_label_num : 38\n",
      "edge_label_num : 0\n",
      "node_attr_dim : False\n",
      "edge_attr_dim : False\n",
      "class_number : 2\n",
      "\n",
      "load SDF: 100%|██████████| 4457424/4457424 [00:11<00:00, 397248.47it/s]\n",
      "ajust data: 100%|██████████| 42687/42687 [00:10<00:00, 3939.72it/s] \n",
      "\n",
      "NCI-HIV:\n",
      "substructures : {'non linear', 'linear'}\n",
      "node_labeled : True\n",
      "edge_labeled : True\n",
      "is_directed : False\n",
      "dataset_size : 42682\n",
      "ave_graph_size : 45.7094559768\n",
      "min_graph_size : 2\n",
      "max_graph_size : 438\n",
      "ave_graph_edge_num : 47.7137903566\n",
      "min_graph_edge_num : 1\n",
      "max_graph_edge_num : 441\n",
      "ave_graph_degree : 3.97605548006\n",
      "min_graph_degree : 1\n",
      "max_graph_degree : 12\n",
      "node_label_num : 63\n",
      "edge_label_num : 3\n",
      "node_attr_dim : False\n",
      "edge_attr_dim : False\n",
      "class_number : 3\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "sys.path.insert(0, \"../\")\n",
    "from pygraph.utils.graphfiles import loadDataset\n",
    "from pygraph.utils.graphdataset import get_dataset_attributes\n",
    "\n",
    "dslist = [\n",
    "    {'name': 'Mutagenicity', 'dataset': '../datasets/Mutagenicity/Mutagenicity_A.txt'},\n",
    "    {'name': 'AIDS', 'dataset': '../datasets/AIDS/AIDS_A.txt'},\n",
    "    {'name': 'FIRSTMM_DB', 'dataset': '../datasets/FIRSTMM_DB/FIRSTMM_DB_A.txt'},\n",
    "    {'name': 'MSRC9', 'dataset': '../datasets/MSRC_9_txt/MSRC_9_A.txt'},\n",
    "    {'name': 'MSRC21', 'dataset': '../datasets/MSRC_21_txt/MSRC_21_A.txt'},\n",
    "    {'name': 'SYNTHETIC', 'dataset': '../datasets/SYNTHETIC_txt/SYNTHETIC_A_sparse.txt'},\n",
    "    {'name': 'BZR', 'dataset': '../datasets/BZR_txt/BZR_A_sparse.txt'},\n",
    "    {'name': 'COX2', 'dataset': '../datasets/COX2_txt/COX2_A_sparse.txt'},\n",
    "    {'name': 'DHFR', 'dataset': '../datasets/DHFR_txt/DHFR_A_sparse.txt'},\n",
    "    {'name': 'ENZYMES', 'dataset': '../datasets/ENZYMES_txt/ENZYMES_A_sparse.txt'},\n",
    "    {'name': 'PROTEINS', 'dataset': '../datasets/PROTEINS_txt/PROTEINS_A_sparse.txt'},\n",
    "    {'name': 'PROTEINS_full', 'dataset': '../datasets/PROTEINS_full_txt/PROTEINS_full_A_sparse.txt'},\n",
    "    {'name': 'D&D', 'dataset': '../datasets/D&D/DD.mat',\n",
    "     'extra_params': {'am_sp_al_nl_el': [0, 1, 2, 1, -1]}},\n",
    "    {'name': 'MUTAG', 'dataset': '../datasets/MUTAG/MUTAG.mat',\n",
    "        'extra_params': {'am_sp_al_nl_el': [0, 0, 3, 1, 2]}},\n",
    "    {'name': 'Alkane', 'dataset': '../datasets/Alkane/dataset.ds',\n",
    "        'dataset_y': '../datasets/Alkane/dataset_boiling_point_names.txt',},\n",
    "    {'name': 'Acyclic', 'dataset': '../datasets/acyclic/dataset_bps.ds',},\n",
    "    {'name': 'MAO', 'dataset': '../datasets/MAO/dataset.ds',},\n",
    "    {'name': 'PAH', 'dataset': '../datasets/PAH/dataset.ds',},\n",
    "    {'name': 'NCI1', 'dataset': '../datasets/NCI1/NCI1.mat',\n",
    "        'extra_params': {'am_sp_al_nl_el': [1, 1, 2, 0, -1]}},\n",
    "    {'name': 'NCI109', 'dataset': '../datasets/NCI109/NCI109.mat',\n",
    "        'extra_params': {'am_sp_al_nl_el': [1, 1, 2, 0, -1]}},\n",
    "    {'name': 'NCI-HIV', 'dataset': '../datasets/NCI-HIV/AIDO99SD.sdf',\n",
    "        'dataset_y': '../datasets/NCI-HIV/aids_conc_may04.txt',},\n",
    "\n",
    "#     # not working below\n",
    "#     {'name': 'PTC_FM', 'dataset': '../datasets/PTC/Train/FM.ds',},\n",
    "#     {'name': 'PTC_FR', 'dataset': '../datasets/PTC/Train/FR.ds',},\n",
    "#     {'name': 'PTC_MM', 'dataset': '../datasets/PTC/Train/MM.ds',},\n",
    "#     {'name': 'PTC_MR', 'dataset': '../datasets/PTC/Train/MR.ds',},\n",
    "]\n",
    "\n",
    "for ds in dslist:\n",
    "    dataset, y = loadDataset(\n",
    "        ds['dataset'],\n",
    "        filename_y=(ds['dataset_y'] if 'dataset_y' in ds else None),\n",
    "        extra_params=(ds['extra_params'] if 'extra_params' in ds else None))\n",
    "    attrs = get_dataset_attributes(\n",
    "        dataset, target=y, node_label='atom', edge_label='bond_type')\n",
    "    print()\n",
    "    print(ds['name'] + ':')\n",
    "    for atr in attrs:\n",
    "        print(atr, ':', attrs[atr])\n",
    "    print()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
