Created
June 16, 2014 23:45
-
-
Save cplaisier/2c00cc2c9cc2ed28ab67 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
| import glob | |
| # Get a list of the '.clone' files in the | |
| files = glob.glob('*.clone') | |
| # Read in expression data and put it into a dictionary | |
| matrixDictionary = {} | |
| conditions = [] | |
| for file in files: | |
| condition = file.split('.')[0] | |
| conditions.append(condition) | |
| inFile = open(file,'r') | |
| print inFile.readline().strip().split('\t')[297] # Get rid of header | |
| while 1: | |
| line = inFile.readline() | |
| if not line: | |
| break | |
| splitUp = line.strip().split('\t') | |
| if not splitUp[0] in matrixDictionary: | |
| matrixDictionary[splitUp[0]] = {} | |
| matrixDictionary[splitUp[0]][condition] = splitUp[297] | |
| inFile.close() | |
| # Turn dictionary into matrix file for import into R | |
| outFile = open('ffrpValidation.csv','w') | |
| outFile.write(','+','.join(conditions)) | |
| for locus in matrixDictionary: | |
| outFile.write('\n'+locus+','+','.join([matrixDictionary[locus][c] for c in conditions])) | |
| outFile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment