Created
September 14, 2023 10:17
-
-
Save mvdbeek/22ff66d33cbe7415a89295c6c46ea3ba to your computer and use it in GitHub Desktop.
ipython session parsing QS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [2]: import urllib | |
In [3]: urllib.parse.parse_qs('tool_id=ucsc_table_direct1&URL=http%3A%2F%2Fgenome.ucsc.edu%2Fcgi-bin%2FhgTables&hguid=1587314780_KBXslDDpain7o5EBARpPf | |
...: 3nJ1NbE&db=hg38&org=Human&hgta_table=knownGene&hgta_track=knownGene&hgta_regionType=range&hgta_outputType=bed&position=chr2%3A25%2C160%2C915-2 | |
...: 5%2C168%2C903&hgsid=1708063580_QD5ONXCqxp8H5TlaKJtczZ2cy5pQ&boolshad.hgta_printCustomTrackHeaders=0&hgta_ctName=tb_knownGene&hgta_ctDesc=table | |
...: +browser+query+on+knownGene&hgta_ctVis=pack&hgta_ctUrl=&fbQual=whole&fbUpBases=200&fbExonBases=0&fbIntronBases=0&fbDownBases=200&hgta_doGetBed | |
...: =get+BED&hgta_doGalaxyQuery=Send+query+to+Galaxy') | |
Out[3]: | |
{'tool_id': ['ucsc_table_direct1'], | |
'URL': ['http://genome.ucsc.edu/cgi-bin/hgTables'], | |
'hguid': ['1587314780_KBXslDDpain7o5EBARpPf3nJ1NbE'], | |
'db': ['hg38'], | |
'org': ['Human'], | |
'hgta_table': ['knownGene'], | |
'hgta_track': ['knownGene'], | |
'hgta_regionType': ['range'], | |
'hgta_outputType': ['bed'], | |
'position': ['chr2:25,160,915-25,168,903'], | |
'hgsid': ['1708063580_QD5ONXCqxp8H5TlaKJtczZ2cy5pQ'], | |
'boolshad.hgta_printCustomTrackHeaders': ['0'], | |
'hgta_ctName': ['tb_knownGene'], | |
'hgta_ctDesc': ['table browser query on knownGene'], | |
'hgta_ctVis': ['pack'], | |
'fbQual': ['whole'], | |
'fbUpBases': ['200'], | |
'fbExonBases': ['0'], | |
'fbIntronBases': ['0'], | |
'fbDownBases': ['200'], | |
'hgta_doGetBed': ['get BED'], | |
'hgta_doGalaxyQuery': ['Send query to Galaxy']} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [4]: d = {'tool_id': 'ucsc_table_direct1', 'URL': "https://genome.ucsc.edu/cgi-bin/hgTables?hguid=1587314780_KBXslDDpain7o5EBARpPf3nJ1NbE&db=hg38&o | |
...: rg=Human&hgta_table=knownGene&hgta_track=knownGene&hgta_regionType=range&hgta_outputType=bed&position=chr2:25,160,915-25,168,903&hgsid=1708063 | |
...: 580_QD5ONXCqxp8H5TlaKJtczZ2cy5pQ&boolshad.hgta_printCustomTrackHeaders=0&hgta_ctName=tb_knownGene&hgta_ctDesc=table+browser+query+on+knownGene | |
...: &hgta_ctVis=pack&hgta_ctUrl=&fbQual=whole&fbUpBases=200&fbExonBases=0&fbIntronBases=0&fbDownBases=200&hgta_doGetBed=get+BED&hgta_doGalaxyQuery | |
...: =Send+query+to+Galaxy"} | |
In [5]: urllib.parse.urlencode(d) | |
Out[5]: 'tool_id=ucsc_table_direct1&URL=https%3A%2F%2Fgenome.ucsc.edu%2Fcgi-bin%2FhgTables%3Fhguid%3D1587314780_KBXslDDpain7o5EBARpPf3nJ1NbE%26db%3Dhg38%26org%3DHuman%26hgta_table%3DknownGene%26hgta_track%3DknownGene%26hgta_regionType%3Drange%26hgta_outputType%3Dbed%26position%3Dchr2%3A25%2C160%2C915-25%2C168%2C903%26hgsid%3D1708063580_QD5ONXCqxp8H5TlaKJtczZ2cy5pQ%26boolshad.hgta_printCustomTrackHeaders%3D0%26hgta_ctName%3Dtb_knownGene%26hgta_ctDesc%3Dtable%2Bbrowser%2Bquery%2Bon%2BknownGene%26hgta_ctVis%3Dpack%26hgta_ctUrl%3D%26fbQual%3Dwhole%26fbUpBases%3D200%26fbExonBases%3D0%26fbIntronBases%3D0%26fbDownBases%3D200%26hgta_doGetBed%3Dget%2BBED%26hgta_doGalaxyQuery%3DSend%2Bquery%2Bto%2BGalaxy' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment