Commit bcaaf637 by Gianluca LOMBARDI

Add gemme-utils bash script, update README

parent 2455b560
...@@ -16,19 +16,40 @@ gemme-utils is a collection of utilities for handling and processing data relate ...@@ -16,19 +16,40 @@ gemme-utils is a collection of utilities for handling and processing data relate
## Installation ## Installation
To install the required Python packages in a dedicated `conda` environment, run the following: After cloning the repository, install the required Python packages in a dedicated `conda` environment, running the following:
```bash ```bash
conda create -n gemme-env python=3.10 conda create -n gemme-env python=3.10
conda install biopython pandas conda install biopython pandas
``` ```
To execute the scripts from any directory, clone the repository and add it to `PATH`: Alternatively, create a virtual environment:
```bash
python -m venv gemme-venv
source gemme-venv/bin/activate
pip install biopython pandas
```
To execute the scripts from any directory, source `gemme-utils.sh` file:
```bash
. /path/to/this/directory/gemme-utils.sh
```
To ensure the script loads every time you open a terminal, add the above line at the end it to the `~/.bashrc` or `~/zshrc` file.
The command defines a new variable `GU_PATH` pointing to this directory, and a function `gemme-utils` for scripts execution. It also enables bash completion to list available scripts. Custom python scripts saved in this directory will be visible and executable as well.
Now you can call the scripts from any location with the following syntax:
```bash ```bash
export PATH="/path/to/this/directory:$PATH" gemme-utils <script.py> <arg1> ...
# Example:
cd test_data && gemme-utils prepare_alignment.py trxf2.a3m
``` ```
Before the execution, ensure that the proper python environment is active.
### PyMOL ### PyMOL
Official PyMOL software can be installed from [https://www.pymol.org/](https://www.pymol.org/) and it requires a valid license to be used. The provided bundles also include a version of Python. Official PyMOL software can be installed from [https://www.pymol.org/](https://www.pymol.org/) and it requires a valid license to be used. The provided bundles also include a version of Python.
......
# Set GU_PATH to this directory
export GU_PATH=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
# Function to execute Python scripts from GU_PATH
# Usage: gemme-utils <script.py> [args...]
gemme-utils() {
if [[ -z "$1" ]]; then
echo "Usage: gemme-utils <script.py> [args...]"
return 1
elif [[ ! -f "$GU_PATH/$1" ]]; then
echo "Error: Script '$1' not found"
return 1
fi
python3 "$GU_PATH/$1" "${@:2}"
}
# Bash Completion Function for gemme-utils
_gemme_utils_complete() {
_complete_scripts() {
local cur=${COMP_WORDS[COMP_CWORD]}
local scripts
mapfile -t scripts < <(find "$GU_PATH" -maxdepth 1 -type f -name "*.py" -exec basename {} \;)
COMPREPLY=( $(compgen -W "${scripts[*]}" -- "$cur") )
}
_complete_default() {
local script=${COMP_WORDS[1]}
local cur=${COMP_WORDS[COMP_CWORD]}
if [ -f "$GU_PATH/$script" ]; then
COMPREPLY=( $(compgen -f -- $cur) ) # Default suggestion
fi
}
if [ ${COMP_CWORD} -eq 1 ]; then
_complete_scripts
else
_complete_default
fi
}
complete -F _gemme_utils_complete gemme-utils
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment