-
Notifications
You must be signed in to change notification settings - Fork 5
/
4_1_extractGeTreData.py
67 lines (58 loc) · 1.67 KB
/
4_1_extractGeTreData.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
# -*- coding:utf-8 -*-
# -----------------------------------------
# Updated Date: 2014/03/24
# Input: The file generated by analysis.r.
# Output: The data was formatted by its transcript name, gene name, normalization data and other statistical data.
# Environemt: Linux or Windows
# Description: Could generate the 'first screen' of the result on transcript level. Find out what items are
# potential for further analyses in the particular format.
# -----------------------------------------
import sys
import os
if len(sys.argv) < 3:
print "Usage: python extractGeTreData.py <cbn_Ge_tr.csv> <out_Ge_tr.csv>\n"
exit(0)
#for i in range(0,len(sys.argv),1):
# 0 file name
# 1 pass_1
# 2 pass_2
#print i,sys.argv[i]
try:
fin = open(sys.argv[1],"r")
except:
print "Error: Make sure",sys.argv[1],"exist."
exit(0)
try:
fout = open(sys.argv[2],"w")
except:
fin.close()
print "Error:",sys.argv[2]," could not be opened."
exit(0)
fout.write("transcript_name,gene_name,control_mean,transcript_mean,M,D,probability\n")
tmp = ""
data = []
geneTrans = []
flag = 0
while True:
tmp = fin.readline().strip()
if len(tmp) == 0:
break
if flag == 0:
flag = flag + 1
continue
data = tmp.split(',')
geneTrans = (data[0]).split('|')
# print data[0],geneTrans[0],geneTrans[1]
try:
# there might be some not useful data
fout.write(geneTrans[0] + "," + geneTrans[1] + ",")
for i in range(1,6,1):
fout.write(data[i])
if(i < 5):
fout.write(",")
else:
fout.write("\n")
except:
continue
fin.close()
fout.close()