Skip to content

Commit

Permalink
Merge pull request #80 from michaelmarty/v3
Browse files Browse the repository at this point in the history
V3
  • Loading branch information
michaelmarty authored Mar 13, 2023
2 parents 2e32ec2 + 74719cc commit 6c108d2
Show file tree
Hide file tree
Showing 24 changed files with 4,999 additions and 4,144 deletions.
20 changes: 10 additions & 10 deletions PublicScripts/DIA-PTCR/IL22/glycan_assigner_brute_force.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@
import pandas as pd
from unidec.modules.matchtools import *

# Idea do this same thing with other omics data (lipidomics, metabolomics, etc.)

# Set the directory and engine
os.chdir("D:\\Data\\Luis Genentech")
eng = engine.UniDec()

# Set and load the peak file
pfile = "20220113162114FcFusionProtein_SA15_20uScans_5500_7000mz_peaks.txt"
#pfile = "20220113144226FcFusionProtein_SA8_20uScans_peaks.txt"
#pfile = "211029_Wendy_Isle22FC_4_warmup_PTR2_peaks.txt"
# pfile = "20220113144226FcFusionProtein_SA8_20uScans_peaks.txt"
# pfile = "211029_Wendy_Isle22FC_4_warmup_PTR2_peaks.txt"
eng.load_peaks(pfile)

# Set and load the glycan file
#gfile = "SA15_Trypsin_glycan_list_abridged.csv"
#gfile = "IL22_SA8_tryp_glycan_list_abridged.csv"
#gfile = "IL22_SA4_tryp_glycan_list_abridged.csv"
#gfile = "IL22_Tryp\\IL22_SA4_tryp_glycan_list_4thsite.csv"
#gfile = "IL22_Tryp\\IL22_SA8_tryp_glycan_list_4thsite.csv"
# gfile = "SA15_Trypsin_glycan_list_abridged.csv"
# gfile = "IL22_SA8_tryp_glycan_list_abridged.csv"
# gfile = "IL22_SA4_tryp_glycan_list_abridged.csv"
# gfile = "IL22_Tryp\\IL22_SA4_tryp_glycan_list_4thsite.csv"
# gfile = "IL22_Tryp\\IL22_SA8_tryp_glycan_list_4thsite.csv"
gfile = "IL22_Tryp\\IL22_SA15_tryp_glycan_list_4thsite.csv"
gdf = pd.read_csv(gfile)
print(gdf.keys())
Expand All @@ -35,7 +36,7 @@
sites = ["S1", "S1", "S2", "S2", "S3", "S3", "S4", "S4"]

st = time.perf_counter()
probs_cutoff=1
probs_cutoff = 1
# Brute force calculate all possible combinations of glycans in the list
indexes, masses, probs, glycans = get_sitematch_list(gdf, sites=sites, probs_cutoff=probs_cutoff)

