From 3c7d9a4cc26113baf1f82dac5bb1ecec42ba914a Mon Sep 17 00:00:00 2001 From: Minniti Julien Date: Fri, 13 Dec 2024 11:27:15 +0100 Subject: [PATCH 1/3] TFinder_standalone_win.bat --- TFinder_standalone_win.bat | 102 +++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 TFinder_standalone_win.bat diff --git a/TFinder_standalone_win.bat b/TFinder_standalone_win.bat new file mode 100644 index 00000000..2e2b66e7 --- /dev/null +++ b/TFinder_standalone_win.bat @@ -0,0 +1,102 @@ +@echo off +:: Colors +for /f "delims=" %%i in ('echo prompt $E^|cmd') do set "ESC=%%i" +set "COLOR_RESET=%ESC%[0m" +set "COLOR_GREEN=%ESC%[32m" +set "COLOR_RED=%ESC%[31m" +set "COLOR_YELLOW=%ESC%[33m" +set "COLOR_BLUE=%ESC%[34m" +set "COLOR_CYAN=%ESC%[36m" +set "COLOR_BOLD=%ESC%[1m" + +:: Welcome +echo %COLOR_GREEN%======================================================================================================%COLOR_RESET% +echo %COLOR_GREEN%!%COLOR_RESET% %COLOR_BOLD%%COLOR_BLUE%Welcome to TFinder%COLOR_RESET% %COLOR_GREEN%!%COLOR_RESET% +echo %COLOR_GREEN%======================================================================================================%COLOR_RESET% +echo %COLOR_CYAN%TFinder%COLOR_RESET% is a %COLOR_BOLD%%COLOR_GREEN%Python easy-to-use web tool%COLOR_RESET% for identifying Transcription Factor Binding Sites (TFBS) and +echo Individual Motif (IM). Using the %COLOR_BOLD%NCBI API%COLOR_RESET%, it can easily extract either the promoter or terminal regions of a gene +echo through a simple query of NCBI gene name or ID. It enables simultaneous analysis across five different species +echo for an unlimited number of genes. The tool searches for TFBS and IM in different formats, including IUPAC codes +echo and JASPAR entries. Moreover, %COLOR_CYAN%TFinder%COLOR_RESET% also allows the generation and use of a %COLOR_BOLD%Position Weight Matrix (PWM)%COLOR_RESET%. +echo Finally, the data may be recovered in a tabular form and a graph showing the relevance of the TFBSs and IMs as +echo well as its location relative to the Transcription Start Site (TSS) or gene end. The results may be sent by email +echo to the user facilitating the ulterior analysis and data sharing. +echo %COLOR_GREEN%======================================================================================================%COLOR_RESET% +echo %COLOR_YELLOW%Created by Minniti Julien%COLOR_RESET% - %COLOR_BLUE%GitHub(%COLOR_RESET%https://github.com/Jumitti/TFinder%COLOR_BLUE%)%COLOR_RESET% +echo %COLOR_YELLOW%MIT Licence%COLOR_RESET% - %COLOR_BLUE%https://github.com/Jumitti/TFinder/blob/main/LICENSE%COLOR_RESET% +echo %COLOR_GREEN%======================================================================================================%COLOR_RESET% + +:: Check if Python 3.11.9 is installed +echo %COLOR_CYAN%Checking for Python 3.11.9 installation...%COLOR_RESET% +python --version | find "3.11.9" >nul 2>&1 +if %errorlevel% neq 0 ( + echo %COLOR_YELLOW%Python 3.11.9 is not installed.%COLOR_RESET% + echo %COLOR_CYAN%Downloading and installing Python 3.11.9...%COLOR_RESET% + + :: Download the Python 3.11.9 installer (Windows x64) + powershell -Command "Invoke-WebRequest -Uri https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe -OutFile python-3.11.9-amd64.exe" + if exist python-3.11.9-amd64.exe ( + echo %COLOR_CYAN%Running Python installer...(may be long)%COLOR_RESET% + start /wait python-3.11.9-amd64.exe /quiet InstallAllUsers=1 PrependPath=1 + del python-3.11.9-amd64.exe + ) else ( + echo %COLOR_RED%Failed to download Python installer. Check your internet connection.%COLOR_RESET% + pause + exit /b + ) + + :: Check again if Python 3.11.9 is installed + python --version | find "3.11.9" >nul 2>&1 + if %errorlevel% neq 0 ( + echo %COLOR_RED%Python 3.11.9 installation failed. Please install it manually.%COLOR_RESET% + pause + exit /b + ) + echo %COLOR_GREEN%Python 3.11.9 installed successfully! %COLOR_RESET% +) + +:: Virtual environment creation +if not exist ".venv" ( + echo %COLOR_CYAN%Creating Python 3.11.9 virtual environment...%COLOR_RESET% + python -m venv .venv + if %errorlevel% neq 0 ( + echo %COLOR_RED%Failed to create the virtual environment. Ensure Python 3.11.9 is installed.%COLOR_RESET% + pause + exit /b + ) + echo %COLOR_GREEN%Virtual environment created successfully! %COLOR_RESET% +) + +:: Activation venv +echo %COLOR_CYAN%Activating virtual environment...%COLOR_RESET% +call .venv\Scripts\activate +if %errorlevel% neq 0 ( + echo %COLOR_RED%Failed to activate the virtual environment.%COLOR_RESET% + pause + exit /b +) +echo %COLOR_GREEN%Virtual environment activated successfully! %COLOR_RESET% + +:: Updating pip and installing dependencies +echo %COLOR_CYAN%Installing/updating Python packages...%COLOR_RESET% +pip install --upgrade pip +pip install -r requirements.txt +if %errorlevel% neq 0 ( + echo %COLOR_RED%Failed to install required packages. Check the requirements.txt file.%COLOR_RESET% + pause + exit /b +) +echo %COLOR_GREEN%Python packages installed successfully! %COLOR_RESET% + +:: Run Streamlit/TFinder +echo %COLOR_CYAN%Launching the TFinder Streamlit app... (CTRL + C to shutdown)%COLOR_RESET% +streamlit run TFinder-v1.py +if %errorlevel% neq 0 ( + echo %COLOR_RED%Failed to launch the Streamlit app. Check your script for errors.%COLOR_RESET% + pause + exit /b +) + +:: Disabling venv on shutdown +deactivate +pause \ No newline at end of file From 874f38119c78a9f58cb22e2faf02f579dfa33895 Mon Sep 17 00:00:00 2001 From: Minniti Julien Date: Fri, 13 Dec 2024 16:57:07 +0100 Subject: [PATCH 2/3] TFinder_standalone_win.bat --- TFinder_standalone_win.bat | 80 ++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/TFinder_standalone_win.bat b/TFinder_standalone_win.bat index 2e2b66e7..40b260ef 100644 --- a/TFinder_standalone_win.bat +++ b/TFinder_standalone_win.bat @@ -26,35 +26,56 @@ echo %COLOR_YELLOW%Created by Minniti Julien%COLOR_RESET% - %COLOR_BLUE%GitHub(% echo %COLOR_YELLOW%MIT Licence%COLOR_RESET% - %COLOR_BLUE%https://github.com/Jumitti/TFinder/blob/main/LICENSE%COLOR_RESET% echo %COLOR_GREEN%======================================================================================================%COLOR_RESET% -:: Check if Python 3.11.9 is installed -echo %COLOR_CYAN%Checking for Python 3.11.9 installation...%COLOR_RESET% -python --version | find "3.11.9" >nul 2>&1 -if %errorlevel% neq 0 ( - echo %COLOR_YELLOW%Python 3.11.9 is not installed.%COLOR_RESET% - echo %COLOR_CYAN%Downloading and installing Python 3.11.9...%COLOR_RESET% +:: Check if Python >= 3.10 is installed +echo %COLOR_CYAN%Checking for Python version higher or equal to 3.10...%COLOR_RESET% +for /f "usebackq tokens=2 delims= " %%v in (`python --version`) do set PYTHON_VERSION=%%v - :: Download the Python 3.11.9 installer (Windows x64) - powershell -Command "Invoke-WebRequest -Uri https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe -OutFile python-3.11.9-amd64.exe" - if exist python-3.11.9-amd64.exe ( - echo %COLOR_CYAN%Running Python installer...(may be long)%COLOR_RESET% - start /wait python-3.11.9-amd64.exe /quiet InstallAllUsers=1 PrependPath=1 - del python-3.11.9-amd64.exe - ) else ( - echo %COLOR_RED%Failed to download Python installer. Check your internet connection.%COLOR_RESET% - pause - exit /b - ) - - :: Check again if Python 3.11.9 is installed - python --version | find "3.11.9" >nul 2>&1 - if %errorlevel% neq 0 ( - echo %COLOR_RED%Python 3.11.9 installation failed. Please install it manually.%COLOR_RESET% - pause - exit /b - ) - echo %COLOR_GREEN%Python 3.11.9 installed successfully! %COLOR_RESET% +:: Extract major and minor version numbers +for /f "tokens=1,2 delims=." %%a in ("%PYTHON_VERSION%") do ( + set MAJOR=%%a + set MINOR=%%b +) + +:: Check if version is >= 3.10 +if not defined MAJOR ( + echo %COLOR_RED%Python is not installed.%COLOR_RESET% + goto install_python +) + +if %MAJOR% lss 3 ( + echo %COLOR_RED%Python version is less than 3.10.%COLOR_RESET% + goto install_python +) else if %MAJOR% equ 3 if %MINOR% lss 10 ( + echo %COLOR_RED%Python version is less than 3.10.%COLOR_RESET% + goto install_python +) + +echo %COLOR_GREEN%Python version %PYTHON_VERSION% is sufficient.%COLOR_RESET% +goto continue + +:install_python +echo %COLOR_YELLOW%Installing Python 3.11.9 from https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe...%COLOR_RESET% +powershell -Command "Invoke-WebRequest -Uri https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe -OutFile \"python-3.11.9-amd64.exe\"" +if exist "python-3.11.9-amd64.exe" ( + echo %COLOR_CYAN%Running Python installer...%COLOR_RESET% + start /wait "python-3.11.9-amd64.exe" /quiet InstallAllUsers=1 PrependPath=1 + del "python-3.11.9-amd64.exe" +) else ( + echo %COLOR_RED%Failed to download Python installer. Check your internet connection.%COLOR_RESET% + pause + exit /b +) + +:: Verify the new installation +python --version | findstr /r "3\.[1-9][0-9]*" >nul 2>&1 +if %errorlevel% neq 0 ( + echo %COLOR_RED%Python installation failed. Please install it manually by downloading on https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe.%COLOR_RESET% + pause + exit /b ) +echo %COLOR_GREEN%Python 3.11.9 installed successfully! %COLOR_RESET% +:continue :: Virtual environment creation if not exist ".venv" ( echo %COLOR_CYAN%Creating Python 3.11.9 virtual environment...%COLOR_RESET% @@ -64,8 +85,8 @@ if not exist ".venv" ( pause exit /b ) - echo %COLOR_GREEN%Virtual environment created successfully! %COLOR_RESET% ) +echo %COLOR_GREEN%Virtual environment created successfully! %COLOR_RESET% :: Activation venv echo %COLOR_CYAN%Activating virtual environment...%COLOR_RESET% @@ -79,8 +100,7 @@ echo %COLOR_GREEN%Virtual environment activated successfully! %COLOR_RESET% :: Updating pip and installing dependencies echo %COLOR_CYAN%Installing/updating Python packages...%COLOR_RESET% -pip install --upgrade pip -pip install -r requirements.txt +pip install -r requirements.txt --verbose if %errorlevel% neq 0 ( echo %COLOR_RED%Failed to install required packages. Check the requirements.txt file.%COLOR_RESET% pause @@ -89,7 +109,7 @@ if %errorlevel% neq 0 ( echo %COLOR_GREEN%Python packages installed successfully! %COLOR_RESET% :: Run Streamlit/TFinder -echo %COLOR_CYAN%Launching the TFinder Streamlit app... (CTRL + C to shutdown)%COLOR_RESET% +echo %COLOR_CYAN%Launching the TFinder Streamlit app... (CTRL + C to shutdown) %COLOR_RESET% streamlit run TFinder-v1.py if %errorlevel% neq 0 ( echo %COLOR_RED%Failed to launch the Streamlit app. Check your script for errors.%COLOR_RESET% From d8d41efd9b5f3e7a50456ebd17d298427c3aa6ed Mon Sep 17 00:00:00 2001 From: Jumitti Date: Sun, 15 Dec 2024 21:19:36 +0100 Subject: [PATCH 3/3] Remove print Platform for Streamlit --- TFinder-v1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TFinder-v1.py b/TFinder-v1.py index 9b74c77c..2381c7be 100644 --- a/TFinder-v1.py +++ b/TFinder-v1.py @@ -130,10 +130,11 @@ def load_lottiefile(filepath: str): if 'LOCAL' not in st.session_state: local_test = platform.processor() - print("Platform:", local_test) + if local_test == "": st.session_state["LOCAL"] = 'False' else: + print("Platform:", local_test) st.session_state["LOCAL"] = 'True' if st.session_state["LOCAL"] == 'False':