import pandas as pd
import numpy as np
import re
import time, copy
import random
import torch
import networkx as nx
from sklearn.model_selection import StratifiedShuffleSplit
#try:
#  from torch_geometric.data import Data, DataLoader
#except ImportError:
#    raise ImportError('<torch_geometric missing; cannot do deep learning>')

lib = ['', '1,4-Anhydro-Gal', '1,4-Anhydro-Kdo', '1-1', '1-2', '1-3', '1-4', '1-5', '1-6', '1dAlt-ol', '1dEry-ol', '2,3-Anhydro-All', '2,3-Anhydro-Man', '2,3-Anhydro-Rib', '2,5-Anhydro-D-Alt', '2,5-Anhydro-D-AltOS', '2,5-Anhydro-L-Man', '2,5-Anhydro-Man', '2,5-Anhydro-Man-ol', '2,5-Anhydro-ManOS', '2,5-Anhydro-Tal-ol', '2,5-Anhydro-TalOP', '2,7-Anhydro-Kdo', '2,7-Anhydro-Kdof', '2-4', '2-5', '2-6', '3', '3,6-Anhydro-Fruf', '3,6-Anhydro-Gal', '3,6-Anhydro-GalOS', '3,6-Anhydro-Glc', '3,6-Anhydro-L-Gal', '3,6-Anhydro-L-GalOMe', '3-3', '3-5', '3-6', '3dLyxHepUlosaric', '4', '4,7-Anhydro-KdoOPEtn', '4,8-Anhydro-DDGlcOct', '4,8-Anhydro-Kdo', '4,8-Anhydro-LDGlcOct', '4-5', '4dAraHex', '4dEry-ol', '4eLegNAcNAc', '5-2', '5-3', '5-5', '5-6', '6dAlt', '6dAltNAc', '6dAltOAc', '6dAltf', '6dAltfOAc', '6dGul', '6dManHep', '6dTal', '6dTalNAc', '6dTalNAcOAc', '6dTalOAc', '6dTalOAcOAc', '6dTalOAcOMe', '6dTalOMe', '6dTalOMe-ol', '6dTalf', '8eAciNAcNAc', '8eLeg', '8eLegNAc', '8eLegNAcNAc', '8eLegNAcNAcGro', '8eLegNAcNBut', 'Abe', 'AbeOAc', 'AcefA', 'AciNAcNAc', 'Aco', 'AcoNAc', 'AllN', 'AllOAc', 'AllOMe', 'Alt', 'AltA', 'AltAN', 'AltNAcA', 'AltOMeA', 'Altf', 'AltfOAc', 'Ami', 'ApiOAc', 'ApiOMe-ol', 'Apif', 'Ara', 'Ara-ol', 'AraHepUloNAc-onic', 'AraHepUloNAcN-onic', 'AraHepUloNGc-onic', 'AraHexA', 'AraN', 'AraNMeOMe', 'AraOAc', 'AraOAcOP-ol', 'AraOMe', 'AraOPN', 'Araf', 'ArafGro', 'ArafOCoum', 'ArafOFer', 'ArafOMe', 'ArafOS', 'Asc', 'Bac', 'BacNAc', 'BoiOMe', 'Col', 'D-2dAraHex', 'D-2dAraHexA', 'D-3dAraHepUlosonic', 'D-3dLyxHepUlosaric', 'D-3dThrHexUlosonic', 'D-3dThrPen', 'D-3dXylHexOMe', 'D-4dAraHex', 'D-4dEryHexOAcN4en', 'D-4dLyxHex', 'D-4dLyxHexOMe', 'D-4dThrHexA4en', 'D-4dThrHexAN4en', 'D-4dThrHexOAcN4en', 'D-4dXylHex', 'D-6dAllOMe', 'D-6dAlt', 'D-6dAltHep', 'D-6dAltHepOMe', 'D-6dAltHepf', 'D-6dAraHex', 'D-6dAraHexN', 'D-6dAraHexNAc', 'D-6dAraHexOMe', 'D-6dLyxHexOMe', 'D-6dManHep', 'D-6dManHepOAc', 'D-6dManHepOP', 'D-6dTal', 'D-6dTalHep', 'D-6dTalOAc', 'D-6dTalOAcOMe', 'D-6dTalOMe', 'D-6dXylHex', 'D-6dXylHexN4Ulo', 'D-6dXylHexNAc4Ulo', 'D-6dXylHexOMe', 'D-7dLyxOctUlosonic', 'D-9dThrAltNon-onic', 'D-Alt', 'D-Apif', 'D-ApifOAc', 'D-ApifOMe', 'D-Ara', 'D-Ara-ol', 'D-AraHepUlo-onic', 'D-AraHex', 'D-AraHexUloOMe', 'D-AraN', 'D-AraOS', 'D-Araf', 'D-ArafN', 'D-Fuc', 'D-Fuc-ol', 'D-FucN', 'D-FucNAc', 'D-FucNAc-ol', 'D-FucNAcN', 'D-FucNAcNMe', 'D-FucNAcNMeN', 'D-FucNAcOAc', 'D-FucNAcOMe', 'D-FucNAcOP', 'D-FucNAcOPEtn', 'D-FucNAlaAc', 'D-FucNAsp', 'D-FucNBut', 'D-FucNButGro', 'D-FucNFo', 'D-FucNLac', 'D-FucNMeN', 'D-FucNN', 'D-FucNThrAc', 'D-FucOAc', 'D-FucOAcN', 'D-FucOAcNBut', 'D-FucOAcNGroA', 'D-FucOAcOBut', 'D-FucOAcOMe', 'D-FucOBut', 'D-FucOEtn', 'D-FucOMe', 'D-FucOMeN', 'D-FucOMeOCoum', 'D-FucOMeOFer', 'D-FucOMeOSin', 'D-FucOS', 'D-Fucf', 'D-FucfNAc', 'D-FucfOAc', 'D-Ido', 'D-IdoA', 'D-IdoOSA', 'D-Rha', 'D-Rha-ol', 'D-RhaCMe', 'D-RhaGro', 'D-RhaN', 'D-RhaNAc', 'D-RhaNAcOAc', 'D-RhaNBut', 'D-RhaNButOMe', 'D-RhaNFo', 'D-RhaOFoN', 'D-RhaOMe', 'D-RhaOMeN', 'D-RhaOP', 'D-RhaOS', 'D-RibHex', 'D-RibHexNAc', 'D-Sor', 'D-ThrHexA4en', 'D-ThrHexAN4en', 'D-ThrHexfNAc2en', 'D-ThrPen', 'D-Thre-ol', 'DDAltHep', 'DDAltHepOMe', 'DDGalHep', 'DDGalHepOMe', 'DDGlcHep', 'DDManHep', 'DDManHepOBut', 'DDManHepOEtn', 'DDManHepOMe', 'DDManHepOP', 'DDManHepOPEtn', 'DDManHepOPGroA', 'DDManNonUloNAcOFoN-onic', 'DLAltNonUloNAc-onic', 'DLGalNonUloNAc-onic', 'DLGalNonUloNAcN', 'DLGalNonUloNAcN-onic', 'DLGlcHepOMe', 'DLHepGlcOMe', 'DLManHep', 'DLManHepOPEtn', 'Dha', 'Dig', 'DigCMe', 'DigOAc', 'DigOFo', 'DigOMe', 'Ery', 'Ery-L-GlcNonUloNAcOAcOMeSH-onic', 'Ery-ol', 'Ery-onic', 'EryHex', 'EryHex2en', 'EryHexA3en', 'EryOMe-onic', 'Fru', 'Fruf', 'FrufF', 'FrufI', 'FrufN', 'FrufNAc', 'FrufOAc', 'FrufOAcOBzOCoum', 'FrufOAcOFer', 'FrufOBzOCin', 'FrufOBzOCoum', 'FrufOBzOFer', 'FrufOFer', 'FrufOLau', 'Fuc', 'Fuc-ol', 'FucN', 'FucNAc', 'FucNAcA', 'FucNAcN', 'FucNAcNMe', 'FucNAcOAc', 'FucNAcOMe', 'FucNAcOPGro', 'FucNAla', 'FucNAm', 'FucNBut', 'FucNFo', 'FucNProp', 'FucNThrAc', 'FucOAc', 'FucOAcNAm', 'FucOAcNBut', 'FucOAcOMe', 'FucOAcOSOMe', 'FucOMe', 'FucOMeOPam', 'FucOMeOVac', 'FucOP', 'FucOPOMe', 'FucOS', 'FucOSOMe', 'Fucf', 'Gal', 'Gal-ol', 'Gal6Ulo', 'GalA', 'GalA-ol', 'GalAAla', 'GalAAlaLys', 'GalAGroN', 'GalALys', 'GalAN', 'GalANCys', 'GalANCysAc', 'GalANSerAc', 'GalAOLac', 'GalAOPyr', 'GalASer', 'GalAThr', 'GalAThrAc', 'GalCl', 'GalF', 'GalGro', 'GalGroN', 'GalN', 'GalNAc', 'GalNAc-ol', 'GalNAc-onic', 'GalNAcA', 'GalNAcAAla', 'GalNAcAN', 'GalNAcASer', 'GalNAcGro', 'GalNAcN', 'GalNAcOAc', 'GalNAcOAcA', 'GalNAcOAcAN', 'GalNAcOAcOMeA', 'GalNAcOAcOP', 'GalNAcOAcOPGro', 'GalNAcOMe', 'GalNAcOP', 'GalNAcOPCho', 'GalNAcOPEtn', 'GalNAcOPGro', 'GalNAcOPGroAN', 'GalNAcOPyr', 'GalNAcOS', 'GalNAla', 'GalNAmA', 'GalNCysGly', 'GalNFoA', 'GalNFoAN', 'GalNOPCho', 'GalNSuc', 'GalNonUloNAc-onic', 'GalOAc', 'GalOAcA', 'GalOAcAGroN', 'GalOAcAOLac', 'GalOAcAThr', 'GalOAcN', 'GalOAcNAla', 'GalOAcNAmA', 'GalOAcNFoA', 'GalOAcNFoAN', 'GalOAcOFoA', 'GalOAcOMe', 'GalOAcOP', 'GalOAcOPGro', 'GalOAcOPyr', 'GalOFoAN', 'GalOFoNAN', 'GalOLac', 'GalOLac-ol', 'GalOMe', 'GalOMeA', 'GalOMeCl', 'GalOMeF', 'GalOMeNAla', 'GalOP', 'GalOPA', 'GalOPAEtn', 'GalOPAN', 'GalOPCho', 'GalOPEtn', 'GalOPEtnA', 'GalOPEtnN', 'GalOPGro', 'GalOPy', 'GalOPyr', 'GalOS', 'GalOSA', 'GalOSOEt', 'GalOSOMeA', 'GalOctUloNAc-onic', 'Galf', 'GalfGro', 'GalfNAc', 'GalfOAc', 'GalfOAcGro', 'GalfOAcOLac', 'GalfOAcOPGro', 'GalfOLac', 'GalfOMe', 'GalfOP', 'GalfOPCho', 'GalfOPGro', 'GalfOPyr', 'Gl', 'Glc', 'Glc-ol', 'Glc6Ulo', 'GlcA', 'GlcAAla', 'GlcAAlaLys', 'GlcAGlu', 'GlcAGly', 'GlcAGro', 'GlcAGroN', 'GlcALys', 'GlcAN', 'GlcAOLac', 'GlcAOPy', 'GlcAOPyr', 'GlcASer', 'GlcAThr', 'GlcAThrAc', 'GlcCho', 'GlcF', 'GlcGro', 'GlcGroA', 'GlcI', 'GlcN', 'GlcN-ol', 'GlcNAc', 'GlcNAc-ol', 'GlcNAcA', 'GlcNAcAAla', 'GlcNAcAN', 'GlcNAcANAla', 'GlcNAcANAlaAc', 'GlcNAcANAlaFo', 'GlcNAcAla', 'GlcNAcCl', 'GlcNAcGlu', 'GlcNAcGly', 'GlcNAcGro', 'GlcNAcI', 'GlcNAcN', 'GlcNAcN-ol', 'GlcNAcNAla', 'GlcNAcNAlaFo', 'GlcNAcNAmA', 'GlcNAcNButA', 'GlcNAcOAc', 'GlcNAcOAcA', 'GlcNAcOAcN', 'GlcNAcOAcNAla', 'GlcNAcOAcOCmOOle', 'GlcNAcOAcOCmOPam', 'GlcNAcOAcOCmOVac', 'GlcNAcOAcOLac', 'GlcNAcOAcOOle', 'GlcNAcOAcOPam', 'GlcNAcOAcOPyr', 'GlcNAcOAcOS-ol', 'GlcNAcOAcOVac', 'GlcNAcOGc', 'GlcNAcOLac', 'GlcNAcOLacAla', 'GlcNAcOLacGro', 'GlcNAcOMe', 'GlcNAcOMeA', 'GlcNAcOP', 'GlcNAcOPCho', 'GlcNAcOPEtg', 'GlcNAcOPEtn', 'GlcNAcOPGro', 'GlcNAcOPGroA', 'GlcNAcOPOAch', 'GlcNAcOPyr', 'GlcNAcOS', 'GlcNAcOS-ol', 'GlcNAcOSA', 'GlcNAm', 'GlcNAmA', 'GlcNBut', 'GlcNButAN', 'GlcNButOAc', 'GlcNCmOCm', 'GlcNCmOCmOOle', 'GlcNCmOCmOVac', 'GlcNCmOVac', 'GlcNGc', 'GlcNGly', 'GlcNMe', 'GlcNMeOCm', 'GlcNMeOCmOPam', 'GlcNMeOCmOSte', 'GlcNMeOCmOVac', 'GlcNMeOSte', 'GlcNMeOVac', 'GlcNN', 'GlcNOAep', 'GlcNOCmOAch', 'GlcNOCmOVac', 'GlcNOMar', 'GlcNOMe', 'GlcNOMyr', 'GlcNOOle', 'GlcNOPam', 'GlcNOPyr', 'GlcNOSte', 'GlcNOVac', 'GlcNS', 'GlcNSOS', 'GlcNSOSOMe', 'GlcNSuc', 'GlcOAc', 'GlcOAcA', 'GlcOAcGro', 'GlcOAcGroA', 'GlcOAcN', 'GlcOAcNBut', 'GlcOAcNCmOOle', 'GlcOAcNCmOPam', 'GlcOAcNCmOVac', 'GlcOAcNMeOCm', 'GlcOAcNMeOCmOVac', 'GlcOAcNMeOVac', 'GlcOAcNOCmOVac', 'GlcOAcNOOle', 'GlcOAcNOPam', 'GlcOAcNOVac', 'GlcOAcOCoum', 'GlcOAcOFer', 'GlcOAcOOle', 'GlcOAcOP', 'GlcOAcOPGro', 'GlcOAcOPam', 'GlcOAcOS', 'GlcOAcOSA', 'GlcOAcOSte', 'GlcOButA', 'GlcOBz', 'GlcOCoum', 'GlcOEt', 'GlcOEtn', 'GlcOEtnA', 'GlcOEtnN', 'GlcOFer', 'GlcOFoN', 'GlcOGc', 'GlcOLac', 'GlcOMal', 'GlcOMe', 'GlcOMe-ol', 'GlcOMeA', 'GlcOMeAN', 'GlcOMeN', 'GlcOMeNOMyr', 'GlcOMeOFoA', 'GlcOMeOPyr', 'GlcOOle', 'GlcOP', 'GlcOP-ol', 'GlcOPA', 'GlcOPCho', 'GlcOPChoGro', 'GlcOPEtn', 'GlcOPEtnGro', 'GlcOPEtnN', 'GlcOPGro', 'GlcOPGroA', 'GlcOPN', 'GlcOPNOMyr', 'GlcOPNOPam', 'GlcOPOOle', 'GlcOPOPGro', 'GlcOPPEtn', 'GlcOPPEtnN', 'GlcOPam', 'GlcOPyr', 'GlcOS', 'GlcOSA', 'GlcOSN', 'GlcOSNMeOCm', 'GlcOSOEt', 'GlcOSOMe', 'GlcOSOMeA', 'GlcOSin', 'GlcS', 'GlcSH', 'GlcThr', 'Glcf', 'Gro', 'Gro-ol', 'Gul', 'GulAN', 'GulNAcA', 'GulNAcAN', 'GulNAcNAmA', 'GulNAcOAcA', 'Hep', 'HepOP', 'HepOPEtn', 'HepOPPEtn', 'Hex', 'HexA', 'HexN', 'HexNAc', 'HexOMeOFo', 'Hexf', 'Ido', 'IdoA', 'IdoN', 'IdoNAc', 'IdoOAcA', 'IdoOAcOSA', 'IdoOMeA', 'IdoOS', 'IdoOSA', 'IdoOSOEtA', 'IdoOSOMeA', 'Kdn', 'KdnOAc', 'KdnOMe', 'KdnOPyr', 'Kdo', 'Kdo-ol', 'KdoN', 'KdoOAc', 'KdoOAcOS', 'KdoOMe', 'KdoOP', 'KdoOPEtn', 'KdoOPGro', 'KdoOPN', 'KdoOPOEtn', 'KdoOPOPEtn', 'KdoOPPEtn', 'KdoOPPEtnN', 'KdoOPyr', 'KdoOS', 'Kdof', 'Ko', 'KoOMe', 'KoOPEtn', 'L-4dEryHexAN4en', 'L-4dThrHex4en', 'L-4dThrHexA4en', 'L-4dThrHexA4enAla', 'L-4dThrHexAN4en', 'L-4dThre-ol', 'L-6dAraHex', 'L-6dAraHexOMe', 'L-6dGalHep', 'L-6dGalHepOP', 'L-6dGulHep', 'L-6dGulHepOMe', 'L-6dGulHepOP', 'L-6dXylHexNAc4Ulo', 'L-Aco', 'L-AcoOMe', 'L-AcoOMeOFo', 'L-BoiOMe', 'L-Cym', 'L-CymOAc', 'L-DigOMe', 'L-Ery', 'L-EryCMeOH', 'L-EryHexA4en', 'L-Fru', 'L-Fruf', 'L-Gal', 'L-GalAN', 'L-GalNAc', 'L-GalNAc-onic', 'L-GalNAcA', 'L-GalNAcAN', 'L-GalNAcOAcA', 'L-GalNAmA', 'L-GalOAcNAmA', 'L-GalOS', 'L-Glc', 'L-GlcA', 'L-GlcNAc', 'L-GlcOMe', 'L-Gro-onic', 'L-GroHexUlo', 'L-Gul', 'L-Gul-onic', 'L-GulA', 'L-GulAN', 'L-GulHep', 'L-GulNAc', 'L-GulNAcA', 'L-GulNAcAGly', 'L-GulNAcAN', 'L-GulNAcANEtn', 'L-GulNAcNAmA', 'L-GulNAcNEtnA', 'L-GulNAcOAc', 'L-GulNAcOAcA', 'L-GulNAcOAcAN', 'L-GulNAcOEtA', 'L-GulNAcOEtnA', 'L-GulOAcA', 'L-Lyx', 'L-LyxHex', 'L-LyxHexNMe', 'L-LyxHexOMe', 'L-Man', 'L-ManOMe', 'L-ManOctUlo-onic', 'L-Ole', 'L-OleOAc', 'L-Oli', 'L-OliOMe', 'L-Qui', 'L-QuiN', 'L-QuiNAc', 'L-QuiNAcOMe', 'L-QuiNAcOP', 'L-QuiOMeN', 'L-RibHex', 'L-Ribf', 'L-Tal', 'L-The', 'L-TheOAc', 'L-Thr', 'L-ThrHexA4en', 'L-ThrHexAN4en', 'L-ThrHexOMe4en', 'L-ThrHexOMeA4en', 'L-ThrHexOSA4en', 'L-Xyl', 'L-XylHex', 'L-XylOMe', 'LDGalHep', 'LDGalNonUloNAc-onic', 'LDGlcHep', 'LDIdoHep', 'LDIdoHepPro', 'LDManHep', 'LDManHepGroN', 'LDManHepOAc', 'LDManHepOCm', 'LDManHepOEtn', 'LDManHepOMe', 'LDManHepOP', 'LDManHepOPEtn', 'LDManHepOPEtnOEtn', 'LDManHepOPGroA', 'LDManHepOPOCm', 'LDManHepOPOMe', 'LDManHepOPOPEtn', 'LDManHepOPOPPEtn', 'LDManHepOPPEtn', 'LDManHepOPPEtnOPyrP', 'LDManHepOPyrP', 'LDManNonUloNAcOFoN-onic', 'LDManNonUloOFoNN-onic', 'LLManNonUloOFoN-onic', 'Leg', 'LegNAc', 'LegNAcAla', 'LegNAcNAc', 'LegNAcNAla', 'LegNAcNAm', 'LegNAcNBut', 'LegNFo', 'Lyx', 'LyxHex', 'LyxHexOMe', 'LyxOMe', 'LyxOctUlo-onic', 'Lyxf', 'M', 'Man', 'Man-ol', 'ManA', 'ManCMe', 'ManF', 'ManN', 'ManNAc', 'ManNAcA', 'ManNAcAAla', 'ManNAcAGro', 'ManNAcAN', 'ManNAcANOOrn', 'ManNAcASer', 'ManNAcAThr', 'ManNAcGroA', 'ManNAcNAmA', 'ManNAcNEtnA', 'ManNAcOAc', 'ManNAcOAcA', 'ManNAcOLac', 'ManNAcOMe', 'ManNAcOMeAN', 'ManNAcOPEtn', 'ManNAcOPGro', 'ManNAcOPGroA', 'ManNAcOPyr', 'ManNBut', 'ManNOPGro', 'ManNonUloNAc-onic', 'ManOAc', 'ManOAcA', 'ManOAcN', 'ManOAcOMe', 'ManOAcOPyr', 'ManOAep', 'ManOBut', 'ManOEtn', 'ManOLac', 'ManOMe', 'ManOMeA', 'ManOP', 'ManOP-ol', 'ManOPCho', 'ManOPEtn', 'ManOPGro', 'ManOPOMe', 'ManOPOPyr-ol', 'ManOPy', 'ManOPyr', 'ManOS', 'ManOctUlo', 'ManSH', 'Manf', 'Mur', 'MurNAc', 'MurNAcAla', 'MurNAcOP', 'MurNAcSer', 'Neu', 'NeuNAc', 'NeuNAcN', 'NeuNAcNAc', 'NeuNAcNMe', 'NeuNAcOAc', 'NeuNAcOAcOMe', 'NeuNAcOGc', 'NeuNAcOMe', 'NeuNAcOS', 'NeuNGc', 'NeuNGcA', 'NeuNGcN', 'NeuNGcOMe', 'NeuNGcOS', 'NeuOFo', 'NeuOMe', 'OLac', 'Ole', 'Oli', 'OliN', 'OliNAc', 'OliOMe', 'Par', 'Parf', 'PerNAc', 'Pse', 'PseNAc', 'PseNAcNAc', 'PseNAcNAcNBut', 'PseNAcNAcOBut', 'PseNAcNAm', 'PseNAcNBut', 'PseNAcNFo', 'PseNAcNGro', 'PseNAcOAcNBut', 'PseNAcOBut', 'PseNButNFo', 'PseNGcNAm', 'PseOAc', 'PseOAcOFo', 'PseOFo', 'Qui', 'QuiN', 'QuiNAc', 'QuiNAc-ol', 'QuiNAcGro', 'QuiNAcN', 'QuiNAcNAlaAc', 'QuiNAcNAm', 'QuiNAcNAspAc', 'QuiNAcNBut', 'QuiNAcNButGro', 'QuiNAcNGroA', 'QuiNAcOAc', 'QuiNAcOBut', 'QuiNAcOMe', 'QuiNAcOP', 'QuiNAcOPGro', 'QuiNAla', 'QuiNAlaAc', 'QuiNAlaAcGro', 'QuiNAlaBut', 'QuiNAlaButGro', 'QuiNAspAc', 'QuiNBut', 'QuiNButAla', 'QuiNButOMe', 'QuiNFo', 'QuiNGlyAc', 'QuiNHse', 'QuiNHseGro', 'QuiNLac', 'QuiNMal', 'QuiNSerAc', 'QuiNThrAc', 'QuiOMe', 'QuiOMeN', 'QuiOS', 'QuiOSN', 'QuiOSNBut', 'Rha', 'Rha-ol', 'RhaCMe', 'RhaCl', 'RhaGro', 'RhaGroA', 'RhaNAc', 'RhaNAcNBut', 'RhaNAcNFo', 'RhaNAcOAc', 'RhaNPro', 'RhaOAc', 'RhaOAcOLac', 'RhaOAcOMe', 'RhaOBut', 'RhaOFer', 'RhaOLac', 'RhaOMe', 'RhaOMeCMeNLac', 'RhaOMeCMeOFo', 'RhaOP', 'RhaOPEtn', 'RhaOPGro', 'RhaOPOMe', 'RhaOProp', 'RhaOPyr', 'RhaOS', 'Rhaf', 'Rib', 'Rib-ol', 'RibOAc', 'RibOAcOP-ol', 'RibOP-ol', 'RibOPEtn-ol', 'RibOPGro-ol', 'RibOPOPGro-ol', 'Ribf', 'Ribf-uronic', 'RibfOAc', 'Sed', 'Sedf', 'Sor', 'Sorf', 'Suc', 'Sug', 'SugOAc', 'Tag', 'Tal', 'The', 'Thr', 'Thre-ol', 'Thre-onic', 'Tyv', 'VioNAc', 'Xluf', 'XlufOMe', 'Xyl', 'Xyl-ol', 'Xyl-onic', 'XylHex', 'XylHexNAc', 'XylHexUlo', 'XylHexUloN', 'XylHexUloNAc', 'XylNAc', 'XylNMe', 'XylOAc', 'XylOBz', 'XylOMe', 'XylOP', 'XylOS', 'Xylf', 'Yer', 'YerOAc', 'a-Tri-ol', 'a-Tri-onic', 'a1-1', 'a1-2', 'a1-3', 'a1-4', 'a1-5', 'a1-6', 'a1-7', 'a1-8', 'a2-1', 'a2-2', 'a2-3', 'a2-4', 'a2-5', 'a2-6', 'a2-7', 'a2-8', 'a2-9', 'a6-6', 'aldehyde-2,5-Anhydro-L-Man', 'aldehyde-2,5-Anhydro-Tal', 'aldehyde-Gro', 'aldehyde-Hex', 'aldehyde-L-Gro', 'aldehyde-L-GroN', 'aldehyde-QuiNAc', 'aldehyde-Rib', 'aldehyde-a-Tri-ol', 'aldehyde-b-Tri-ol', 'b-Tri-N-ol', 'b-Tri-OP-ol', 'b-Tri-ol', 'b-Tri-onic', 'b1-1', 'b1-2', 'b1-3', 'b1-3FucNAc', 'b1-4', 'b1-4Glc', 'b1-5', 'b1-6', 'b1-7', 'b1-8', 'b1-9', 'b2-1', 'b2-2', 'b2-3', 'b2-4', 'b2-5', 'b2-6', 'b2-7', 'b2-8', 'b3-3', 'cNeuNAc']

def get_namespace():
  """returns list of function names in this package"""
  return ['unwrap, find_nth, small_motif_find, min_process_glycans, motif_find, \
process_glycans, character_to_label, string_to_labels, pad_sequence, get_lib, \
glycan_to_graph, dataset_to_graphs, hierarchy_filter, compare_glycans, subgraph_isomorphism, \
glycan_to_nxGraph, seed_wildcard, seed_wildcard_hierarchy']







def seed_wildcard(df_in, wildcard_list, wildcard_name, r = 0.1, col = 'target'):
  """adds dataframe rows in which glycan parts have been replaced with the appropriate wildcards
  df_in -- dataframe in which the glycan column is called "target" and is the first column
  wildcard_list -- list which glycoletters a wildcard encompasses
  wildcard_name -- how the wildcard should be named in the IUPACcondensed nomenclature
  r -- rate of replacement, default is 0.1 or 10%"""
  added_rows = []
  for k in range(len(df_in)):
    temp = df_in[col].values.tolist()[k]
    for j in wildcard_list:
      if j in temp:
        if random.uniform(0, 1) < r:
          added_rows.append([temp.replace(j, wildcard_name)] + df_in.iloc[k, 1:].values.tolist())
  added_rows = pd.DataFrame(added_rows, columns = df_in.columns.values.tolist())
  df_out = pd.concat([df_in, added_rows], axis = 0, ignore_index = True)
  return df_out













