Created
June 27, 2014 15:36
-
-
Save dandanxu/01bf95544de4d5fe5f58 to your computer and use it in GitHub Desktop.
This script takes sequenom data and makes plink files
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
print '\nBuongiorno\n' | |
print "WELCOME! This script will take sequenom data and make plink files" | |
resultsFile = open("mappedSeqResults.txt", "r") | |
resultsMatrix = [[0 for col in range(0)] for row in range(0)] | |
for line in resultsFile: | |
inputInfo = line.split() | |
resultsMatrix.append(inputInfo) | |
##################################################################### | |
mapFile = open("sample.map", "r") | |
mapMatrix = [[0 for col in range(0)] for row in range(0)] | |
mapList = [] | |
n = 0 | |
for line in mapFile: | |
inputInfo = line.split() | |
mapMatrix.append(inputInfo) | |
n = n+1 | |
for line in mapMatrix: mapList.append(line[1]) | |
print n | |
##################################################################### | |
samplesFile = open("sample.list", "r") | |
samplesList = [] | |
for line in samplesFile: | |
sampleInfo = line.split() # get rid of weird formatting | |
samplesList.append(sampleInfo[0]) | |
##################################################################### | |
pedMatrix = [[0 for col in range(0)] for row in range(0)] | |
count = 0 | |
for samplesLine in samplesList: | |
pedLine = ["00"] * (n+6) | |
pedLine[0] = samplesLine | |
pedLine[1] = samplesLine | |
pedLine[2] = 0 | |
pedLine[3] = 0 | |
pedLine[4] = 1 | |
pedLine[5] = 0 | |
for resultsLine in resultsMatrix: | |
if resultsLine[0] == pedLine[0]: | |
for mapLine in mapList: | |
if resultsLine[2] == mapLine: | |
mapIndex = mapList.index(resultsLine[2]) + 6 | |
pedLine[mapIndex] = resultsLine[1] | |
pedMatrix.append(pedLine) | |
##################################################################### | |
outputFile = "sample.ped" | |
output = open(outputFile,"w") | |
for line in pedMatrix: | |
for item in line: | |
if isinstance(item,str): | |
if len(item) == 2: output.write(item[0]+"\t"+item[1]+"\t") | |
else: output.write(str(item)+"\t") | |
else: output.write(str(item)+"\t") | |
output.write("\n") | |
#for line in pedMatrix: | |
# output.write(line[0]+"\t"+line[1]+"\t"+line[2]+"\n") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment