renamed into English

This commit is contained in:
ralf 2024-07-11 13:48:33 +03:00
parent e6fcf23d38
commit 0824b0c4fe

View File

@ -1,84 +1,84 @@
import h5py import h5py
import os import os
import pandas as pd import pandas as pd
h5_file = 'ltcc_current.h5' h5_file = 'ltcc_current.h5'
sobiv_eid_list = [] sobiv_eid_list = []
ttx_eid_list = [] ttx_eid_list = []
teised_eid_list = [] teised_eid_list = []
with h5py.File(h5_file, 'r') as h5_file: with h5py.File(h5_file, 'r') as h5_file:
for eid in h5_file.keys(): for eid in h5_file.keys():
if 'tag' in h5_file[eid].attrs: if 'tag' in h5_file[eid].attrs:
tag_val = h5_file[eid].attrs['tag'] tag_val = h5_file[eid].attrs['tag']
if isinstance(tag_val, bytes): if isinstance(tag_val, bytes):
tag_val = tag_val.decode('utf-8') tag_val = tag_val.decode('utf-8')
puhas_eid = eid.replace(" ", "_").replace(":", "-") puhas_eid = eid.replace(" ", "_").replace(":", "-")
fit_result_eid = "fit_results_" + puhas_eid fit_result_eid = "fit_results_" + puhas_eid
if tag_val == 'iso': if tag_val == 'iso':
sobiv_eid_list.append(fit_result_eid) sobiv_eid_list.append(fit_result_eid)
elif tag_val == 'ttx': elif tag_val == 'ttx':
ttx_eid_list.append(fit_result_eid) ttx_eid_list.append(fit_result_eid)
else: else:
teised_eid_list.append(fit_result_eid) teised_eid_list.append(fit_result_eid)
file = 'ltcc_current.h5' file = 'ltcc_current.h5'
with h5py.File(file, 'r') as h5_file: with h5py.File(file, 'r') as h5_file:
for eid in h5_file.keys(): for eid in h5_file.keys():
puhastatud_eid = eid.replace(" ", "_").replace(":", "-") puhastatud_eid = eid.replace(" ", "_").replace(":", "-")
atribuudid = h5_file[eid].attrs atribuudid = h5_file[eid].attrs
sex = atribuudid.get('sex') sex = atribuudid.get('sex')
spid = atribuudid.get('spid') spid = atribuudid.get('spid')
csv_file_name = f"fit_results_{puhastatud_eid}.csv" csv_file_name = f"fit_results_{puhastatud_eid}.csv"
if os.path.exists(csv_file_name): if os.path.exists(csv_file_name):
df = pd.read_csv(csv_file_name) df = pd.read_csv(csv_file_name)
df['sex'] = sex df['sex'] = sex
df['spid'] = spid.replace("Mouse AGAT", "") df['spid'] = spid.replace("Mouse AGAT", "")
df['eid'] = eid df['eid'] = eid
df.to_csv(csv_file_name, index=False) df.to_csv(csv_file_name, index=False)
for fail in os.listdir(): for fail in os.listdir():
if fail.endswith('.csv'): if fail.endswith('.csv'):
eksperiment_id = fail.replace(".csv", "") eksperiment_id = fail.replace(".csv", "")
if eksperiment_id in sobiv_eid_list: if eksperiment_id in sobiv_eid_list:
df = pd.read_csv(fail) df = pd.read_csv(fail)
df['tag'] = 'iso' df['tag'] = 'iso'
df.to_csv(fail, index=False) df.to_csv(fail, index=False)
elif eksperiment_id in ttx_eid_list: elif eksperiment_id in ttx_eid_list:
df = pd.read_csv(fail) df = pd.read_csv(fail)
df['tag'] = 'ttx' df['tag'] = 'ttx'
df.to_csv(fail, index=False) df.to_csv(fail, index=False)
else: else:
df = pd.read_csv(fail) df = pd.read_csv(fail)
df['tag'] = 'teised' df['tag'] = 'teised'
df.to_csv(fail, index=False) df.to_csv(fail, index=False)
comb_df = pd.DataFrame() comb_df = pd.DataFrame()
for filename in os.listdir(): for filename in os.listdir():
if filename.endswith('.csv'): if filename.endswith('.csv'):
df = pd.read_csv(filename) df = pd.read_csv(filename)
if 'tag' in df.columns and df['tag'].isin(['iso', 'ttx']).all(): if 'tag' in df.columns and df['tag'].isin(['iso', 'ttx']).all():
comb_df = pd.concat([comb_df, df], ignore_index=True) comb_df = pd.concat([comb_df, df], ignore_index=True)
print(comb_df) print(comb_df)