-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaffx2plink.py
executable file
·55 lines (44 loc) · 1.06 KB
/
affx2plink.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
import sys
import getopt
from os import system
def main(argv):
cmd = argv.pop(0).split('/')[-1]
help = """Usage: %s OPTIONS INPUT OUTPUT
Converts from Affymetrix format to PLINK MAP/PED file.
Example:
%s -c 1 -p 0 input output
produces output.map, output.ped
""" % (cmd,cmd)
try:
opts,args = getopt.getopt(argv, "c:p:h", ["chromosome=","phenotype=","help"])
except getopt.error,msg:
print msg
print help
return 1
chrom = ""
phen = ""
for opt,arg in opts:
if opt in ("-h","--help"):
print help
return 0
elif opt in ("-c","--chromosome"):
chrom = arg
elif opt in ("-p","--phenotype"):
phen = arg
else:
print "Unrecognized option %s %s" % (opt, arg)
print help
return 1
if chrom == "" or phen == "":
print "Chromosome and phenotype options are required"
print help
return 1
argc = len(args)
if argc != 2:
print help
return 1
input,output = args
return system("./affx2csv.py %s | ./csv2plink.py -c %s -p %s %s" % (input, chrom, phen, output))
if __name__ == '__main__':
sys.exit(main(sys.argv))