<commit_before>//var test_string = "(((5HT1D:0.14656,5HT1B:0.18681):0.08093,(5HT1F:0.18620,5HT1E:0.20912):0.12352):0.09868,(5HT5A:0.61709,(5HT7R:0.48940,((DRD1:0.13081,DRD5:0.11617):0.37543,((((DRD2:0.15236,DRD3:0.18945):0.24327,DRD4:0.48536):0.05986,((ADA2A:0.13115,ADA2C:0.18228):0.01936,ADA2B:0.15621):0.42124):0.05763,(((ADRB2:0.25547,ADRB1:0.19778):0.08565,ADRB3:0.34080):0.26142,(((ADA1A:0.17733,ADA1B:0.14958):0.02087,ADA1D:0.20860):0.31132,((HRH2:0.52426,(5HT4R:0.52452,((TAAR1:0.26729,(TAAR2:0.22284,TAAR3:0.31017):0.23539):0.22600,(((TAAR6:0.08400,TAAR8:0.19222):0.07454,TAAR9:0.21355):0.22951,TAAR5:0.47985):0.02793):0.23241):0.04297):0.05334,((((5HT2A:0.17106,5HT2C:0.16504):0.04954,5HT2B:0.25906):0.41256,(5HT6R:0.69434,GP119:1.09071):0.07887):0.04207,(((((ACM2:0.10343,ACM4:0.08889):0.11475,((ACM3:0.11552,ACM1:0.18469):0.01030,ACM5:0.09545):0.11701):0.40955,HRH1:0.66818):0.06411,(HRH4:0.47944,HRH3:0.32974):0.35975):0.14632,((((AA1R:0.28657,AA3R:0.32509):0.15582,(AA2AR:0.22538,AA2BR:0.20286):0.13983):0.45766,((((MSHR:0.38244,((MC3R:0.16962,MC5R:0.21034):0.04580,MC4R:0.17196):0.09610):0.10745,ACTHR:0.44663):0.33195,((GPR6:0.26054,GPR12:0.27634):0.00641,GPR3:0.19274):0.56708):0.06336,(((S1PR1:0.27466,(S1PR2:0.39143,(S1PR3:0.36509,(S1PR5:0.36473,S1PR4:0.55222):0.02790):0.00867):0.16091):0.26558,(LPAR1:0.27356,(LPAR2:0.36350,LPAR3:0.29943):0.02502):0.28322):0.13154,(CNR1:0.35087,CNR2:0.35507):0.62427):0.12276):0.19783):0.04243,(((((GP161:0.88256,GP101:0.81561):0.07534,GP135:0.80381):0.04794,(GPR45:0.26599,GPR63:0.34295):0.52601):0.08401,((MTR1A:0.20256,MTR1B:0.19320):0.15610,MTR1L:0.45969):0.54665):0.04891,(((((OPN4:0.56879,OPN5:0.92903):0.06501,((((OPSG:0.02697,OPSR:0.03342):0.53998,OPSB:0.52647):0.01057,OPSD:0.44439):0.19490,OPN3:0.80151):0.19502):0.18268,((RXFP1:0.21942,RXFP2:0.26012):0.66213,(((TSHR:0.16173,LSHR:0.21867):0.04430,FSHR:0.15058):0.48573,((LGR5:0.24949,LGR6:0.45298):0.09865,LGR4:0.35743):0.99322):0.08326):0.46464):0.07709,(((FFAR4:0.92854,GPR22:1.18891):0.07305,GP176:1.12688):0.05328,((((MRGX4:0.10513,((MRGX1:0.04116,MRGX3:0.12617):0.05361,MRGX2:0.27642):0.04263):0.29790,((MRGRE:0.61765,MRGRG:0.73434):0.25048,MAS1L:0.90053):0.03282):0.06336,(MAS:0.77797,(MRGRD:0.50798,MRGRF:0.77014):0.08596):0.11897):0.69213,((((PE2R2:0.41800,PD2R:0.67895):0.10363,PI2R:0.67801):0.24656,PE2R4:0.72942):0.13337,(((PE2R1:0.58381,PF2R:0.56725):0.05786,TA2R:0.56254):0.20544,PE2R3:0.59249):0.28215):0.56311):0.09818):0.03669):0.05237,((((((GPR61:0.53396,GPR62:0.79568):0.45475,(GPR26:0.35671,GPR78:0.55697):0.67563):0.13541,UR2R:0.90308):0.05448,(((((((RL3R2:0.41574,RL3R1:0.37875):0.33106,(AGTR2:0.55722,AGTR1:0.55967):0.13173):0.05873,(APJ:0.67628,(GPR15:0.58010,GPR25:0.61852):0.18176):0.00778):0.02780,(((((CXCR2:0.05388,CXCR1:0.08153):0.42425,(CXCR5:0.50867,CXCR3:0.45350):0.06213):0.01352,CXCR4:0.56322):0.03272,((((CCR8:0.42058,((((CCR2:0.08743,CCR5:0.10207):0.16440,(CCR3:0.18374,CCR1:0.18158):0.07935):0.02277,CCRL2:0.52166):0.07748,CCR4:0.38947):0.05710):0.05044,CX3C1:0.38371):0.06819,(XCR1:0.54471,ACKR2:0.54304):0.04238):0.08031,(CXCR6:0.50090,((ACKR4:0.46379,(CCR7:0.42440,CCR9:0.38556):0.05089):0.04825,CCR6:0.47437):0.00461):0.12806):0.01989):0.14820,((ACKR3:0.52247,GP182:0.59468):0.23813,GPER1:0.88006):0.01691):0.01708):0.02247,(BKRB2:0.51447,BKRB1:0.56345):0.29484):0.05314,(((((HCAR2:0.05555,HCAR3:0.10376):0.18659,HCAR1:0.35694):0.24507,OXER1:0.47038):0.11069,GPR31:0.61743):0.35707,(((((((GPR35:0.72834,(GPR55:0.66501,FFAR1:0.82706):0.21885):0.07208,LPAR5:0.68476):0.04084,GPR20:0.77307):0.07754,((PAR4:0.57467,(((PAR2:0.52345,PAR1:0.57365):0.02890,PAR3:0.54309):0.04601,P2RY8:0.59538):0.03028):0.12099,(FFAR2:0.42973,(FFAR3:0.00538,GPR42:0.00422):0.37178):0.49994):0.05897):0.01895,(((PSYR:0.57559,(GPR4:0.40370,OGR1:0.39889):0.18363):0.09103,GP132:0.70545):0.24656,(((((LPAR6:0.25135,LPAR4:0.32636):0.28952,(PTAFR:0.67270,(GP174:0.36331,P2Y10:0.36053):0.42764):0.08679):0.09420,(CLTR1:0.52254,CLTR2:0.54393):0.15646):0.01173,GPR17:0.65080):0.04675,(((P2RY1:0.51184,P2Y11:0.83945):0.06289,((P2RY2:0.15600,P2RY4:0.32583):0.25068,P2RY6:0.50242):0.14435):0.09686,(OXGR1:0.62196,SUCR1:0.62748):0.09278):0.13068):0.02514):0.04548):0.02914,GP183:0.77503):0.01692,(((GPR34:0.63511,((GPR87:0.35245,(P2Y14:0.36677,(P2Y12:0.26004,P2Y13:0.40774):0.03744):0.08916):0.20002,GP171:0.69543):0.15216):0.06879,GPR82:1.06732):0.09381,(GPR18:0.89407,GP141:1.71148):0.10901):0.06110):0.09217):0.07603):0.06065,((((LT4R1:0.34230,LT4R2:0.56786):0.20423,GP152:1.16379):0.13340,(((C3AR:0.47649,(C5AR1:0.41334,C5AR2:0.63635):0.17172):0.02610,PD2R2:0.67680):0.03026,((CML1:0.43811,GPR1:0.57985):0.07689,((GPR32:0.71839,((FPR2:0.14255,FPR1:0.18677):0.03982,FPR3:0.22440):0.34075):0.07286,GPR33:0.82218):0.02563):0.02168):0.09214):0.14307,((CCR10:0.51827,ACKR1:1.92511):0.18804,(((GP162:0.40624,GP153:0.80663):1.72843,GPR75:1.26731):0.05945,(GPBAR:1.48202,(GP149:2.44392,GP160:1.72540):0.31634):0.18513):0.09889):0.06230):0.04630):0.04141):0.02581,(((((SSR1:0.17885,SSR4:0.18260):0.11696,((SSR3:0.20393,SSR5:0.23343):0.05093,SSR2:0.28178):0.06928):0.12990,(((OPRK:0.12704,(OPRD:0.15715,OPRM:0.15980):0.04678):0.06932,OPRX:0.26870):0.24080,(NPBW2:0.18687,NPBW1:0.20734):0.44035):0.03465):0.10010,(MCHR1:0.52414,MCHR2:0.65206):0.24588):0.12716,(GALR1:0.44912,((GALR2:0.20275,GALR3:0.25153):0.32957,KISSR:0.71877):0.09052):0.14818):0.06828):0.04164,((((((QRFPR:0.68527,((OX2R:0.10301,OX1R:0.13914):0.48857,(NPFF2:0.21754,NPFF1:0.21929):0.38045):0.05377):0.03012,((PKR2:0.02894,PKR1:0.05433):0.94818,(((NPY2R:0.55492,GPR83:0.61282):0.05075,PRLHR:0.52930):0.02798,((NPY4R:0.39508,(NPY1R:0.28705,NPY6R:0.46511):0.11830):0.21474,NPY5R:0.70556):0.04245):0.10298):0.03365):0.02436,((NK1R:0.19827,NK3R:0.17196):0.05848,NK2R:0.28508):0.64876):0.05066,((((EDNRA:0.27381,EDNRB:0.12535):0.49073,(GPR37:0.16443,ETBR2:0.32750):0.72694):0.17684,((GRPR:0.23985,NMBR:0.15452):0.06152,BRS3:0.23636):0.38078):0.25329,((MTLR:0.33253,GHSR:0.28880):0.35765,(((NTR1:0.30166,NTR2:0.48134):0.19543,GPR39:0.79339):0.20210,(NMUR2:0.26599,NMUR1:0.31573):0.37745):0.08651):0.21233):0.04012):0.03969,(((GASR:0.22694,CCKAR:0.25077):0.47959,(((TRFR:0.72308,(GP151:0.98114,GP148:2.65017):0.40020):0.18809,GP146:1.53033):0.20362,(GPR84:1.09609,GPR88:1.55637):0.25109):0.01643):0.05945,((GPR19:0.91434,(GPR21:0.11729,GPR52:0.15469):1.06171):0.05945,(((GP173:0.24912,GPR85:0.24442):0.22342,GPR27:0.44745):0.95429,(GP142:0.39179,GP139:0.29840):1.13574):0.05795):0.09169):0.02103):0.00363,(((NPSR1:0.63239,GP150:1.02736):0.02766,(((V1AR:0.23225,V1BR:0.25766):0.04238,OXYR:0.29802):0.17148,V2R:0.51306):0.25307):0.13452,(GNRHR:0.94238,GNRR2:0.34480):0.53223):0.27855):0.01449):0.03852):0.02177):0.12428):0.07151):0.05842):0.05872):0.01847):0.00164):0.01488):0.01919):0.06475):0.03004):0.08337,5HT1A:0.36804)OROOT;"
//var selectivity_data = {'V1AR': ['Gq/G11 family'], '5HT4R': ['Gs family', 'G12/G13 family'], 'EDNRB': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'DRD1': ['Gs family'], 'OPRM': ['Gi/Go family', 'Gq/G11 family'], 'NPFF1': ['Gi/Go family'], 'OX2R': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'FZD9': ['Gi/Go family'], 'FZD1': ['Gi/Go family', 'Gq/G11 family'], 'CXCR4': ['Gi/Go family'], 'HCAR1': ['Gi/Go family'], 'NMUR1': ['Gq/G11 family'], '5HT7R': ['Gs family'], 'GPR55': ['Gq/G11 family', 'G12/G13 family'], '5HT1D': ['Gi/Go family'], 'HRH1': ['Gq/G11 family'], 'GRM4': ['Gi/Go family'], 'RXFP2': ['Gi/Go family', 'Gs family'], 'S1PR4': ['Gi/Go family', 'G12/G13 family'], 'GPR18': ['Gi/Go family', 'Gq/G11 family'], 'GPR31': ['Gi/Go family'], 'LT4R1': ['Gi/Go family', 'Gq/G11 family'], 'FPR3': ['Gi/Go family'], 'GASR': ['Gq/G11 family'], 'OGR1': ['Gi/Go family', 'Gq/G11 family'], 'S1PR3': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'APJ': ['Gi/Go family'], 'ACM4': ['Gi/Go family'], 'RL3R2': ['Gi/Go family'], 'GPR26': ['Gs family'], 'GPR4': ['Gi/Go family', 'Gq/G11 family', 'Gs family', 'G12/G13 family'], 'SSR5': ['Gi/Go family', 'Gq/G11 family'], 'MC5R': ['Gs family'], 'CCR7': ['Gi/Go family'], 'GPBAR': ['Gs family'], 'ETBR2': ['Gi/Go family'], 'ACM3': ['Gq/G11 family'], '5HT1A': ['Gi/Go family'], 'OPRD': ['Gi/Go family'], 'ADA1B': ['Gq/G11 family'], 'KISSR': ['Gq/G11 family'], 'NK2R': ['Gq/G11 family', 'Gs family'], 'GRM2': ['Gi/Go family'], 'CLTR1': ['Gi/Go family', 'Gq/G11 family'], 'FPR2': ['Gi/Go family', 'Gq/G11 family'], 'AGTR2': ['Gi/Go family'], 'GRM5': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'CNR2': ['Gi/Go family', 'Gs family'], 'CML1': ['Gi/Go family'], 'NPBW1': ['Gi/Go family'], 'LPAR6': ['Gi/Go family', 'Gs family', 'G12/G13 family'], 'MRGRD': ['Gi/Go family', 'Gq/G11 family'], 'DRD4': ['Gi/Go family'], 'AA2BR': ['Gq/G11 family', 'Gs family'], 'ADA1D': ['Gq/G11 family'], 'NPFF2': ['Gi/Go family'], 'GPR20': ['Gi/Go family'], 'GALR3': ['Gi/Go family'], 'FFAR2': ['Gi/Go family', 'Gq/G11 family'], 'PD2R2': ['Gi/Go family'], 'GIPR': ['Gs family'], 'LPAR4': ['Gi/Go family', 'Gq/G11 family', 'Gs family', 'G12/G13 family'], 'FFAR1': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'ACM5': ['Gq/G11 family'], 'TA2R': ['Gq/G11 family'], 'RL3R1': ['Gi/Go family'], 'CCR2': ['Gi/Go family'], 'GHSR': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'FZD3': ['Gs family'], 'CALCR': ['Gq/G11 family', 'Gs family'], 'GNRHR': ['Gi/Go family', 'Gq/G11 family'], 'TRFR': ['Gq/G11 family'], 'S1PR5': ['Gi/Go family', 'G12/G13 family'], 'MCHR2': ['Gq/G11 family'], 'MRGX2': ['Gi/Go family', 'Gq/G11 family'], 'GP119': ['Gs family'], 'GRM7': ['Gi/Go family'], 'FZD2': ['Gi/Go family'], 'ADRB2': ['Gi/Go family', 'Gs family'], 'S1PR2': ['Gq/G11 family', 'Gs family', 'G12/G13 family'], 'CLTR2': ['Gi/Go family', 'Gq/G11 family'], 'P2Y11': ['Gq/G11 family', 'Gs family'], 'NPY1R': ['Gi/Go family'], 'SSR1': ['Gi/Go family'], 'VIPR1': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'MTR1B': ['Gi/Go family'], 'ADA2C': ['Gi/Go family', 'Gs family'], 'MTR1A': ['Gi/Go family', 'Gq/G11 family'], 'CCKAR': ['Gq/G11 family', 'Gs family'], 'MRGX3': ['Gq/G11 family'], 'GRPR': ['Gq/G11 family'], 'PD2R': ['Gs family'], 'RXFP1': ['Gi/Go family', 'Gs family'], 'ADRB1': ['Gi/Go family', 'Gs family'], 'NTR1': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], '5HT1F': ['Gi/Go family'], 'CXCR6': ['Gi/Go family'], 'TSHR': ['Gq/G11 family', 'Gs family'], 'FZD7': ['Gi/Go family', 'Gs family'], 'CCR1': ['Gi/Go family'], 'V2R': ['Gs family'], 'GPC6A': ['Gq/G11 family'], 'GLR': ['Gs family'], 'CRFR2': ['Gq/G11 family', 'Gs family'], 'CXCR1': ['Gi/Go family', 'Gq/G11 family'], 'NPY4R': ['Gi/Go family', 'Gq/G11 family'], '5HT1E': ['Gi/Go family'], 'GP101': ['Gs family'], 'S1PR1': ['Gi/Go family'], 'P2RY4': ['Gq/G11 family'], 'GPR78': ['Gs family'], 'NPY2R': ['Gi/Go family', 'Gq/G11 family'], 'CRFR1': ['Gq/G11 family', 'Gs family'], 'GPR34': ['Gi/Go family'], 'NTR2': ['Gq/G11 family'], 'MAS': ['Gi/Go family', 'Gq/G11 family'], 'ADA1A': ['Gq/G11 family', 'G12/G13 family'], 'GPR84': ['Gi/Go family'], 'EDNRA': ['Gq/G11 family'], 'UR2R': ['Gq/G11 family'], 'DRD2': ['Gi/Go family'], 'V1BR': ['Gq/G11 family'], 'PE2R1': ['Gi/Go family', 'Gq/G11 family'], 'SSR4': ['Gi/Go family'], 'ADA2A': ['Gi/Go family', 'Gs family'], 'LPAR2': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'GPR33': ['Gi/Go family'], 'CXCR5': ['Gi/Go family'], 'GALR1': ['Gi/Go family'], 'SSR3': ['Gi/Go family', 'Gq/G11 family'], 'GP139': ['Gq/G11 family'], 'OPN5': ['Gi/Go family'], 'MTLR': ['Gq/G11 family', 'G12/G13 family'], 'ADA2B': ['Gi/Go family', 'Gs family'], 'AA3R': ['Gi/Go family'], 'CCR10': ['Gi/Go family'], 'XCR1': ['Gi/Go family'], 'PKR1': ['Gq/G11 family', 'Gs family'], 'MC3R': ['Gs family'], 'PTAFR': ['Gi/Go family', 'Gq/G11 family'], 'FFAR3': ['Gi/Go family'], 'NMBR': ['Gq/G11 family'], 'GRM3': ['Gi/Go family'], 'NPY5R': ['Gi/Go family'], 'PF2R': ['Gq/G11 family', 'Gs family'], 'MSHR': ['Gs family'], 'MC4R': ['Gs family'], 'GPR37': ['Gi/Go family'], 'ADRB3': ['Gi/Go family', 'Gs family'], 'DRD3': ['Gi/Go family'], 'VIPR2': ['Gs family'], 'SSR2': ['Gi/Go family', 'Gq/G11 family'], 'FZD10': ['G12/G13 family'], 'GPR3': ['Gs family'], 'GPER1': ['Gi/Go family', 'Gs family'], 'PE2R3': ['Gi/Go family', 'Gq/G11 family'], 'GPR12': ['Gi/Go family', 'Gs family'], 'CASR': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'QRFPR': ['Gi/Go family', 'Gq/G11 family'], 'MRGX1': ['Gq/G11 family'], 'HCAR2': ['Gi/Go family'], 'LT4R2': ['Gi/Go family', 'Gq/G11 family'], 'P2RY6': ['Gq/G11 family', 'G12/G13 family'], 'LPAR1': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'GPR6': ['Gi/Go family', 'Gs family'], 'ACTHR': ['Gs family'], 'PI2R': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'FZD6': ['Gi/Go family', 'Gq/G11 family'], 'FSHR': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'BKRB1': ['Gi/Go family', 'Gq/G11 family'], 'GPR39': ['Gq/G11 family', 'Gs family', 'G12/G13 family'], 'CCR9': ['Gi/Go family'], 'OPRX': ['Gi/Go family'], 'TAAR1': ['Gq/G11 family', 'Gs family'], 'NMUR2': ['Gq/G11 family'], 'PE2R4': ['Gi/Go family', 'Gs family'], 'GRM6': ['Gi/Go family'], 'GRM8': ['Gi/Go family'], 'OXYR': ['Gi/Go family', 'Gq/G11 family'], '5HT1B': ['Gi/Go family'], 'HRH4': ['Gi/Go family'], 'P2RY1': ['Gi/Go family', 'Gq/G11 family'], 'GHRHR': ['Gs family'], 'CNR1': ['Gi/Go family', 'Gs family'], 'CXCR2': ['Gi/Go family'], 'PKR2': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'OX1R': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'DRD5': ['Gs family'], 'FZD4': ['G12/G13 family'], 'OPRK': ['Gi/Go family', 'G12/G13 family'], 'GPR27': ['Gq/G11 family'], 'OXGR1': ['Gq/G11 family'], 'C5AR1': ['Gi/Go family', 'Gq/G11 family'], 'CCR8': ['Gi/Go family'], 'AA1R': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'NK3R': ['Gq/G11 family'], 'MRGX4': ['Gq/G11 family'], 'PE2R2': ['Gs family'], 'PACR': ['Gq/G11 family', 'Gs family'], 'SMO': ['Gi/Go family', 'G12/G13 family'], 'OXER1': ['Gi/Go family'], 'LPAR3': ['Gi/Go family', 'Gq/G11 family'], 'P2Y13': ['Gi/Go family'], 'CCR5': ['Gi/Go family'], 'NPBW2': ['Gi/Go family'], 'CCR4': ['Gi/Go family'], 'PSYR': ['Gs family'], '5HT2A': ['Gi/Go family', 'Gq/G11 family'], 'GRM1': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], '5HT2C': ['Gi/Go family', 'Gq/G11 family'], 'GPR22': ['Gi/Go family'], 'PTH1R': ['Gq/G11 family', 'Gs family'], 'SUCR1': ['Gi/Go family', 'Gq/G11 family'], 'NPSR1': ['Gq/G11 family', 'Gs family'], 'BKRB2': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'GP183': ['Gi/Go family'], '5HT2B': ['Gq/G11 family'], 'FPR1': ['Gi/Go family'], 'LSHR': ['Gq/G11 family', 'Gs family'], 'HRH3': ['Gi/Go family'], 'LPAR5': ['Gq/G11 family', 'G12/G13 family'], '5HT5A': ['Gi/Go family', 'Gq/G11 family'], 'P2Y14': ['Gi/Go family'], 'OPN4': ['Gi/Go family', 'Gq/G11 family'], 'MCHR1': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'GALR2': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'CCR6': ['Gi/Go family'], 'NK1R': ['Gq/G11 family', 'Gs family'], 'CCR3': ['Gi/Go family'], 'BRS3': ['Gq/G11 family'], 'GLP1R': ['Gs family'], 'CXCR3': ['Gi/Go family'], 'ACM1': ['Gq/G11 family'], '5HT6R': ['Gq/G11 family', 'Gs family'], 'ACM2': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'CX3C1': ['Gi/Go family'], 'P2RY2': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'GPR17': ['Gi/Go family', 'Gq/G11 family'], 'AA2AR': ['Gq/G11 family', 'Gs family'], 'HCAR3': ['Gi/Go family'], 'HRH2': ['Gq/G11 family', 'Gs family'], 'AGTR1': ['Gi/Go family', 'Gq/G11 family'], 'GPR75': ['Gq/G11 family'], 'FFAR4': ['Gq/G11 family']};

