File size: 1,862 Bytes
70b95b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/python
# coding: utf-8

# Author: LE YUAN
# Date: 2020-06-25
# This script is to extract Kcat data from all EC files into one file.

import os
import csv
import re

outfile = open("../../Data/database/Kcat_brenda.tsv", "wt")
# with open("./Kcat_sabio.tsv", "wt") as outfile :
tsv_writer = csv.writer(outfile, delimiter="\t")
tsv_writer.writerow(["EntryID", "Type", "ECNumber", "Substrate", 'EnzymeType', "Organism","Value", "Unit"])

filenames = os.listdir('../../Data/database/Kcat_brenda')
# print(len(filenames)) # 3339 EC files

i = 0
j = 0
for filename in filenames :
    print(filename[2:-4])
    if filename != '.DS_Store' :
        with open("../../Data/database/Kcat_brenda/%s" %(filename), 'r', encoding="utf-8") as file :
            lines = file.readlines()

    for line in lines[1:] :
        data = line.strip().split('\t')
        value = float(data[2])
        desc = data[4]
        # print(desc)
        if value > 0 :  # Kcat value should not be less than 0, but there exist some weird values, less than 0.
            # print(value)
            # print(type(value))
            i += 1
            if 'mutant' in desc or 'mutated' in desc:
                # print(desc)
                mutant = re.findall('[A-Z]\d+[A-Z]', desc)  # re is of great use
                # print(mutant)
                if len(mutant) >=1 :
                    enzymeType = '/'.join(mutant)
                else :
                    continue
                    # print(desc)
                    # j += 1
                    # print(j)
                    # enzymeType = 'wildtype'
                    # print('------------------------------------------------')
            else :
                enzymeType = 'wildtype'
            tsv_writer.writerow([i, 'kcat', filename[2:-4], data[3], enzymeType, data[1], str(value), 's^(-1)'])

outfile.close()