-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtract_nonWhite_related_geno.py
More file actions
58 lines (46 loc) · 1.31 KB
/
Copy pathExtract_nonWhite_related_geno.py
File metadata and controls
58 lines (46 loc) · 1.31 KB
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
56
57
58
#!/usr/bin/python
import os, sys
'''
Script that takes two files: 1. reduced genotype
2.all genotypes
and extract the genotypes from file2 that were not found in file1
python compare_allele_to_existing_tabix.py /path/to/reduced_file /path/to/all_genotypes /path/to/output/file
'''
reduced_file = str(sys.argv[1])
allgeno_file = str(sys.argv[2])
resultfile = str(sys.argv[3])
infile = open(reduced_file, 'r')
infiletwo = open(allgeno_file, 'r')
outfile = open(resultfile, 'w')
'''
read file 1, store into an array
'''
lin = infile.readline()
line = lin.strip().split("\t")
allgeno = infiletwo.readline()
allgen = allgeno.strip().split("\t")
'''
for each element in the second file
'''
counter = 0
for j in range(0, len(allgen)):
'''
compare it to each element of the first file
'''
'''
counter that will determine if a genotype was found or not
'''
found = 0
for i in range(0, len(line)):
if line[i]==allgen[j]:
found = 1
'''
check if the genotype was found if the reduced dataset, if not found, copy it to the result file
'''
if found == 0:
counter = counter +1
outfile.write(allgen[j] + "\t")
print "Number of genotypes excluded is: " + str(counter)
infile.close()
infiletwo.close()
outfile.close()