//var test_string = "(((glp1r_human:0.03295,g1sgd4_rabit:0.01369):0.30976,glr_human:0.27221):0.47235,(crfr1_human:0.64018,(grm1_human:0.10097,grm5_human:0.17333):3.05238):0.10081,calcr_human:0.71265);";

var urls = {
    'glp1r_human': "http://gpcrdb.org/protein/glp1r_human/",
    'g1sgd4_rabit': "http://gpcrdb.org/protein/g1sgd4_rabit/",
    'glr_human': "http://gpcrdb.org/protein/glr_human/",
    'crfr1_human': "http://gpcrdb.org/protein/crfr1_human/",
    'grm1_human': "http://gpcrdb.org/protein/grm1_human/",
    'grm5_human': "http://gpcrdb.org/protein/grm5_human/",
    'calcr_human':"http://gpcrdb.org/protein/calcr_human/"
};


var width  = 800,
    height = 800,
    color_scheme = d3.scale.category10(),
    selection_set = ['Foreground'],
    current_selection_id = 0;

var tree;


d3.select(window).on('load', init);

// d3.json("receptors_json.json", function (error, data) {
//     if (error) throw error;
//     receptor_data = data;
// });

// d3.json("data_type.json", function (error, dt_type) {
//     if (error) throw error;
//     data_type = dt_type;
// });

