Skip to content

Commit

Permalink
Merge pull request #26 from ZhixuNi/master
Browse files Browse the repository at this point in the history
GUI scale, pymzML 2.2.5 and other fix
  • Loading branch information
ZhixuNi authored Aug 6, 2019
2 parents 0abf9f2 + df174c0 commit cb05357
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 61 deletions.
Binary file modified ConfigurationFiles/3-Specific_ions.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion LibLipidHunter/Hunter_Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ def huntlipids(param_dct: dict, error_lst: list,
gen_html_report(param_dct, output_df, lipid_info_img_lst)
else:
print('[WARNING] !!! User skip image generation !!!!!!')

print('Time', time.clock(), start_time)
tot_run_time = time.clock() - start_time

print('[STATUS] >>> >>> >>> FINISHED in %s sec <<< <<< <<<' % tot_run_time)
Expand Down
6 changes: 4 additions & 2 deletions LibLipidHunter/IsotopeHunter.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def peak_top_checker(ms1_pr_mz, spec_df, core_count=1, ms1_precision=50e-6):
top_obs_i = 0
top_delta = 0

if pr_obs_i >= 0.75 * top_obs_i > 0:
if pr_obs_i * 1.5 >= top_obs_i > 0:
peak_top = True
# print(core_count,
# '[PASSED]MS1 PR m/z {pr} is peak top in +/- {delta} m/z, PR i {obs_i}, max i {max_i}'
Expand Down Expand Up @@ -374,7 +374,9 @@ def get_isotope_score(self, ms1_pr_mz, ms1_pr_i, formula, spec_df, core_count,
if ms1_pr_i > max_pre_m_i or pseudo_pr_check == 0:
elem_dct = self.get_elements(formula)
mono_mz = self.get_mono_mz(elem_dct)
if abs((ms1_pr_mz - mono_mz)) <= ms1_precision * ms1_pr_mz:
pr_range_top, range_top_obs_i = self.peak_top_checker(ms1_pr_mz, spec_df, core_count=core_count,
ms1_precision=ms1_precision * 2.5)
if pr_range_top and abs((ms1_pr_mz - mono_mz)) <= ms1_precision * ms1_pr_mz:
isotope_pattern_df = self.get_isotope_mz(elem_dct, only_c=only_c)
# print(isotope_pattern_df)
ms1_pr_i -= m0_base_abs
Expand Down
4 changes: 2 additions & 2 deletions LibLipidHunter/LipidHunter_Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def __init__(self, parent=None, cwd=None):
self.ui.setupUi(self, scale=scale)

# set version
version_date = r'06, March, 2019'
version_date = r'06, August, 2019'
version_html = (r'<html><head/><body><p><span style=" font-weight:600;">'
r'LipidHunter 2 (RC) # Released Date: {version_date}'
r'LipidHunter 2 (RC2) # Released Date: {version_date}'
r'</span></p></body></html>').format(version_date=version_date)
self.ui.version_lb.setText(QtGui.QApplication.translate("MainWindow", version_html, None,
QtGui.QApplication.UnicodeUTF8))
Expand Down
2 changes: 1 addition & 1 deletion LibLipidHunter/LipidHunter_UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ def setupUi(self, MainWindow, scale=1):
QtCore.QMetaObject.connectSlotsByName(MainWindow)

def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "LipidHunter 2 (RC) | University of Leipzig ", None, QtGui.QApplication.UnicodeUTF8))
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "LipidHunter 2 (RC2) | University of Leipzig ", None, QtGui.QApplication.UnicodeUTF8))
self.label_50.setText(QtGui.QApplication.translate("MainWindow", "Score weight factor settings:", None, QtGui.QApplication.UnicodeUTF8))
self.tab_a_mzml_pb.setText(QtGui.QApplication.translate("MainWindow", "Open", None, QtGui.QApplication.UnicodeUTF8))
self.label_3.setText(QtGui.QApplication.translate("MainWindow", "Select lipid class:", None, QtGui.QApplication.UnicodeUTF8))
Expand Down
21 changes: 11 additions & 10 deletions LibLipidHunter/PanelPlotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@ def plot_spectra(abbr, mz_se, xic_df, ident_info_dct, spec_info_dct, isotope_sco
obs_ident_df = ident_info_dct['IDENT']

obs_fa_df = ident_info_dct['OBS_FA']
obs_fa_df['obs_mz'] = obs_fa_df['obs_mz'].astype(float).round(4)
obs_fa_df['obs_ppm'] = obs_fa_df['obs_ppm'].astype(int).tolist()
obs_fa_df['obs_i_r'] = obs_fa_df['obs_i_r'].astype(float).round(1)
if not obs_fa_df.empty:
obs_fa_df['obs_mz'] = obs_fa_df['obs_mz'].astype(float).round(4)
obs_fa_df['obs_ppm'] = obs_fa_df['obs_ppm'].astype(int).tolist()
obs_fa_df['obs_i_r'] = obs_fa_df['obs_i_r'].astype(float).round(1)

if 'OBS_LYSO' in list(ident_info_dct.keys()):
obs_lyso_df = ident_info_dct['OBS_LYSO']
obs_lyso_df['obs_mz'] = obs_lyso_df['obs_mz'].astype(float).round(4)
obs_lyso_df['obs_ppm'] = obs_lyso_df['obs_ppm'].astype(int).tolist()
obs_lyso_df['obs_i_r'] = obs_lyso_df['obs_i_r'].astype(float).round(1)
if not obs_lyso_df.empty:
obs_lyso_df['obs_mz'] = obs_lyso_df['obs_mz'].astype(float).round(4)
obs_lyso_df['obs_ppm'] = obs_lyso_df['obs_ppm'].astype(int).tolist()
obs_lyso_df['obs_i_r'] = obs_lyso_df['obs_i_r'].astype(float).round(1)
obs_dg_na_df = obs_lyso_df.loc[obs_lyso_df['TYPE'] == 'NL_Na']
obs_dg_na_df.reset_index(drop=True, inplace=True)
obs_dg_na_idx = obs_lyso_df.index[obs_lyso_df['TYPE'] == 'NL_Na'].tolist()
Expand Down Expand Up @@ -563,6 +564,7 @@ def plot_msms():
plt.setp(base_l, visible=False)
else:
pass

if other_frag_df is not False:
marker_l, stem_l, base_l = msms_pic.stem(other_frag_df['mz'], other_frag_df['i'], markerfmt=' ',
use_line_collection=True)
Expand Down Expand Up @@ -671,16 +673,15 @@ def plot_msms_low():
else:
_fa_table2 = False
# Create the table with the Free FA fragments for TG and PL
if obs_fa_df.loc[obs_fa_df['TYPE'] == 'FA']['obs_abbr'].values.tolist():
_fa_ident_lst = obs_fa_df.loc[obs_fa_df['TYPE'] == 'FA']['obs_abbr'].values.tolist()
if _fa_ident_lst:
_fa_table_df = pd.DataFrame(
data={'#': obs_fa_df.loc[obs_fa_df['TYPE'] == 'FA']['obs_rank'].astype(int).values.tolist(),
'identification': obs_fa_df.loc[obs_fa_df['TYPE'] == 'FA']['obs_abbr'].values.tolist(),
'identification': _fa_ident_lst,
'm/z': obs_fa_df.loc[obs_fa_df['TYPE'] == 'FA']['obs_mz'].tolist(),
'ppm': obs_fa_df.loc[obs_fa_df['TYPE'] == 'FA']['obs_ppm'].tolist(),
'i (%)': obs_fa_df.loc[obs_fa_df['TYPE'] == 'FA']['obs_i_r'].tolist()})
_fa_table_df = _fa_table_df.reindex(columns=_fa_col_labels)
print('_fa_table_df')
print(_fa_table_df)
_fa_table_vals = list(map(list, _fa_table_df.values))
_fa_col_width_lst = [0.03, 0.2, 0.10, 0.06, 0.06]
# _fa_col_width_lst2 = [0.03, 0.2, 0.30, 0.26, 0.26]
Expand Down
16 changes: 13 additions & 3 deletions LibLipidHunter/SpectraReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,17 @@ def extract_mzml(mzml: str, rt_range: list, dda_top: int = 6,

print('[STATUS] >>> Start to process file: %s' % mzml)
print('[INFO] --> Processing RT: %.2f -> %.2f with DDA Top % i' % (rt_start, rt_end, dda_top))

spec_obj = pymzml.run.Reader(mzml, MS1_Precision=ms1_precision, MSn_Precision=ms2_precision)
try:
spec_obj = pymzml.run.Reader(mzml, MS1_Precision=ms1_precision, MSn_Precision=ms2_precision)
except (IOError, OSError):
try:
# Try to use the CV from mzML 4.0 released in 2016
spec_obj = pymzml.run.Reader(mzml, MS1_Precision=ms1_precision, MSn_Precision=ms2_precision,
obo_version='4.0.1')
except (IOError, OSError):
# try to use legacy version 1.1.0 to parse the mzML
spec_obj = pymzml.run.Reader(mzml, MS1_Precision=ms1_precision, MSn_Precision=ms2_precision,
obo_version='1.1.0')

spec_idx = 0
dda_event_idx = 0
Expand Down Expand Up @@ -287,7 +296,8 @@ def get_spectra(mz, mz_lib, func_id, ms2_scan_id, ms1_obs_mz_lst,
try:
ms2_df.drop('rt', axis=1, inplace=True)
except (KeyError, ValueError):
print('[ERROR] !!! MS2_df do not have rt column...')
# print('[INFO] !!! MS2_df do not have rt column...')
pass
else:
print('[WARNING] !!! MS2 spectra not in the list ...')
else:
Expand Down
53 changes: 38 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# About LipidHunter 2 #
![LipidHunter_logo](LipidHunter.png)

![Platforms](https://img.shields.io/badge/Platform-Linux%20%7C%20macOS%20%7C%20Windows-blue.svg)
[![Travis (.com) all](https://img.shields.io/travis/com/ZhixuNi/lipidhunter/master.svg)](https://travis-ci.com/SysMedOs/epiLION)
![GitHub last commit](https://img.shields.io/github/last-commit/ZhixuNi/lipidhunter.svg)
![pyup dependencies](https://pyup.io/repos/github/ZhixuNi/lipidhunter/shield.svg)
![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date-pre/SysMedOs/LipidHunter.svg)
![GitHub commits since latest release](https://img.shields.io/github/commits-since/SysMedOs/lipidhunter/LipidHunter2_RC.svg)
![total downloads](https://img.shields.io/github/downloads/SysMedOs/lipidhunter/total.svg?color=orange)
![GitHub commits since latest release](https://img.shields.io/github/commits-since/SysMedOs/lipidhunter/LipidHunter2_RC.svg)
![GitHub last commit](https://img.shields.io/github/last-commit/ZhixuNi/lipidhunter.svg)

[![Travis (.com) all](https://img.shields.io/travis/com/ZhixuNi/lipidhunter/master.svg)](https://travis-ci.com/SysMedOs/epiLION)
![Platform macOS](https://img.shields.io/badge/Platform-macOS-lightgrey.svg)
![Platform Linux](https://img.shields.io/badge/Platform-Linux-orange.svg)
![Platform Windows](https://img.shields.io/badge/Platform-Windows-blue.svg)

LipidHunter 2 has significant improvement from the original LipidHunter.
The major improvements are listed below:
Expand Down Expand Up @@ -65,12 +67,10 @@ https://github.com/SysMedOs/lipidhunter/releases

### Windows version ###

* The binary excutable version of LipidHunter 2 is provided for Windows users. (Windows 7, 8, and 10, 64bit system required)

+ [`.exe` installation file](https://github.com/SysMedOs/lipidhunter/releases/download/LipidHunter2_RC/Lipidhunter2_RC_Setup.exe)

+ [`.zip` portable zip file](https://github.com/SysMedOs/lipidhunter/releases/download/LipidHunter2_RC/LipidHunter2_RC.zip)
* The binary executable version of LipidHunter 2 is provided for Windows users. (Windows 7, 8, and 10, 64bit system required)

+ [`.exe` and `.zip` installation file](https://github.com/SysMedOs/lipidhunter/releases/latest)

### How to install LipidHunter 2 from source code ###
* Download the LipidHunter 2 as zip file for your system
+ Please use the source code page in the release page https://github.com/SysMedOs/lipidhunter/releases/
Expand All @@ -91,7 +91,7 @@ https://github.com/SysMedOs/lipidhunter/releases
- pip: activate your virtual environment, then `pip install -r requirements.txt`
+ Main dependencies are:
- Data processing: numpy, pandas, scipy, numba, natsort
- mzML reader: pymzml == 0.7.8
- mzML reader: pymzml
- Image plot: matplotlib, plotly(required by pymzml)
- Excel output: openpyxl, xlrd, xlwt
- Graphic interface: pyside
Expand All @@ -104,11 +104,34 @@ https://github.com/SysMedOs/lipidhunter/releases
* [LipidHunter user guide](doc/LipidHunter_UserGuide.pdf)


* Errors/bugs

In case you experienced any problems with running LipidHunter
### mzML File conversion ###

We recommend to use ProteoWizard version 3.0.19217 64 bit version or above to convert your raw files to mzML.
You can find the latest version of ProteoWizard from:

http://proteowizard.sourceforge.net/download.html

If you have difficulties to run your mzML file.
Please try to run your analysis again in the LipidHunter_debug.exe and post the error messages
to the [issue tracker](https://github.com/SysMedOs/lipidhunter/issues) or contact us.


### Graphic interface issue on high resolution screens ###

Please open the `config.ini` file and change `gui_scale = 1` to `gui_scale = 1.5` or `gui_scale = 2`save it
and restart LipidHunter.
If there is no `gui_scale = 1` section, you can manually add it in the end.

We recommend laptop user with high resolution screen to try the scale ratio `2` or `1.5`.
You can try to set scale factor from `0.75` (75%) to `2.75` (275%) with the step of `0.25` (25%)
to find the best value for your screen.


### Errors/bugs ###

please report an issue in the [issue tracker](https://github.com/SysMedOs/lipidhunter/issues) or contact us.
In case you experienced any problems with running LipidHunter

please report an issue in the [issue tracker](https://github.com/SysMedOs/lipidhunter/issues) or contact us.

### License ###

Expand Down
2 changes: 1 addition & 1 deletion config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ runhunter_tab = 1
lipidgen_tab = 1
default_vendor = 0
default_lipid = 0
gui_scale = 5
gui_scale = 1

52 changes: 26 additions & 26 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
ca-certificates>=2019.3.9
certifi>=2019.3.9
codecov==2.0.15
coverage==4.5.3
cython==0.29.12
idna==2.8
llvmlite==0.29.0
matplotlib==3.1.1
natsort==6.0.0
numba==0.45.0
numexpr==2.6.9
numpy==1.16.4
openpyxl==2.6.2
packaging==19.0
codecov>=2.0.15
coverage>=4.5.3
cython>=0.29.12
idna>=2.8
llvmlite>=0.29.0
matplotlib>=3.1.1
natsort>=6.0.0
numba>=0.45.0
numexpr>=2.6.9
numpy>=1.16.4
openpyxl>=2.6.2
packaging>=19.0
pandas==0.25.0
plotly==4.0.0
plotly>=4.0.0
pymzml==2.2.5
pyparsing==2.4.0
pyside>=1.2.4
pyparsing>=2.4.0
pyside==1.2.4
python>=3.6.7
pytest==5.0.1
pytest-cov==2.7.1
python-dateutil==2.8.0
pytz==2019.1
regex==2019.6.8
requests==2.22.0
scipy==1.3.0
six==1.12.0
urllib3==1.25.3
xlrd==1.2.0
xlwt==1.3.0
pytest>=5.0.1
pytest-cov>=2.7.1
python-dateutil>=2.8.0
pytz>=2019.1
regex>=2019.6.8
requests>=2.22.0
scipy.=1.3.0
six>=1.12.0
urllib3>=1.25.3
xlrd>=1.2.0
xlwt>=1.3.0

0 comments on commit cb05357

Please sign in to comment.