Expand All @@ -50,9 +51,8 @@
plt.savefig(gfile[:-4]+"TheoreticalMassBruteForce"+str(probs_cutoff)+".pdf")
plt.show()'''


# Open the output file
outfile = gfile[:-4] + "_matches_brute_force"+str(probs_cutoff)+".xlsx"
outfile = gfile[:-4] + "_matches_brute_force" + str(probs_cutoff) + ".xlsx"
with pd.ExcelWriter(outfile) as writer:
# Loop through all peaks
for mass in eng.pks.masses:
Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rem build docker and commit
rem build wheel, test, and commit
rem python -m build -o .\distpypi
rem python -m twine upload --repository testpypi .\distpypi\* --config-file .pypirc (check that old wheels are deleted)
rem update docs with .\unidec_docs\make.bat html
rem update docs with .\unidec_doc\make.bat html
rem paste docs into UniDecDocumentation and push to git

echo "Building"
Expand Down
20 changes: 19 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,27 @@ Of course, using the pre-compiled version means you don't need to know Python at

## Change Log

v.6.0.1

*Added Noise Removal Tool* to UniDec and UniDecCD. This allows you to select specific noise regions (common in UHMR data) and set them to 0. Try Tools > Select Noise Peaks and the checking "Remove Noise Peaks" in the Advanced Data Processing Parameters.

UPP Changes:
* Added "Config m/z Peak FWHM", "Config m/z Peak Shape", and "Config Sample Mass Every" parameters. If "Config m/z Peak FWHM" is specified as a float or integer, it will use that and skip the automatic peak width determination.
* Enabled relative paths.
* Added "All" or "None" keywords on "Apply Fixed Mods" and "Disulfides Oxidized."
* Added "Config File" keyword to load a specific config file.
* More tolerant of nans and different file extensions
* Added ability to select files to load to UPP.
* Added "Global Fixed Mod" to apply the same float value to each pair.
* Special Bispecific Antibody Pairing Calculations (see Help File)
* Fixex issues bugs with use_converted, clear all, and resetting the config.

Fixed major bugs with 2D zooming and plotting.

v.6.0.0

Major changes to code structure to enable PyPI distribution. Changed to more conventional Python package structure with unidec top directory. Renamed unidec_modules to modeuls, unidec_src to src, and unidec_bin to bin. Renamed some top level windows and moved all to main folder. For example, unidectools.py has been moved from modules to the top level and renamed as tools.py, and unidec.py has been renamed as engine.py.
Major changes to code structure to enable PyPI distribution. Changed to more conventional Python package structure with unidec top directory. Renamed unidec_modules to modules, unidec_src to src, and unidec_bin to bin. Renamed some top level windows and moved all to main folder. For example, unidectools.py has been moved from modules to the top level and renamed as tools.py, and unidec.py has been renamed as engine.py. The good news is that you can now do `pip install unidec` and `python -m unidec.Launcher` to run UniDec from the command line.


Improved command line tools. Added -o option for file output in unidec. Included new entry points and smoothed out command line interface. Now you can use unidec to lanuch python -m unidec in the scripts folder. Similarly, gunidec will launch python -m unidec.Launcher. If you have Python and the scripts folder configured in your system path, command line tools will be much easier to use.

Expand Down
2 changes: 1 addition & 1 deletion unidec/Launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __init__(self, parent):
button7 = wx.Button(panel, -1, "UltraMeta Data Collector\n\nVisualize Multiple HDF5 Data Sets\nFit Trends")
button8 = wx.Button(panel, -1, "UniChrom\n\nDeconvolution of Chromatograms\nUniDec for LC/MS Data")
button9 = wx.Button(panel, -1, "UniDecCD\n\nDeconvolution of Charge Detection MS\nUniDec for CD-MS Data")
button10 = wx.Button(panel, -1, "UPP\n\nUniDec Pharama Pipeline\nBatch Processing Workflow")
button10 = wx.Button(panel, -1, "UPP\n\nUniDec Processing Pipeline\nBatch Processing Workflow")
html = wx.html.HtmlWindow(panel, -1, size=(390, 310))
pathtofile = os.path.dirname(os.path.abspath(__file__))
self.imagepath = self.eng.config.toplogofile
Expand Down
66 changes: 62 additions & 4 deletions unidec/UPP.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ def __init__(self, nrows=2, ncolumns=2, title="UniDec Processing Pipeline"):
# Save File Menu
save_file_menu_item = menu.Append(wx.ID_ANY, "Save File", "Save a CSV or Excel file")
self.Bind(wx.EVT_MENU, self.on_save_file, save_file_menu_item)
menu.AppendSeparator()

# Add Files Menu
add_files_menu_item = menu.Append(wx.ID_ANY, "Add Data Files", "Add Data Files")
self.Bind(wx.EVT_MENU, self.on_add_files, add_files_menu_item)

# Clear everything on the panel
clear_everything_menu_item = menu.Append(wx.ID_ANY, "Clear All", "Clear Everything")
self.Bind(wx.EVT_MENU, self.clear_all, clear_everything_menu_item)

help_menu = wx.Menu()
# Open File Menu
Expand Down Expand Up @@ -315,9 +324,16 @@ def on_run_selected(self, event=None, rows=None):
if not self.hide_col_flag:
self.on_hide_columns()

def clear_all(self, event=None):
self.ss.delete_all()
self.ss.set_col_headers(["Sample name", "Data Directory"])

def load_file(self, filename):
print("Loading File:", filename)
self.ss.delete_all()
try:
self.ss.delete_all()
except Exception:
pass
self.bpeng.top_dir = os.path.dirname(filename)
df = file_to_df(filename)
self.ss.set_df(df)
Expand Down Expand Up @@ -405,6 +421,46 @@ def open_unidec(self, row):
app.after_pick_peaks()
app.start()

def on_add_files(self, event=None):

wildcard = "CSV or Excel files (*.csv; *.xlsx; *.xls)|*.csv; *.xlsx; *.xls|CSV files (*.csv)|*.csv|Excel files (*.xlsx; *.xls)|*.xlsx; *.xls"
wildcard = "Any files (*.*) |*.*| " \
"Known file types (*.raw; *.d; *.mzML; *.mzXML; *.txt; *.csv; *.dat; *.npz)|" \
"*.raw; *.d; *.mzML; *.mzXML; *.txt; *.csv; *.dat; *.npz|" \
"Thermo RAW files (*.raw)|*.raw|" \
"Agilent D files (*.d)|*.d|" \
"mzML files (*.mzML)|*.mzML|" \
"mzXML files (*.mzXML)|*.mzXML|" \
"Text files (*.txt)|*.txt|" \
"CSV files (*.csv)|*.csv|" \
"Dat files (*.dat)|*.dat|" \
"NPZ files (*.npz)|*.npz"

# Create a file selection dialog
with wx.FileDialog(self, "Select Files to Add",
wildcard=wildcard,
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE) as fileDialog:
# Show the dialog and retrieve the user response. If it is the OK response,
# process the data.

if fileDialog.ShowModal() == wx.ID_CANCEL:
return
# Proceed loading the file chosen by the user
paths = fileDialog.GetPaths()
self.add_files(paths)

def add_files(self, paths):
print("Adding Files:", paths)
self.get_from_gui()
# Add paths list to the datafram in the "Sample name" column
sample_names = [os.path.basename(path) for path in paths]
data_dir = [os.path.dirname(path) for path in paths]
newdf = pd.DataFrame({"Sample name": sample_names, "Data Directory": data_dir})
self.bpeng.rundf = pd.concat([self.bpeng.rundf, newdf], ignore_index=True)

self.ss.set_df(self.bpeng.rundf)
self.reset_hidden_columns()

def on_hide_columns(self, event=None, reset=False):
columns_to_hide = ["Tolerance", "File", "Time", "Config", "Sequence", "Directory", "Matches"]
if not self.hide_col_flag and not reset:
Expand Down Expand Up @@ -457,17 +513,19 @@ def on_exit(self, event=None):
if __name__ == "__main__":
app = wx.App()
frame = UPPApp()
frame.usedeconbox.SetValue(False)
frame.usedeconbox.SetValue(True)
path = "C:\\Data\\Wilson_Genentech\\sequences_short.xlsx"
path = "C:\\Data\\Wilson_Genentech\\BsAb\\BsAb test short.xlsx"

# frame.on_help_page()
# exit()
if True:
if False:
frame.load_file(path)
# frame.set_dir_tet_box("C:\\Data\\Wilson_Genentech\\Data")
# print(df)
frame.on_run()
# frame.on_run()
# frame.on_run_selected(rows=[1])
# frame.on_run_selected(rows=[0])
# frame.on_add_files()

app.MainLoop()
Loading

0 comments on commit 6c108d2

Please sign in to comment.