-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorganize_metscores.py
92 lines (75 loc) · 2.78 KB
/
organize_metscores.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python
'''
Ian Rambo
Created: February 4, 2016
Last modified: February 4, 2016
GOAL: Create new methylation score files for methylation state comparison.
'''
#==============================================================================
rootDir = "/Users/imrambo/R/ORMP/data"
metFile1 = "%s/S06-08-QuantMetMeasureData_copy.txt" % rootDir
metFile2 = "%s/S15-08-QuantMetMeasureData_copy.txt" % rootDir
outFile = "%s/MetCCGG-0615.txt" % rootDir
#==============================================================================
#outFile.write()
#Dictionary containing information for the first methylation score file
met1Dict = dict()
with open(metFile1, 'r') as met1 :
met1.readline()
for m in met1 :
m = m.rstrip()
mVars = m.split('\t')
contig = mVars[0]
metPos = mVars[33]
#Header containing taxonomic and protein annotation
taxGenHeader = '|'.join(mVars[1:33])
#Methylated score metric
GPmet = float(mVars[34])
#Non-methylated score metric
GPumt = float(mVars[35])
#Methylation score
GPscore = float(mVars[36])
localD = float(mVars[37])
solo = int(mVars[38])
metDesc = str()
if GPmet < 5.65 and GPumt < 2.00 :
metDesc = 'UNK'
elif GPmet > 5.65 and GPumt < 2.00 :
metDesc = 'MET'
elif GPmet < 5.65 and GPumt > 2.00 :
metDesc = 'UMT'
elif GPmet > 5.65 and GPumt > 2.00 :
metDesc = 'MIX'
else :
pass
met1Dict[(contig, metPos)] = dict([('contig', contig), ('header', taxGenHeader),\
('position', metPos),('GPmet',str(GPmet)),('GPumt', str(GPumt)),('GPscore', str(GPscore)),\
('localD', str(localD)),('solo', solo),('metDesc', str(metDesc))])
with open(metFile2, 'r') as met2 :
met2.readline()
for m in met2 :
m = m.rstrip()
mVars = m.split('\t')
contig = mVars[0]
metPos = mVars[33]
#Header containing taxonomic and protein annotation
taxGenHeader = '|'.join(mVars[1:33])
GPmet = float(mVars[34])
GPumt = float(mVars[35])
GPscore = float(mVars[36])
localD = float(mVars[37])
solo = mVars[38]
metDesc = str()
if GPmet < 5.65 and GPumt < 2.00 :
metDesc = 'UNK'
elif GPmet >= 5.65 and GPumt < 2.00 :
metDesc = 'MET'
elif GPmet < 5.65 and GPumt > 2.00 :
metDesc = 'UMT'
elif GPmet >= 5.65 and GPumt > 2.00 :
metDesc = 'MIX'
else :
pass
if (contig, metPos) in met1Dict :
shift = '%s:%s' % (met1Dict[(contig, metPos)]['metDesc'], metDesc)
print(shift)