Skip to content

Commit

Permalink
Merge pull request #10 from ZhixuNi/master
Browse files Browse the repository at this point in the history
Updated UI for Linker and Converter
  • Loading branch information
ZhixuNi authored Aug 14, 2020
2 parents 0ab9849 + fb88195 commit 0be0b54
Show file tree
Hide file tree
Showing 57 changed files with 1,195 additions and 464 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: psf/black@master
34 changes: 15 additions & 19 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,20 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8]
os: [ubuntu-20.04, ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7]

name: Test Python ${{ matrix.python-version }}
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Black Code Formatter
uses: lgeiger/[email protected]
- name: Test with pytest
run: |
pip install codecov pytest pytest-cov
pytest --cov=./
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: GitHub Action for pytest
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install codecov pytest pytest-cov
pytest ./
84 changes: 45 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
# LipidLynxX

![LipidLynx_Logo](doc/images/LipidLynxX_Logo_128.jpg)
![LipidLynx_icon_Logo](doc/images/LipidLynxX_icon_128.jpg)
![LipidLynx_text_Logo](lynx/static/images/LipidLynxX_logo_color.png)

![Platforms](https://img.shields.io/badge/Platform-Linux%20%7C%20macOS%20%7C%20Windows-blue.svg?color=orange)
![total downloads](https://img.shields.io/github/downloads/SysMedOs/LipidLynxX/total.svg?color=green)
![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date-pre/SysMedOs/LipidLynxX.svg)
![total downloads](https://img.shields.io/github/downloads/SysMedOs/LipidLynxX/total.svg?color=success)
![GitHub commits since latest release](https://img.shields.io/github/commits-since/SysMedOs/LipidLynxX/v0.4.12-beta.svg?color=green)
![GitHub last commit](https://img.shields.io/github/last-commit/SysMedOs/LipidLynxX.svg)

The LipidLynxX project is aimed to provide a unified identifier for major lipids, especially oxidized lipids
in the epilipidome.

![LipidLynx_01_Home](doc/images/LipidLynxX_Start_Chromium.png)

## Try LipidLynxX simple converter demo on [`mybinder.org`](https://mybinder.org) 🆕
## Main Modules

**This demo is always updated automatically to the latest source code on the master branch.**
To preview the latest changes on the converter without dealing with source code.
- **LipidLynxX Converter**

Just click this button 👉
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ZhixuNi/LipidLynxX/develop?filepath=converter_notebook.ipynb)
- Convert different abbreviations to uniformed LipidLynxX ID

And wait a bit ☕ Binder and Jupyter Notebook will prepare LipidLynxX demo for you.
- **LipidLynxX Equalizer**

- You can paste a list of lipid abbreviations, select export style, and download the output table as `.csv` or `.xlsx`.
- Cross compare different level of LipidLynxX ID on selected level

- If you observed some IDs not converted in the Windows .exe version, try this demo to see if it got fixed.
- **LipidLynxX Linker**

- You can run the notebook named `converter_notebook.ipynb` in this repository as well.
- Link lipid abbreviations to available resources

## Important Notice
## Key Features

- Optimized for manual interpretation and computer processing
- Suitable for both unmodified lipids and modified lipids
- Unified modification controlled vocabularies
- Unified position specific annotations
- Cross level match based on shared levels
- Extract key information from LipidLynxX ID
- Strictly controlled format using JSON schema
- Easy to use Graphic User Interface
- API access for professional users
- Command line tools for professional users

### Supported lipid notation styles

The current LipidLynxX source code was tested using our collection of lipid abbreviations
for major lipid classes from following databases and programs:
Expand All @@ -47,6 +58,8 @@ for major lipid classes from following databases and programs:
- Abbreviations such as DHA, PAPE, PLPC, PONPC .etc are also included as `defined alias`.
detailed settings can be found in `lynx/configurations/defined_alias.json`

## Important Notice

**If your database / program is not included in the list above**, you can test if any of the configuration files located in `lynx/configurations/rules/input` would fit to your database / program.
If conversion is not possible, please contact us so that we can help you to generate suitable configuration file.

Expand All @@ -71,30 +84,6 @@ We kindly ask if you have any plans to use LipidLynxX API contact us first, or f
New features of LipidLynxX is generally developed using repository [https://github.com/ZhixuNi/LipidLynxX](https://github.com/ZhixuNi/LipidLynxX).


### Key Features

- Optimized for manual interpretation and computer processing
- Suitable for both unmodified lipids and modified lipids
- Unified modification controlled vocabularies
- Unified position specific annotations
- Cross level match based on shared levels
- Extract key information from LipidLynxX ID
- Strictly controlled format using JSON schema
- Easy to use Graphic User Interface
- API access for professional users
- Command line tools for professional users


### Main Modules

- **LipidLynxX Converter**

- Convert different abbreviations to uniformed LipidLynxX ID

- **LipidLynxX Equalizer**

- Cross link different level of LipidLynxX ID on selected level

## Instructions

### Sample files:
Expand All @@ -108,6 +97,23 @@ Please find our user guide in folder `doc`.
- [User Guide in PDF format](doc/LipidLynxX_UserGuide.pdf)
- [User Guide in Markdown format](doc/LipidLynxX_UserGuide.md)

## Try LipidLynxX simple converter demo on [`mybinder.org`](https://mybinder.org)

**This demo is always updated automatically to the latest source code on the master branch.**
To preview the latest changes on the converter without dealing with source code.

Just click this button 👉
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ZhixuNi/LipidLynxX/develop?filepath=converter_notebook.ipynb)

And wait a bit ☕ Binder and Jupyter Notebook will prepare LipidLynxX demo for you.

- You can paste a list of lipid abbreviations, select export style, and download the output table as `.csv` or `.xlsx`.

- If you observed some IDs not converted in the Windows .exe version, try this demo to see if it got fixed.

- You can run the notebook named `converter_notebook.ipynb` in this repository as well.


### Screenshots

- **GUI**
Expand All @@ -128,7 +134,7 @@ Please find our user guide in folder `doc`.
- **Use as Python module**
- Please check `examples_notebook.ipynb`
- You can find online interactive version via Binder
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ZhixuNi/LipidLynxX/develop?filepath=examples_notebook.ipynb)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ZhixuNi/LipidLynxX/develop?filepath=converter_notebook.ipynb)

### LipidLynxX Nomenclature

Expand Down
3 changes: 3 additions & 0 deletions doc/LipidLynxX_UserGuide.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

![LipidLynx_icon_Logo](images/LipidLynxX_icon_128.jpg)
![LipidLynx_text_Logo](images/LipidLynxX_logo_color.png)
# LipidLynxX User Guide

![LipidLynxX_Start_Chromium](images/LipidLynxX_Start_Chromium.png)
Expand Down
File renamed without changes
File renamed without changes
Binary file added doc/images/LipidLynxX_logo_color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions doc/sample_data/input/LipidLynxX_test.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ PE(O-34:2),FA22:6,"FA22:6<{4Z,7Z,10Z,13Z,16Z,19Z}>",PE(34:2),Docosahexaenoic aci
PE(P-34:2),PE(16:0_18:2),PE(16:0/18:2),PE(O-34:2),"PE(16:0/18:2(9Z,12Z))",Cer 44:0;4O,Cer 18:0;2O/26:0;O,"GPEtn(15:0/22:5(4Z,7Z,10Z,13Z,16Z))",POPC
PIP(34:1),PE(O-16:0_18:2),PE(O-16:0/18:2),PE(P-34:2),"PE(O-16:0/18:2(9Z,12Z))",Cer 44:0;4O,Cer 18:0;3O/26:0,"GPEtn(20:3(5Z,8Z,11Z)/20:3(5Z,8Z,11Z))",PAPC
PIP2(34:2),PE(P-16:0_18:2),PE(P-16:0/18:2),PIP(34:1),"PE(P-16:0/18:2(9Z,12Z))",Cer 44:0;4O,Cer 18:0;3O/26:0;(3OH),"GPIns(18:0/20:4(5E,8E,11E,14E))",DPPC
PIP3(34:2),PIP(16:0_18:1),PIP(16:0/18:1),PIP2(34:2),"CL(1'-[18:1(9Z)/18:2(9Z,12Z)],3'-[18:2(9Z,12Z)/18:2(9Z,12Z)])",Cer 44:1;3O,Cer 18:0;3O/26:0;O,"GPSer(18:0/22:6(4Z,7Z,10Z,13Z,16Z,19Z))",PLPE
PIP3(34:2),PIP(16:0_18:1),PIP(16:0/18:1),PIP2(34:2),"Cer(d18:0/26:0)",Cer 44:1;3O,Cer 18:0;3O/26:0;O,"GPSer(18:0/22:6(4Z,7Z,10Z,13Z,16Z,19Z))",PLPE
CL(72:7),PIP2(16:0_18:2),PIP2(16:0/18:2),PIP3(34:2),Cer(d18:0/26:0(3OH)),Cer 44:1;3O,Cer 18:1;2O/26:0,,POPE
PE(34:2;2),PIP3(16:0_18:2),PIP3(16:0/18:2),DG(34:2),Cer(d18:1/26:0(3OH)),Cer 44:1;3O,Cer 18:1;2O/26:0;(3OH),,PAPE
Cer(44:0;2),PE(18:2;2_16:0),PE(18:2;2/16:0),TG(52:2),Cer(t18:0/26:0),Cer 59:0;5O,Cer 18:1;2O/26:0;O,,DPPE
Cer(44:0;3),SPB18:0;2,SPB18:0;2,,SM(d18:1/26:0),Cer 44:0;2O,LPE 16:0/0:0,,
Cer(44:0;3),SPB18:1;2,SPB18:1;2,,MG(16:0),Cer 44:0;3O,LPIP 16:0/0:0,,
Cer(44:0;3),Cer(18:0;2/26:0),Cer(18:0;2/26:0),,"DG(16:0/18:2(9Z,12Z)/0:0)[iso2]",Cer 44:1;2O,PE 16:0_18:2,,
Cer(44:1;2),Cer(18:0;2/26:0;1),Cer(18:0;2/26:0;1),,DG(O-16:0/18:1(9Z)),FA 16:0,PE O-16:0_18:2,,
Cer(44:1;2),Cer(18:0;2/26:0;1),Cer(18:0;2/26:0;1),,DG(O-16:0/18:1),FA 16:0,PE O-16:0_18:2,,
Cer(44:1;3),Cer(18:0;2/26:0<OH{2}>),Cer(18:0;2/26:0<OH{2}>),,"TG(16:0/18:0/18:2(9Z,12Z))[iso6]",LPE 16:0 ,PE P-16:0_18:2,,
Cer(44:1;3),Cer(18:0;2/26:0<OH{3}>),Cer(18:0;2/26:0<OH{3}>),,TG(16:0/18:2/HETE),LPE O-18:1,PIP 16:0_18:1,,
Cer(44:1;3),Cer(18:1;2/26:0),Cer(18:1;2/26:0),,,LPE P-16:0,PIP2 16:0_18:2,,
Expand All @@ -26,7 +26,7 @@ DG(34:2),Cer(18:0;3/26:0<OH{3}>),Cer(18:0;3/26:0<OH{3}>),,,PIP3 34:2,,,
DG(O-34:2),SM(18:1;2/16:0),SM(18:1;2/16:0),,,SM 34:1;2O,,,
DG(P-34:2),MG(16:0),MG(16:0),,,SPB 18:0;2O,,,
TG(52:2),DG(16:0/18:2),DG(16:0/18:2),,,,,,
TG(O-52:2),DG(O-16:0/18:2),DG(O-16:0/18:1<{9Z}>),,,,,,
TG(O-52:2),DG(O-16:0/18:2),DG(O-16:0/18:1),,,,,,
TG(P-52:2),DG(P-16:0/18:2),DG(P-16:0/18:2),,,,,,
,TG(16:0/18:2/18:0),"TG(16:0/18:2<{9Z,12Z}>/18:0)",,,,,,
,TG(O-16:0/18:2/18:0),TG(O-16:0/18:2/18:0),,,,,,
Expand Down
2 changes: 1 addition & 1 deletion lynx/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def custom_openapi():
description=f"This is the api (V{api_version}) used in LipidLynxX (V{lynx_version})",
routes=app.routes,
)
openapi_schema["info"]["x-logo"] = {"url": "images/LipidLynxX_Logo.png"}
openapi_schema["info"]["x-logo"] = {"url": "images/LipidLynxX_icon.png"}
app.openapi_schema = openapi_schema
return app.openapi_schema

Expand Down
6 changes: 5 additions & 1 deletion lynx/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ api_version = 1.0
app_log_level = INFO
app_port = 1399
app_url = 127.0.0.1
;app_url = 0.0.0.0
cli_log_level = ERROR
controlled_vocabularies = lynx/configurations/controlled_vocabularies.json
defined_alias = lynx/configurations/defined_alias.json
input_rules = lynx/configurations/rules/input
output_rules = lynx/configurations/rules/output
resource_kegg = lynx/configurations/resources/KEGG_COMPOUND.json
resource_lion = lynx/configurations/resources/LION.json
resource_lion = lynx/configurations/resources/LION.json
temp_folder = lynx/temp
temp_max_days = 3
temp_max_files = 99
10 changes: 5 additions & 5 deletions lynx/controllers/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def convert_list(
output_dct[k].append(abbr_result.get(k, ""))
# for k in output_dct:
# output_dct[k] = [v for v in output_dct[k] if v] # remove "" or None
if 'skipped' in output_dct:
output_dct['skipped'] = [v for v in output_dct['skipped'] if v]
if 'converted' in output_dct:
output_dct['converted'] = [v for v in output_dct['converted'] if v]
if "skipped" in output_dct:
output_dct["skipped"] = [v for v in output_dct["skipped"] if v]
if "converted" in output_dct:
output_dct["converted"] = [v for v in output_dct["converted"] if v]
converted_lst_obj = ConvertedListData(
input=output_dct.get("input"),
output=output_dct.get("output"),
Expand Down Expand Up @@ -170,7 +170,7 @@ def convert_lipid(
"FACoA 18:0",
"Cer 24:2",
"LMGP01010594",
"lid"
"lid",
]
lv = "B1"
# test_out_rule = "COMP_DB"
Expand Down
8 changes: 4 additions & 4 deletions lynx/controllers/linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async def get_lmsd_id(
else:
url_safe_lipid_name = urllib.parse.quote(lipid_name, safe="")
ref_url = re.sub(r"<lipid_id>", url_safe_lipid_name, lmsd_bulk_base_url)
print(ref_url)
# print(ref_url)
async with aiohttp.request("GET", ref_url) as r_cross_ref_obj:
r_cross_ref_status = r_cross_ref_obj.status
if r_cross_ref_status == 200:
Expand Down Expand Up @@ -325,7 +325,7 @@ async def get_external_link(ref_id: str, ref_db: str, check_url: bool = False) -
if ref_base_url:
ref_url = re.sub(r"<lipid_id>", ref_id, ref_base_url)
if check_url:
print(ref_url)
# print(ref_url)
async with aiohttp.request("GET", ref_url) as r_cross_ref_obj:
r_cross_ref_status = r_cross_ref_obj.status
if r_cross_ref_status == 200:
Expand Down Expand Up @@ -359,7 +359,7 @@ async def get_cross_links(
r"\((\d{1,2}[EZ]?)(,\d{1,2}[EZ]?)+\)", "", siwss_lv_s_str
)
siwss_lv_m_str = re.sub(r"/", "_", siwss_lv_s_str)
print("SWISS_NAMES: ", swisslipids_name, siwss_lv_s_str, siwss_lv_m_str)
# print("SWISS_NAMES: ", swisslipids_name, siwss_lv_s_str, siwss_lv_m_str)
if (
lipid_name == swisslipids_name
or lipid_name == siwss_lv_s_str
Expand Down Expand Up @@ -524,7 +524,7 @@ async def link_lipids(lipid_list: List[str]) -> pd.DataFrame:
else:
resources[db] = ""
linked_info_dct[idx] = resources
print(resources)
# print(resources)

idx += 1
default_col = ["Input_name", "ShorthandNotation", "LipidLynxX", "BioPAN"]
Expand Down
4 changes: 2 additions & 2 deletions lynx/liblynx/LipidNomenclature.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ def get_smi_fa(self, abbr: str) -> str:
c_shift = 3
if c_shift * _mod_count > int(fa_info_dct["NUM_C"]) - 2:
c_shift = (
2
) # if more C=C in chain and no bis-allylic position
2 # if more C=C in chain and no bis-allylic position
)
logger.info(
"Too many C=C, try to remove bis-allylic positions"
)
Expand Down
1 change: 1 addition & 0 deletions lynx/liblynx/nomenclature.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# For more info please contact:
# Developer Zhixu Ni [email protected]


class LynxObject(object):
def __init__(self, lynx_id: str):

Expand Down
14 changes: 14 additions & 0 deletions lynx/models/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# Developer Zhixu Ni [email protected]

import json
import os

from lynx.utils.cfg_reader import app_cfg_info
from lynx.utils.params_loader import (
Expand All @@ -33,6 +34,15 @@
default_alias_file = get_abs_path(app_cfg_info["defined_alias"])
default_kegg_file = get_abs_path(app_cfg_info["resource_kegg"])
default_lion_file = get_abs_path(app_cfg_info["resource_lion"])
default_temp_folder = app_cfg_info.get("temp_folder", r"lynx/temp")
default_temp_max_days = int(app_cfg_info.get("temp_max_days", "3"))
default_temp_max_files = int(app_cfg_info.get("temp_max_files", "99"))

if os.path.isdir(default_temp_folder):
pass
else:
os.mkdir(default_temp_folder)
default_temp_folder = get_abs_path(default_temp_folder)

with open(default_cv_file, "r") as cv_js:
cv_alias_json = json.load(cv_js)
Expand All @@ -53,6 +63,10 @@
with open(default_lion_file, "r") as lion_json_obj:
lion_ids = json.load(lion_json_obj)

default_template_files = {
"LipidLynxX_Linker_Template.csv": "lynx/static/files/LipidLynxX_Linker_Template.csv"
}

lipid_level_lst = ["B", "D", "S"]
mod_level_lst = ["0", "1", "2", "3", "4", "5"]
db_level_lst = [".0", "0.1", "0.2"]
Expand Down
Loading

0 comments on commit 0be0b54

Please sign in to comment.