Last active
March 6, 2018 17:47
-
-
Save cplaisier/a56fda7303ff980f55cf3df311da7a95 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| motifName2entrezId = {} | |
| entrezId2motifName = {} | |
| # humanTFs_All.csv with columns separated by commas - Motif Name,Gene Symbol,Entrez ID | |
| with open('id_conversion/humanTFs_All.csv','r') as inFile: | |
| header = inFile.readline().strip().split(',') # Capture header, get rid of white space ".strip()", and split by commas ".split(',')" | |
| while 1: | |
| inLine = inFile.readline() | |
| #Breaks out of the while loop when we hit the end of the file | |
| if not inLine: | |
| break | |
| # Build ID conversion dictionary | |
| splitUp = inLine.strip().split(',') # Get rid of white space ".strip()", and split by commas ".split(',')" | |
| # Motif name to entrez ID is mostly one to one mapping | |
| motifName2entrezId[splitUp[0]] = splitUp[2] | |
| # Entrez Id to motif name is a one to many mapping, so need to have a list under the dictionary key | |
| if not splitUp[2] in entrezId2motifName: | |
| entrezId2motifName[splitUp[2]] = [] | |
| entrezId2motifName[splitUp[2]].append(splitUp[0]) | |
| print('motifName2entrezId = '+str(len(motifName2entrezId))) | |
| print('entrezId2motifName = '+str(len(entrezId2motifName))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment