-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsubsetSnps.py
More file actions
executable file
·47 lines (42 loc) · 842 Bytes
/
subsetSnps.py
File metadata and controls
executable file
·47 lines (42 loc) · 842 Bytes
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
#!/usr/bin/python
import sys
print("Usage: ",sys.argv[0], " SubsetFile StructureFile")
print(sys.argv[1])
#Get loci to keep
loci = []
with open(sys.argv[1]) as file_object:
count = 0
for line in file_object:
if count == 0:
count += 1
continue
line = line.strip()
t = line.split()
loc = t[0].replace("\"","")
loci.append(int(loc))
file_object.close()
output = open("out.str", "w")
with open(sys.argv[2]) as file_2:
for line in file_2:
line = line.strip()
t = line.split()
#print("Line: ", t[0])
col = 0
snp = 0
for c in t:
if col in (0,1):
#print(c)
if col == 0:
output.write(c)
else:
stuff = "\t" + c
output.write(stuff)
col += 1
else:
snp += 1
if snp in loci:
#print(snp)
stuff = "\t" + c
output.write(stuff)
output.write("\n")
output.close()