-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
32 lines (31 loc) · 1.24 KB
/
test.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
import mysql.connector
connection = mysql.connector.connect(host="localhost",user="testuser",passwd="test123",database="TESTDB")
cursor = connection.cursor()
flag=0
#taking data from output.txt
with open("Output.txt", "r") as fd:
max=0
for line in fd:
if flag!=0:
parts = line.split()
info = parts[1]+' '+parts[2]+' '+parts[3]+' '+parts[4]+' '+parts[5]+' '+parts[6]+' '+parts[7]+' '+parts[8]+' '+parts[9]
slno = int(parts[0])
gene = parts[10]
length = int(parts[11])
a = int(parts[12])
c = int(parts[13])
g = int(parts[14])
t = int(parts[15])
if(length>max):
max=length
gc = ((g+c)/(a+t+g+c))*100
print(type(length))
sql = 'INSERT INTO gene (slno, info, gene, count_A, count_T, count_G, count_C, length, GC) VALUES ({},"{}","{}",{},{},{},{},{},{})'.format(slno, info, gene, a, t, g, c, length, gc)
#cursor.execute(sql, %(slno, info, gene, a, t, g, c, length, gc))
cursor.execute(sql)
#break
else:
flag=1
print(max)
connection.commit()
connection.close()