Created
February 3, 2015 18:42
-
-
Save cplaisier/f6b52cb6205353997531 to your computer and use it in GitHub Desktop.
makeSynoyms.py
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
| entrezIds = {} | |
| inFile = open('mart_export.txt','r') | |
| inFile.readline() # Get rid of header | |
| while 1: | |
| line = inFile.readline() | |
| if not line: | |
| break | |
| splitUp = line.strip().split(',') | |
| if not splitUp[3]=='': | |
| if not splitUp[3] in entrezIds: | |
| entrezIds[splitUp[3]] = [] | |
| entrezIds[splitUp[3]] += [i for i in splitUp if i and not entrezIds[splitUp[3]].count(i)] | |
| inFile.close() | |
| outFile = open('synonymThesaurus.csv','w') | |
| outFile.write('\n'.join([i+','+';'.join(['"'+j+'"' for j in entrezIds[i]]) for i in entrezIds])) | |
| outFile.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment