Skip to content

Commit

Permalink
added example_minimal_case.py to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mpecchi committed Jun 6, 2024
1 parent 6d6d40a commit 0e3c44c
Show file tree
Hide file tree
Showing 25 changed files with 176 additions and 130 deletions.
129 changes: 0 additions & 129 deletions example/example_minimal_case.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions examples/data_minimal_case/S_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Header]
Data File Name C:\Users\user\Documents\jla278\T1.qgd
Output Date 3/18/2024
Output Time 11:00:20 AM

[MC Peak Table]
# of Peaks 3
Mass TIC
Peak# Ret.Time Proc.From Proc.To Mass Area Height A/H Conc. Mark Name Ret. Index Area% Height% SI CAS #
1 13.703 13.580 13.900 TIC 20 20 1 0 V Capric Acid 2.59 3.01 97 108-95-2
2 20.942 20.767 21.020 TIC 200 200 1 0 V Naphthalene 8.11 9.20 98 91-20-3
3 21.426 21.373 21.500 TIC 2000 2000 1 0 V Dodecane 0.36 0.57 96 112-40-3
4 22.426 22.373 22.500 TIC 1000 1000 1 0 V NotValidComp 0.36 0.57 96 112-40-3
5 23.426 22.373 22.500 TIC 1000 100 1 0 V Palmitic Acid 0.36 0.57 96 112-40-3
6 24.426 22.373 22.500 TIC 1000 200 1 0 V Dichlorobenzene 0.36 0.57 96 112-40-3
13 changes: 13 additions & 0 deletions examples/data_minimal_case/S_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Header]
Data File Name C:\Users\user\Documents\jla278\T1.qgd
Output Date 3/18/2024
Output Time 11:00:20 AM

[MC Peak Table]
# of Peaks 3
Mass TIC
Peak# Ret.Time Proc.From Proc.To Mass Area Height A/H Conc. Mark Name Ret. Index Area% Height% SI CAS #
1 13.703 13.580 13.900 TIC 40 40 1 0 V Capric Acid 2.59 3.01 97 108-95-2
2 20.942 20.767 21.020 TIC 400 400 1 0 V Naphthalene 8.11 9.20 98 91-20-3
3 21.426 21.373 21.500 TIC 4000 4000 1 0 V Dodecane 0.36 0.57 96 112-40-3
4 24.426 26.373 21.500 TIC 1000 1000 1 0 V Almost Oleic Acid 0.36 0.57 96 112-40-3
12 changes: 12 additions & 0 deletions examples/data_minimal_case/T_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Header]
Data File Name C:\Users\user\Documents\jla278\T1.qgd
Output Date 3/18/2024
Output Time 11:00:20 AM

[MC Peak Table]
# of Peaks 3
Mass TIC
Peak# Ret.Time Proc.From Proc.To Mass Area Height A/H Conc. Mark Name Ret. Index Area% Height% SI CAS #
1 13.703 13.580 13.900 TIC 20 20 1 0 V Phenol 2.59 3.01 97 108-95-2
2 20.942 20.767 21.020 TIC 50 50 1 0 V Naphthalene 8.11 9.20 98 91-20-3
3 21.426 21.373 21.500 TIC 500 500 1 0 V Dodecane 0.36 0.57 96 112-40-3
12 changes: 12 additions & 0 deletions examples/data_minimal_case/T_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Header]
Data File Name C:\Users\user\Documents\jla278\T2.qgd
Output Date 3/18/2024
Output Time 11:00:20 AM

[MC Peak Table]
# of Peaks 3
Mass TIC
Peak# Ret.Time Proc.From Proc.To Mass Area Height A/H Conc. Mark Name Ret. Index Area% Height% SI CAS #
1 13.703 13.580 13.900 TIC 10 10 1 0 V Phenol 2.59 3.01 97 108-95-2
2 20.942 20.767 21.020 TIC 100 1000 1 0 V Naphthalene 8.11 9.20 98 91-20-3
3 21.426 21.373 21.500 TIC 1000 1000 1 0 V Dodecane 0.36 0.57 96 112-40-3
12 changes: 12 additions & 0 deletions examples/data_minimal_case/T_3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Header]
Data File Name C:\Users\user\Documents\jla278\T3.qgd
Output Date 3/18/2024
Output Time 11:00:20 AM

[MC Peak Table]
# of Peaks 3
Mass TIC
Peak# Ret.Time Proc.From Proc.To Mass Area Height A/H Conc. Mark Name Ret. Index Area% Height% SI CAS #
1 13.703 13.580 13.900 TIC 10 10 1 0 V Phenol 2.59 3.01 97 108-95-2
2 20.942 20.767 21.020 TIC 100 1000 1 0 V Naphthalene 8.11 9.20 98 91-20-3
3 21.426 21.373 21.500 TIC 1000 1000 1 0 V Dodecane 0.36 0.57 96 112-40-3
Binary file added examples/data_minimal_case/cal_minimal.xlsx
Binary file not shown.
Binary file not shown.
Binary file added examples/data_minimal_case/files_info.xlsx
Binary file not shown.
112 changes: 112 additions & 0 deletions examples/example_minimal_case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# %% Import necessary libraries
import pathlib as plib
from gcms_data_analysis.gcms import Project

folder_path: plib.Path = plib.Path(__file__).parent

folder_path = r"/Users/matteo/Projects/gcms_data_analysis/examples/data_minimal_case"

proj = Project(
folder_path=folder_path,
auto_save_to_excel=False,
compounds_to_rename_in_files={
"almost oleic acid": "oleic acid",
"dichlorobenzene": "p-dichlorobenzene",
},
)

# %%
files_info_created = proj.create_files_info(update_saved_files_info=False)
print(files_info_created.T)

files_info_loaded = proj.load_files_info(update_saved_files_info=False)
print(files_info_loaded.T)
# %%
files = proj.load_all_files()
print(files["S_1"])
# %%
class_code_frac = proj.load_class_code_frac()
print(class_code_frac)
# %%
calibrations = proj.load_calibrations()
print(calibrations["cal_minimal"])
# %%
list_of_all_compounds = proj.create_list_of_all_compounds()
print(list_of_all_compounds)
# %%
compounds_properties_created = proj.create_compounds_properties(
update_saved_files_info=True
)
compounds_properties_loaded = proj.load_compounds_properties()
print(compounds_properties_created)
# %%
dict_names_to_iupac = proj.create_dict_names_to_iupacs()
print(dict_names_to_iupac)

# %%
files_iupac, calibration_iupac = proj.add_iupac_to_files_and_calibrations()
print(files_iupac["S_1"])
print(calibration_iupac["cal_minimal"])
# %%
tanimoto_similarity_df, mol_weight_diff_df = (
proj.create_tanimoto_and_molecular_weight_similarity_dfs()
)
print(tanimoto_similarity_df)
print(mol_weight_diff_df)
# %%
semi_calibratoin_dict = proj.create_semi_calibration_dict()
print(semi_calibratoin_dict)
# %%
file1 = proj.apply_calib_to_single_file("S_1")
file2 = proj.apply_calib_to_single_file("S_2")
print(file1)
# %%
files_calibrated = proj.apply_calibration_to_files()
print(files_calibrated["S_1"])
# %%
file_info_with_stats = proj.add_stats_to_files_info()
print(file_info_with_stats)
# %%
samples_info_ave, samples_info_std = proj.create_samples_info()
print(samples_info_ave.T)
print(samples_info_std.T)
# %%
sample1_ave, sample1_std = proj.create_single_sample_from_files(
files_in_sample=[file1, file2], samplename="S"
)
# %%
samples, samples_std = proj.create_samples_from_files()
# %%
reph = proj.create_files_param_report(param="height")
print(reph)

repc = proj.create_files_param_report(param="conc_vial_mg_L")
print(repc)
# %%
repsh, repsh_d = proj.create_samples_param_report(param="height")
print(repsh)
repsc, repsc_d = proj.create_samples_param_report(param="conc_vial_mg_L")
print(repsc)
# %%
aggh = proj.create_files_param_aggrrep(param="height")
print(aggh)
# %%
aggc = proj.create_files_param_aggrrep(param="conc_vial_mg_L")

print(aggc)
# %%
aggsh, aggsh_d = proj.create_samples_param_aggrrep(param="height")
print(aggsh)
print(aggsh_d)
# %%
aggsc, aggsc_d = proj.create_samples_param_aggrrep(param="conc_vial_mg_L")

print(aggsc)
print(aggsc_d)
# %%
proj.save_files_samples_reports()
# %%

proj.plot_report()

# %%
Binary file not shown.
1 change: 0 additions & 1 deletion tests/test_project_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pandas as pd
from pandas.testing import assert_frame_equal
import numpy as np
import shutil

folder_path: plib.Path = plib.Path(__file__).parent

Expand Down

0 comments on commit 0e3c44c

Please sign in to comment.