function init() {

    // append checkboxes according to data in data_type
    $.each(data_type, function (obj, value) {
        $("#data_selection_id").append('<input type=\"checkbox\" name=\"' + value.name + '\" value=\"' + value.type +'\"' +'\/> ' + value.print_name.replace(/["']/g, "") + '\n');
    });

    tree = d3.layout.phylotree("body")
        .size([800, 800])
        .separation (function (a,b) {return 1;});

    var container_id = '#tree_container';
    //var margin = {top: 80, right: 50, bottom: 150, left: 100};

    var svg = d3.select(container_id)
        .append("svg")
        .attr("id", "my_svg");
    

    default_tree_settings();
    tree(phylip_data).svg(svg).layout();

    // add spaces to tree when buttons selected
    d3.selectAll("[data-direction]").on("click", function (e) {
        var which_function = $(this).data ("direction") === 'vertical' ? tree.spacing_x : tree.spacing_y;
        which_function(which_function() + (+ $(this).data ("amount"))).update();
    });

    // go from linear to radial layout
    $(".phylotree-layout-mode").on("change", function (e) {
        if ($(this).is(':checked')) {
            if (tree.radial() !== ($(this).data("mode") === "radial")) {
                tree.radial(!tree.radial()).placenodes().update();
            }
        }
    });

    // activate or deactivate animation
    d3.select("#toggle_animation").on("click", function (e) {
        var current_mode = $(this).hasClass('active');
        $(this).toggleClass('active');
        tree.options ({'transitions' : !current_mode} );
    });

    $(".phylotree-align-toggler").on("change", function (e) {
        if ($(this).is(':checked')) {
            if (tree.align_tips ($(this).data("align") === "right")) {
                tree.placenodes().update();
            }
        }
    });

    d3.select("#sort_original").on ("click", function (e) {
        tree.resort_children (function (a,b) {
            return a["original_child_order"] - b["original_child_order"];
        });
    });

    d3.select("#sort_ascending").on("click", function (e) {
        sort_nodes(true);
    });

    d3.select("#sort_descending").on ("click", function (e) {
        sort_nodes(false);
    });


    selected_case = [];
    d3.select("fieldset[name=data_selection]").on("change", function() {
        selected_case = [];
        $(this).children("input:checked").map(function() {
            selected_case.push(this); // add the entire input tag in the array
            return selected_case;
        });
    });

    d3.select("#draw_data").on("click", function (e) {
        // TODO add a function that resize the svg and checks for elements inside
        if(selected_case.length === 0){
            alert("Please select data")
        } else {
            $(this).toggleClass('active');
            if($(this).hasClass('active') ){
                // check for type of data selected and draw accordingly - the type of data is specified in the value of the input tag
                selected_case.forEach(function (option) {
                    if (option.value === "class"){
                        if (option.name === "GPCR_class"){
                            draw_class_data(receptor_data, data_type[0]);
                        } else if (option.name === "ligand_type"){
                            draw_class_data(receptor_data, data_type[1]);
                        }
                    } else if (option.value === "category"){
                        draw_categorical_data(receptor_data, data_type[2])

                    } else if (option.value === "quantity"){
                        draw_quantitative_data(receptor_data, data_type[3]);
                    }
                });

            } else {
                remove_annotations()


            }

        }

    });

    // TODO modify the opening of the receptor page
    // add a custom menu for terminal nodes - to open receptor page
    function add_url_to_menu_title() { //add title to menu
        return "Open receptor page";
    }

    function my_node_urls(element, url_data) { // open link on new page
        dblclick(url_data[element.name])
    }

    tree.get_nodes().forEach(function(tree_node) { // add menu to leaf nodes
        d3.layout.phylotree.add_custom_menu(tree_node,
            add_url_to_menu_title,
            function() {my_node_urls(tree_node, urls);},
            d3.layout.phylotree.is_leafnode
        );
    });<commit_msg>added general function<commit_after>//var test_string = "(((5HT1D:0.14656,5HT1B:0.18681):0.08093,(5HT1F:0.18620,5HT1E:0.20912):0.12352):0.09868,(5HT5A:0.61709,(5HT7R:0.48940,((DRD1:0.13081,DRD5:0.11617):0.37543,((((DRD2:0.15236,DRD3:0.18945):0.24327,DRD4:0.48536):0.05986,((ADA2A:0.13115,ADA2C:0.18228):0.01936,ADA2B:0.15621):0.42124):0.05763,(((ADRB2:0.25547,ADRB1:0.19778):0.08565,ADRB3:0.34080):0.26142,(((ADA1A:0.17733,ADA1B:0.14958):0.02087,ADA1D:0.20860):0.31132,((HRH2:0.52426,(5HT4R:0.52452,((TAAR1:0.26729,(TAAR2:0.22284,TAAR3:0.31017):0.23539):0.22600,(((TAAR6:0.08400,TAAR8:0.19222):0.07454,TAAR9:0.21355):0.22951,TAAR5:0.47985):0.02793):0.23241):0.04297):0.05334,((((5HT2A:0.17106,5HT2C:0.16504):0.04954,5HT2B:0.25906):0.41256,(5HT6R:0.69434,GP119:1.09071):0.07887):0.04207,(((((ACM2:0.10343,ACM4:0.08889):0.11475,((ACM3:0.11552,ACM1:0.18469):0.01030,ACM5:0.09545):0.11701):0.40955,HRH1:0.66818):0.06411,(HRH4:0.47944,HRH3:0.32974):0.35975):0.14632,((((AA1R:0.28657,AA3R:0.32509):0.15582,(AA2AR:0.22538,AA2BR:0.20286):0.13983):0.45766,((((MSHR:0.38244,((MC3R:0.16962,MC5R:0.21034):0.04580,MC4R:0.17196):0.09610):0.10745,ACTHR:0.44663):0.33195,((GPR6:0.26054,GPR12:0.27634):0.00641,GPR3:0.19274):0.56708):0.06336,(((S1PR1:0.27466,(S1PR2:0.39143,(S1PR3:0.36509,(S1PR5:0.36473,S1PR4:0.55222):0.02790):0.00867):0.16091):0.26558,(LPAR1:0.27356,(LPAR2:0.36350,LPAR3:0.29943):0.02502):0.28322):0.13154,(CNR1:0.35087,CNR2:0.35507):0.62427):0.12276):0.19783):0.04243,(((((GP161:0.88256,GP101:0.81561):0.07534,GP135:0.80381):0.04794,(GPR45:0.26599,GPR63:0.34295):0.52601):0.08401,((MTR1A:0.20256,MTR1B:0.19320):0.15610,MTR1L:0.45969):0.54665):0.04891,(((((OPN4:0.56879,OPN5:0.92903):0.06501,((((OPSG:0.02697,OPSR:0.03342):0.53998,OPSB:0.52647):0.01057,OPSD:0.44439):0.19490,OPN3:0.80151):0.19502):0.18268,((RXFP1:0.21942,RXFP2:0.26012):0.66213,(((TSHR:0.16173,LSHR:0.21867):0.04430,FSHR:0.15058):0.48573,((LGR5:0.24949,LGR6:0.45298):0.09865,LGR4:0.35743):0.99322):0.08326):0.46464):0.07709,(((FFAR4:0.92854,GPR22:1.18891):0.07305,GP176:1.12688):0.05328,((((MRGX4:0.10513,((MRGX1:0.04116,MRGX3:0.12617):0.05361,MRGX2:0.27642):0.04263):0.29790,((MRGRE:0.61765,MRGRG:0.73434):0.25048,MAS1L:0.90053):0.03282):0.06336,(MAS:0.77797,(MRGRD:0.50798,MRGRF:0.77014):0.08596):0.11897):0.69213,((((PE2R2:0.41800,PD2R:0.67895):0.10363,PI2R:0.67801):0.24656,PE2R4:0.72942):0.13337,(((PE2R1:0.58381,PF2R:0.56725):0.05786,TA2R:0.56254):0.20544,PE2R3:0.59249):0.28215):0.56311):0.09818):0.03669):0.05237,((((((GPR61:0.53396,GPR62:0.79568):0.45475,(GPR26:0.35671,GPR78:0.55697):0.67563):0.13541,UR2R:0.90308):0.05448,(((((((RL3R2:0.41574,RL3R1:0.37875):0.33106,(AGTR2:0.55722,AGTR1:0.55967):0.13173):0.05873,(APJ:0.67628,(GPR15:0.58010,GPR25:0.61852):0.18176):0.00778):0.02780,(((((CXCR2:0.05388,CXCR1:0.08153):0.42425,(CXCR5:0.50867,CXCR3:0.45350):0.06213):0.01352,CXCR4:0.56322):0.03272,((((CCR8:0.42058,((((CCR2:0.08743,CCR5:0.10207):0.16440,(CCR3:0.18374,CCR1:0.18158):0.07935):0.02277,CCRL2:0.52166):0.07748,CCR4:0.38947):0.05710):0.05044,CX3C1:0.38371):0.06819,(XCR1:0.54471,ACKR2:0.54304):0.04238):0.08031,(CXCR6:0.50090,((ACKR4:0.46379,(CCR7:0.42440,CCR9:0.38556):0.05089):0.04825,CCR6:0.47437):0.00461):0.12806):0.01989):0.14820,((ACKR3:0.52247,GP182:0.59468):0.23813,GPER1:0.88006):0.01691):0.01708):0.02247,(BKRB2:0.51447,BKRB1:0.56345):0.29484):0.05314,(((((HCAR2:0.05555,HCAR3:0.10376):0.18659,HCAR1:0.35694):0.24507,OXER1:0.47038):0.11069,GPR31:0.61743):0.35707,(((((((GPR35:0.72834,(GPR55:0.66501,FFAR1:0.82706):0.21885):0.07208,LPAR5:0.68476):0.04084,GPR20:0.77307):0.07754,((PAR4:0.57467,(((PAR2:0.52345,PAR1:0.57365):0.02890,PAR3:0.54309):0.04601,P2RY8:0.59538):0.03028):0.12099,(FFAR2:0.42973,(FFAR3:0.00538,GPR42:0.00422):0.37178):0.49994):0.05897):0.01895,(((PSYR:0.57559,(GPR4:0.40370,OGR1:0.39889):0.18363):0.09103,GP132:0.70545):0.24656,(((((LPAR6:0.25135,LPAR4:0.32636):0.28952,(PTAFR:0.67270,(GP174:0.36331,P2Y10:0.36053):0.42764):0.08679):0.09420,(CLTR1:0.52254,CLTR2:0.54393):0.15646):0.01173,GPR17:0.65080):0.04675,(((P2RY1:0.51184,P2Y11:0.83945):0.06289,((P2RY2:0.15600,P2RY4:0.32583):0.25068,P2RY6:0.50242):0.14435):0.09686,(OXGR1:0.62196,SUCR1:0.62748):0.09278):0.13068):0.02514):0.04548):0.02914,GP183:0.77503):0.01692,(((GPR34:0.63511,((GPR87:0.35245,(P2Y14:0.36677,(P2Y12:0.26004,P2Y13:0.40774):0.03744):0.08916):0.20002,GP171:0.69543):0.15216):0.06879,GPR82:1.06732):0.09381,(GPR18:0.89407,GP141:1.71148):0.10901):0.06110):0.09217):0.07603):0.06065,((((LT4R1:0.34230,LT4R2:0.56786):0.20423,GP152:1.16379):0.13340,(((C3AR:0.47649,(C5AR1:0.41334,C5AR2:0.63635):0.17172):0.02610,PD2R2:0.67680):0.03026,((CML1:0.43811,GPR1:0.57985):0.07689,((GPR32:0.71839,((FPR2:0.14255,FPR1:0.18677):0.03982,FPR3:0.22440):0.34075):0.07286,GPR33:0.82218):0.02563):0.02168):0.09214):0.14307,((CCR10:0.51827,ACKR1:1.92511):0.18804,(((GP162:0.40624,GP153:0.80663):1.72843,GPR75:1.26731):0.05945,(GPBAR:1.48202,(GP149:2.44392,GP160:1.72540):0.31634):0.18513):0.09889):0.06230):0.04630):0.04141):0.02581,(((((SSR1:0.17885,SSR4:0.18260):0.11696,((SSR3:0.20393,SSR5:0.23343):0.05093,SSR2:0.28178):0.06928):0.12990,(((OPRK:0.12704,(OPRD:0.15715,OPRM:0.15980):0.04678):0.06932,OPRX:0.26870):0.24080,(NPBW2:0.18687,NPBW1:0.20734):0.44035):0.03465):0.10010,(MCHR1:0.52414,MCHR2:0.65206):0.24588):0.12716,(GALR1:0.44912,((GALR2:0.20275,GALR3:0.25153):0.32957,KISSR:0.71877):0.09052):0.14818):0.06828):0.04164,((((((QRFPR:0.68527,((OX2R:0.10301,OX1R:0.13914):0.48857,(NPFF2:0.21754,NPFF1:0.21929):0.38045):0.05377):0.03012,((PKR2:0.02894,PKR1:0.05433):0.94818,(((NPY2R:0.55492,GPR83:0.61282):0.05075,PRLHR:0.52930):0.02798,((NPY4R:0.39508,(NPY1R:0.28705,NPY6R:0.46511):0.11830):0.21474,NPY5R:0.70556):0.04245):0.10298):0.03365):0.02436,((NK1R:0.19827,NK3R:0.17196):0.05848,NK2R:0.28508):0.64876):0.05066,((((EDNRA:0.27381,EDNRB:0.12535):0.49073,(GPR37:0.16443,ETBR2:0.32750):0.72694):0.17684,((GRPR:0.23985,NMBR:0.15452):0.06152,BRS3:0.23636):0.38078):0.25329,((MTLR:0.33253,GHSR:0.28880):0.35765,(((NTR1:0.30166,NTR2:0.48134):0.19543,GPR39:0.79339):0.20210,(NMUR2:0.26599,NMUR1:0.31573):0.37745):0.08651):0.21233):0.04012):0.03969,(((GASR:0.22694,CCKAR:0.25077):0.47959,(((TRFR:0.72308,(GP151:0.98114,GP148:2.65017):0.40020):0.18809,GP146:1.53033):0.20362,(GPR84:1.09609,GPR88:1.55637):0.25109):0.01643):0.05945,((GPR19:0.91434,(GPR21:0.11729,GPR52:0.15469):1.06171):0.05945,(((GP173:0.24912,GPR85:0.24442):0.22342,GPR27:0.44745):0.95429,(GP142:0.39179,GP139:0.29840):1.13574):0.05795):0.09169):0.02103):0.00363,(((NPSR1:0.63239,GP150:1.02736):0.02766,(((V1AR:0.23225,V1BR:0.25766):0.04238,OXYR:0.29802):0.17148,V2R:0.51306):0.25307):0.13452,(GNRHR:0.94238,GNRR2:0.34480):0.53223):0.27855):0.01449):0.03852):0.02177):0.12428):0.07151):0.05842):0.05872):0.01847):0.00164):0.01488):0.01919):0.06475):0.03004):0.08337,5HT1A:0.36804)OROOT;"
//var selectivity_data = {'V1AR': ['Gq/G11 family'], '5HT4R': ['Gs family', 'G12/G13 family'], 'EDNRB': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'DRD1': ['Gs family'], 'OPRM': ['Gi/Go family', 'Gq/G11 family'], 'NPFF1': ['Gi/Go family'], 'OX2R': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'FZD9': ['Gi/Go family'], 'FZD1': ['Gi/Go family', 'Gq/G11 family'], 'CXCR4': ['Gi/Go family'], 'HCAR1': ['Gi/Go family'], 'NMUR1': ['Gq/G11 family'], '5HT7R': ['Gs family'], 'GPR55': ['Gq/G11 family', 'G12/G13 family'], '5HT1D': ['Gi/Go family'], 'HRH1': ['Gq/G11 family'], 'GRM4': ['Gi/Go family'], 'RXFP2': ['Gi/Go family', 'Gs family'], 'S1PR4': ['Gi/Go family', 'G12/G13 family'], 'GPR18': ['Gi/Go family', 'Gq/G11 family'], 'GPR31': ['Gi/Go family'], 'LT4R1': ['Gi/Go family', 'Gq/G11 family'], 'FPR3': ['Gi/Go family'], 'GASR': ['Gq/G11 family'], 'OGR1': ['Gi/Go family', 'Gq/G11 family'], 'S1PR3': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'APJ': ['Gi/Go family'], 'ACM4': ['Gi/Go family'], 'RL3R2': ['Gi/Go family'], 'GPR26': ['Gs family'], 'GPR4': ['Gi/Go family', 'Gq/G11 family', 'Gs family', 'G12/G13 family'], 'SSR5': ['Gi/Go family', 'Gq/G11 family'], 'MC5R': ['Gs family'], 'CCR7': ['Gi/Go family'], 'GPBAR': ['Gs family'], 'ETBR2': ['Gi/Go family'], 'ACM3': ['Gq/G11 family'], '5HT1A': ['Gi/Go family'], 'OPRD': ['Gi/Go family'], 'ADA1B': ['Gq/G11 family'], 'KISSR': ['Gq/G11 family'], 'NK2R': ['Gq/G11 family', 'Gs family'], 'GRM2': ['Gi/Go family'], 'CLTR1': ['Gi/Go family', 'Gq/G11 family'], 'FPR2': ['Gi/Go family', 'Gq/G11 family'], 'AGTR2': ['Gi/Go family'], 'GRM5': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'CNR2': ['Gi/Go family', 'Gs family'], 'CML1': ['Gi/Go family'], 'NPBW1': ['Gi/Go family'], 'LPAR6': ['Gi/Go family', 'Gs family', 'G12/G13 family'], 'MRGRD': ['Gi/Go family', 'Gq/G11 family'], 'DRD4': ['Gi/Go family'], 'AA2BR': ['Gq/G11 family', 'Gs family'], 'ADA1D': ['Gq/G11 family'], 'NPFF2': ['Gi/Go family'], 'GPR20': ['Gi/Go family'], 'GALR3': ['Gi/Go family'], 'FFAR2': ['Gi/Go family', 'Gq/G11 family'], 'PD2R2': ['Gi/Go family'], 'GIPR': ['Gs family'], 'LPAR4': ['Gi/Go family', 'Gq/G11 family', 'Gs family', 'G12/G13 family'], 'FFAR1': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'ACM5': ['Gq/G11 family'], 'TA2R': ['Gq/G11 family'], 'RL3R1': ['Gi/Go family'], 'CCR2': ['Gi/Go family'], 'GHSR': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'FZD3': ['Gs family'], 'CALCR': ['Gq/G11 family', 'Gs family'], 'GNRHR': ['Gi/Go family', 'Gq/G11 family'], 'TRFR': ['Gq/G11 family'], 'S1PR5': ['Gi/Go family', 'G12/G13 family'], 'MCHR2': ['Gq/G11 family'], 'MRGX2': ['Gi/Go family', 'Gq/G11 family'], 'GP119': ['Gs family'], 'GRM7': ['Gi/Go family'], 'FZD2': ['Gi/Go family'], 'ADRB2': ['Gi/Go family', 'Gs family'], 'S1PR2': ['Gq/G11 family', 'Gs family', 'G12/G13 family'], 'CLTR2': ['Gi/Go family', 'Gq/G11 family'], 'P2Y11': ['Gq/G11 family', 'Gs family'], 'NPY1R': ['Gi/Go family'], 'SSR1': ['Gi/Go family'], 'VIPR1': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'MTR1B': ['Gi/Go family'], 'ADA2C': ['Gi/Go family', 'Gs family'], 'MTR1A': ['Gi/Go family', 'Gq/G11 family'], 'CCKAR': ['Gq/G11 family', 'Gs family'], 'MRGX3': ['Gq/G11 family'], 'GRPR': ['Gq/G11 family'], 'PD2R': ['Gs family'], 'RXFP1': ['Gi/Go family', 'Gs family'], 'ADRB1': ['Gi/Go family', 'Gs family'], 'NTR1': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], '5HT1F': ['Gi/Go family'], 'CXCR6': ['Gi/Go family'], 'TSHR': ['Gq/G11 family', 'Gs family'], 'FZD7': ['Gi/Go family', 'Gs family'], 'CCR1': ['Gi/Go family'], 'V2R': ['Gs family'], 'GPC6A': ['Gq/G11 family'], 'GLR': ['Gs family'], 'CRFR2': ['Gq/G11 family', 'Gs family'], 'CXCR1': ['Gi/Go family', 'Gq/G11 family'], 'NPY4R': ['Gi/Go family', 'Gq/G11 family'], '5HT1E': ['Gi/Go family'], 'GP101': ['Gs family'], 'S1PR1': ['Gi/Go family'], 'P2RY4': ['Gq/G11 family'], 'GPR78': ['Gs family'], 'NPY2R': ['Gi/Go family', 'Gq/G11 family'], 'CRFR1': ['Gq/G11 family', 'Gs family'], 'GPR34': ['Gi/Go family'], 'NTR2': ['Gq/G11 family'], 'MAS': ['Gi/Go family', 'Gq/G11 family'], 'ADA1A': ['Gq/G11 family', 'G12/G13 family'], 'GPR84': ['Gi/Go family'], 'EDNRA': ['Gq/G11 family'], 'UR2R': ['Gq/G11 family'], 'DRD2': ['Gi/Go family'], 'V1BR': ['Gq/G11 family'], 'PE2R1': ['Gi/Go family', 'Gq/G11 family'], 'SSR4': ['Gi/Go family'], 'ADA2A': ['Gi/Go family', 'Gs family'], 'LPAR2': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'GPR33': ['Gi/Go family'], 'CXCR5': ['Gi/Go family'], 'GALR1': ['Gi/Go family'], 'SSR3': ['Gi/Go family', 'Gq/G11 family'], 'GP139': ['Gq/G11 family'], 'OPN5': ['Gi/Go family'], 'MTLR': ['Gq/G11 family', 'G12/G13 family'], 'ADA2B': ['Gi/Go family', 'Gs family'], 'AA3R': ['Gi/Go family'], 'CCR10': ['Gi/Go family'], 'XCR1': ['Gi/Go family'], 'PKR1': ['Gq/G11 family', 'Gs family'], 'MC3R': ['Gs family'], 'PTAFR': ['Gi/Go family', 'Gq/G11 family'], 'FFAR3': ['Gi/Go family'], 'NMBR': ['Gq/G11 family'], 'GRM3': ['Gi/Go family'], 'NPY5R': ['Gi/Go family'], 'PF2R': ['Gq/G11 family', 'Gs family'], 'MSHR': ['Gs family'], 'MC4R': ['Gs family'], 'GPR37': ['Gi/Go family'], 'ADRB3': ['Gi/Go family', 'Gs family'], 'DRD3': ['Gi/Go family'], 'VIPR2': ['Gs family'], 'SSR2': ['Gi/Go family', 'Gq/G11 family'], 'FZD10': ['G12/G13 family'], 'GPR3': ['Gs family'], 'GPER1': ['Gi/Go family', 'Gs family'], 'PE2R3': ['Gi/Go family', 'Gq/G11 family'], 'GPR12': ['Gi/Go family', 'Gs family'], 'CASR': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'QRFPR': ['Gi/Go family', 'Gq/G11 family'], 'MRGX1': ['Gq/G11 family'], 'HCAR2': ['Gi/Go family'], 'LT4R2': ['Gi/Go family', 'Gq/G11 family'], 'P2RY6': ['Gq/G11 family', 'G12/G13 family'], 'LPAR1': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'GPR6': ['Gi/Go family', 'Gs family'], 'ACTHR': ['Gs family'], 'PI2R': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'FZD6': ['Gi/Go family', 'Gq/G11 family'], 'FSHR': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'BKRB1': ['Gi/Go family', 'Gq/G11 family'], 'GPR39': ['Gq/G11 family', 'Gs family', 'G12/G13 family'], 'CCR9': ['Gi/Go family'], 'OPRX': ['Gi/Go family'], 'TAAR1': ['Gq/G11 family', 'Gs family'], 'NMUR2': ['Gq/G11 family'], 'PE2R4': ['Gi/Go family', 'Gs family'], 'GRM6': ['Gi/Go family'], 'GRM8': ['Gi/Go family'], 'OXYR': ['Gi/Go family', 'Gq/G11 family'], '5HT1B': ['Gi/Go family'], 'HRH4': ['Gi/Go family'], 'P2RY1': ['Gi/Go family', 'Gq/G11 family'], 'GHRHR': ['Gs family'], 'CNR1': ['Gi/Go family', 'Gs family'], 'CXCR2': ['Gi/Go family'], 'PKR2': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'OX1R': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'DRD5': ['Gs family'], 'FZD4': ['G12/G13 family'], 'OPRK': ['Gi/Go family', 'G12/G13 family'], 'GPR27': ['Gq/G11 family'], 'OXGR1': ['Gq/G11 family'], 'C5AR1': ['Gi/Go family', 'Gq/G11 family'], 'CCR8': ['Gi/Go family'], 'AA1R': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'NK3R': ['Gq/G11 family'], 'MRGX4': ['Gq/G11 family'], 'PE2R2': ['Gs family'], 'PACR': ['Gq/G11 family', 'Gs family'], 'SMO': ['Gi/Go family', 'G12/G13 family'], 'OXER1': ['Gi/Go family'], 'LPAR3': ['Gi/Go family', 'Gq/G11 family'], 'P2Y13': ['Gi/Go family'], 'CCR5': ['Gi/Go family'], 'NPBW2': ['Gi/Go family'], 'CCR4': ['Gi/Go family'], 'PSYR': ['Gs family'], '5HT2A': ['Gi/Go family', 'Gq/G11 family'], 'GRM1': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], '5HT2C': ['Gi/Go family', 'Gq/G11 family'], 'GPR22': ['Gi/Go family'], 'PTH1R': ['Gq/G11 family', 'Gs family'], 'SUCR1': ['Gi/Go family', 'Gq/G11 family'], 'NPSR1': ['Gq/G11 family', 'Gs family'], 'BKRB2': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'GP183': ['Gi/Go family'], '5HT2B': ['Gq/G11 family'], 'FPR1': ['Gi/Go family'], 'LSHR': ['Gq/G11 family', 'Gs family'], 'HRH3': ['Gi/Go family'], 'LPAR5': ['Gq/G11 family', 'G12/G13 family'], '5HT5A': ['Gi/Go family', 'Gq/G11 family'], 'P2Y14': ['Gi/Go family'], 'OPN4': ['Gi/Go family', 'Gq/G11 family'], 'MCHR1': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'GALR2': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'CCR6': ['Gi/Go family'], 'NK1R': ['Gq/G11 family', 'Gs family'], 'CCR3': ['Gi/Go family'], 'BRS3': ['Gq/G11 family'], 'GLP1R': ['Gs family'], 'CXCR3': ['Gi/Go family'], 'ACM1': ['Gq/G11 family'], '5HT6R': ['Gq/G11 family', 'Gs family'], 'ACM2': ['Gi/Go family', 'Gq/G11 family', 'Gs family'], 'CX3C1': ['Gi/Go family'], 'P2RY2': ['Gi/Go family', 'Gq/G11 family', 'G12/G13 family'], 'GPR17': ['Gi/Go family', 'Gq/G11 family'], 'AA2AR': ['Gq/G11 family', 'Gs family'], 'HCAR3': ['Gi/Go family'], 'HRH2': ['Gq/G11 family', 'Gs family'], 'AGTR1': ['Gi/Go family', 'Gq/G11 family'], 'GPR75': ['Gq/G11 family'], 'FFAR4': ['Gq/G11 family']};

//var test_string = "(((glp1r_human:0.03295,g1sgd4_rabit:0.01369):0.30976,glr_human:0.27221):0.47235,(crfr1_human:0.64018,(grm1_human:0.10097,grm5_human:0.17333):3.05238):0.10081,calcr_human:0.71265);";

var urls = {
    'glp1r_human': "http://gpcrdb.org/protein/glp1r_human/",
    'g1sgd4_rabit': "http://gpcrdb.org/protein/g1sgd4_rabit/",
    'glr_human': "http://gpcrdb.org/protein/glr_human/",
    'crfr1_human': "http://gpcrdb.org/protein/crfr1_human/",
    'grm1_human': "http://gpcrdb.org/protein/grm1_human/",
    'grm5_human': "http://gpcrdb.org/protein/grm5_human/",
    'calcr_human':"http://gpcrdb.org/protein/calcr_human/"
};


var width  = 800,
    height = 800,
    color_scheme = d3.scale.category10(),
    selection_set = ['Foreground'],
    current_selection_id = 0;

var tree;


d3.select(window).on('load', init);

// d3.json("receptors_json.json", function (error, data) {
//     if (error) throw error;
//     receptor_data = data;
// });

// d3.json("data_type.json", function (error, dt_type) {
//     if (error) throw error;
//     data_type = dt_type;
// });

function init() {

    // append checkboxes according to data in data_type
    $.each(data_type, function (obj, value) {
        $("#data_selection_id").append('<input type=\"checkbox\" name=\"' + value.name + '\" value=\"' + value.type +'\"' +'\/> ' + value.print_name.replace(/["']/g, "") + '\n');
    });

    tree = d3.layout.phylotree("body")
        .size([800, 800])
        .separation (function (a,b) {return 1;});

    var container_id = '#tree_container';
    //var margin = {top: 80, right: 50, bottom: 150, left: 100};

    var svg = d3.select(container_id)
        .append("svg")
        .attr("id", "my_svg");
    

    default_tree_settings();
    tree(phylip_data).svg(svg).layout();

    // add spaces to tree when buttons selected
    d3.selectAll("[data-direction]").on("click", function (e) {
        var which_function = $(this).data ("direction") === 'vertical' ? tree.spacing_x : tree.spacing_y;
        which_function(which_function() + (+ $(this).data ("amount"))).update();
    });

    // go from linear to radial layout
    $(".phylotree-layout-mode").on("change", function (e) {
        if ($(this).is(':checked')) {
            if (tree.radial() !== ($(this).data("mode") === "radial")) {
                tree.radial(!tree.radial()).placenodes().update();
            }
        }
    });

    // activate or deactivate animation
    d3.select("#toggle_animation").on("click", function (e) {
        var current_mode = $(this).hasClass('active');
        $(this).toggleClass('active');
        tree.options ({'transitions' : !current_mode} );
    });

    $(".phylotree-align-toggler").on("change", function (e) {
        if ($(this).is(':checked')) {
            if (tree.align_tips ($(this).data("align") === "right")) {
                tree.placenodes().update();
            }
        }
    });

    d3.select("#sort_original").on ("click", function (e) {
        tree.resort_children (function (a,b) {
            return a["original_child_order"] - b["original_child_order"];
        });
    });

    d3.select("#sort_ascending").on("click", function (e) {
        sort_nodes(true);
    });

    d3.select("#sort_descending").on ("click", function (e) {
        sort_nodes(false);
    });


    selected_case = [];
    d3.select("fieldset[name=data_selection]").on("change", function() {
        selected_case = [];
        $(this).children("input:checked").map(function() {
            selected_case.push(this); // add the entire input tag in the array
            return selected_case;
        });
    });

    d3.select("#draw_data").on("click", function (e) {
        // TODO TAKE A LOOK HERE
        if(selected_case.length === 0){
            alert("Please select data")
        } else {
            $(this).toggleClass('active');
            if($(this).hasClass('active') ){
                data_type.forEach(function (obj, index) {
                    selected_case.forEach(function (option) {
                        if (option.value === "class" && option.name === obj.name){
                            draw_class_data(receptor_data, data_type[index])
                        } else if(option.value === "category" && option.name === obj.name){
                            draw_categorical_data(receptor_data, data_type[index])
                        } else if(option.value === "quantity" && option.name === obj.name){
                            draw_quantitative_data(receptor_data, data_type[index])
                        }
                    })
                });
            } else {
                remove_annotations()
            }

        }

    });

    // TODO modify the opening of the receptor page
    // add a custom menu for terminal nodes - to open receptor page
    function add_url_to_menu_title() { //add title to menu
        return "Open receptor page";
    }

    function my_node_urls(element, url_data) { // open link on new page
        dblclick(url_data[element.name])
    }

    tree.get_nodes().forEach(function(tree_node) { // add menu to leaf nodes
        d3.layout.phylotree.add_custom_menu(tree_node,
            add_url_to_menu_title,
            function() {my_node_urls(tree_node, urls);},
            d3.layout.phylotree.is_leafnode
        );
    });
{'fraction_non_alphanumeric': 0.26874955144613766, 'fraction_numerical': 0.21721968373962344, 'mean_word_length': 4.933569907735983, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6059752', 'n_tokens_mistral': 23965, 'n_tokens_neox': 19116, 'n_words': 2646}