-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add metabolites concentration from YMDB
- Loading branch information
1 parent
e1d5435
commit 3b7ae52
Showing
16,045 changed files
with
181 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
modelWithConc = importModel('../../model/yeast-GEM.xml'); | ||
data = readtable('../data/allConcData.xlsx'); | ||
data = table2cell(data); | ||
metConc.allConc = cell(length(modelWithConc.metNames), 1); | ||
metConc.maxConc = cell(length(modelWithConc.metNames), 1); | ||
metConc.minConc = cell(length(modelWithConc.metNames), 1); | ||
|
||
met.name = modelWithConc.metNames; | ||
met.kegg = {}; | ||
|
||
for i = 1:length(met.name) | ||
idx = find(strcmp('kegg.compound',modelWithConc.metMiriams{i, 1}.name)); | ||
if idx | ||
met.kegg{i, 1} = modelWithConc.metMiriams{i, 1}.value{idx, 1}; | ||
end | ||
clear idx | ||
end | ||
|
||
metWithConc = {}; | ||
for j = 2:870 | ||
keggId = data{2, j}; | ||
idx = find(strcmp(keggId, met.kegg)); | ||
if idx | ||
%fprintf(keggId) | ||
metWithConc{end+1} = keggId; | ||
for id= 1:length(idx) | ||
metConc.allConc{idx(id), 1} = data{3, j}; | ||
metConc.maxConc{idx(id), 1} = data{4, j}; | ||
metConc.minConc{idx(id), 1} = data{5, j}; | ||
end | ||
end | ||
end | ||
fprintf('In total, %d mets have concentration range.', length(metWithConc)) | ||
modelWithConc.metConc = metConc; | ||
save('../modelWithConc.mat', 'modelWithConc'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
''' | ||
@qqlaoxia 20240306 | ||
''' | ||
|
||
import argparse | ||
import requests | ||
import pandas as pd | ||
import json | ||
import os | ||
import time | ||
def extract_data(i): | ||
cmp='YMDB'+'{:05d}'.format(i) | ||
# Send an HTTP request to get the content of the web page | ||
url = r'https://www.ymdb.ca/compounds/'+cmp | ||
response = requests.get(url) | ||
web_content = response.text | ||
data = json.loads(web_content) | ||
|
||
if isinstance(data, dict): | ||
data = [data] | ||
extracted_data = [] | ||
for item in data: | ||
row_data = {key: value for key, value in item.items()} | ||
extracted_data.append(row_data) | ||
|
||
df = pd.DataFrame(extracted_data) | ||
# if not os.path.exists(cmp): | ||
# os.mkdir(cmp) | ||
# | ||
# # Save the DataFrame to an Excel file | ||
# excel_path = './%s/%s.xlsx' %(cmp,cmp) | ||
# df.to_excel(excel_path, index=False) | ||
# print(f'Data saved to {excel_path}') | ||
|
||
|
||
# % rearrange data | ||
df_transposed = df.T.reset_index() | ||
df_transposed.columns = ['Key', 'Content'] | ||
|
||
# Save the transposed DataFrame to a new Excel file | ||
transposed_excel_path = f'../data/YMDB/{cmp}_transposed.xlsx' | ||
df_transposed.to_excel(transposed_excel_path, index=False, header=True) | ||
print(f'Transposed data saved to {transposed_excel_path}') | ||
time.sleep(5) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-i', help='input number',type=int) | ||
args = parser.parse_args() | ||
extract_data(args.i) | ||
# It is suggested to used parallel arithmetic in matlab. | ||
# parfor i=1:16338 | ||
# system(['python main.py -i ',num2str(i)]); | ||
# end | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#################################################################### | ||
# get concentration | ||
# The concentration range is calculated according to the following logic | ||
# For example: In YMDB, three conc is recorded for glutamine ('17140.0 ± 1971.0 umol/L', '2500.0 ± 500.0 umol/L', '15000.0 ± 0.0 umol/L') | ||
# maximal conc: The maximum concentration plus the corresponding error. In this case, is "17140.0 + 1971.0 umol/L" | ||
# minimal conc: The minimum concentration minus the corresponding error. In this case, is "2500.0 - 500.0 umol/L" | ||
|
||
|
||
import os | ||
import numpy as np | ||
import pandas as pd | ||
import re | ||
|
||
|
||
def get_conc(rawconc): | ||
concSplit = rawconc.split('}, ') | ||
# unit: umol/L | ||
all_conc = [] | ||
# unit: mol/L | ||
maxmin = [] | ||
for c in concSplit: | ||
regex = r'\'([^\']*)\'' | ||
result = re.findall(regex, c) | ||
try: | ||
if (result[5] == 'µM') or (result[5] == 'uM') or (result[5] == 'umol/L'): | ||
all_conc.append(str(result[3] + ' ± ' + result[7] + ' umol/L')) | ||
maxmin.append((float(result[3]) - float(result[7]))*10**(-6)) | ||
maxmin.append((float(result[3]) + float(result[7]))*10**(-6)) | ||
except IndexError: | ||
pass | ||
return all_conc, maxmin | ||
|
||
# load data and put them together | ||
folder_path = r"../data/YMDB" | ||
fileName = os.listdir(folder_path) | ||
data = pd.DataFrame() | ||
for fn in fileName: | ||
file_path = os.path.join(folder_path, fn) | ||
file = pd.read_excel(file_path) | ||
id = file.iloc[0, 1] | ||
if id == 'YMDB00001': | ||
data.index = list(file.loc[:, 'Key'])[1:] | ||
else: | ||
pass | ||
data.loc[:, id] = list(file.loc[:, 'Content'])[1:] | ||
print(fn) | ||
# data.to_csv(r'../data/allConcData.csv') | ||
|
||
# compute maximal conc and minimal conc | ||
conc = pd.DataFrame(index=['conc', 'maxConc', 'minConc'], columns=data.columns) | ||
for i in range(len(data.columns)): | ||
print(i) | ||
rawconc = data.iloc[44, i] | ||
all_conc, maxmin = get_conc(rawconc) | ||
if len(all_conc) != 0: | ||
conc.loc['conc', data.columns[i]] = all_conc | ||
conc.loc['maxConc', data.columns[i]] = np.max(maxmin) | ||
conc.loc['minConc', data.columns[i]] = np.min(maxmin) | ||
else: | ||
pass | ||
|
||
data = pd.concat([data, conc], axis=0) | ||
newdata = data.loc[['name', 'chebi_id', 'kegg_id', 'conc', 'maxConc', 'minConc']] | ||
cleaned_data = newdata.dropna(axis=1, subset=['conc']) | ||
cleaned_data.to_excel('../data/allConcData.xlsx') | ||
# # test unit | ||
# | ||
# def check_unit(rawconc): | ||
# concSplit = rawconc.split('}, ') | ||
# unit = [] | ||
# try: | ||
# for c in concSplit: | ||
# regex = r'\'([^\']*)\'' | ||
# result = re.findall(regex, c) | ||
# unit.append(result[5]) | ||
# except: | ||
# pass | ||
# return unit | ||
# | ||
# all_unit= [] | ||
# for i in range(len(data.columns)): | ||
# rawconc = data.iloc[44, i] | ||
# unit = check_unit(rawconc) | ||
# for u in unit: | ||
# if u not in all_unit: | ||
# all_unit.append(u) | ||
# print(data.columns[i]) | ||
# print(u) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.