Skip to content

Commit

Permalink
Merge pull request #3 from frapercan/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
frapercan authored Jan 10, 2025
2 parents cbaf5d9 + e1328ce commit 497e566
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 19 deletions.
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ RUN python3 -m venv /opt/venv

# Activate the virtual environment and install Python packages
RUN /opt/venv/bin/pip install --upgrade pip \
&& /opt/venv/bin/pip install protein-metamorphisms-is --no-cache-dir
&& /opt/venv/bin/pip install fantasia --no-cache-dir


# Add the virtual environment to the PATH
ENV PATH="/opt/venv/bin:$PATH"

# Copy application files and set the working directory
COPY . /app
WORKDIR /app

# Default command to keep the container running
ENTRYPOINT ["python3", "-m", "FANTASIA.main"]
ENTRYPOINT ["python3", "-m", "fantasia.main"]

2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services:
- fantasia-network
volumes:
- $HOME/fantasia:/root/fantasia # Sincroniza /home/xaxi/fantasia con /root/fantasia en el contenedor
- $HOME/.cache/huggingface:/root/.cache/huggingface # Monta la caché de Hugging Face en el contenedor




Expand Down
8 changes: 4 additions & 4 deletions fantasia/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DB_HOST: pgvectorsql
DB_PORT: 5432
DB_NAME: BioData

rabbitmq_host: localhost
rabbitmq_host: rabbitmq
rabbitmq_user: guest
rabbitmq_password: guest

Expand All @@ -24,15 +24,15 @@ fantasia_output_csv: ~/fantasia/results/
redundancy_file: ~/fantasia/redundancy/output.fasta

fantasia_prefix: finger_zinc
max_distance: 1.1
max_distance: 0.5
length_filter: 5000
redundancy_filter: 0.65

embedding:
types:
- 1 # ESM
- 2 # Prost
- 3 # Prot
# - 3 # Prot
batch_size: 50 # Queue

embedding_batch_size: 10 # Model input size
Expand All @@ -41,6 +41,6 @@ topgo?: True



constants: "./fantasia/constants.yaml"
constants: "./opt/venv/lib/python3.12/site-packages/fantasia/constants.yaml"


34 changes: 24 additions & 10 deletions fantasia/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@ def initialize(config_path):
load_dump_to_db(tar_path, conf)


def run_pipeline(config_path, fasta_path=None):
# Leer la configuración
conf = read_yaml_config(config_path)

# Actualizar la ruta del FASTA si se proporciona
if fasta_path:
conf["fantasia_input_fasta"] = fasta_path

def run_pipeline(conf):
# Ejecutar el pipeline de fantasia
current_date = datetime.now().strftime("%Y%m%d%H%M%S")
embedder = SequenceEmbedder(conf, current_date)
Expand All @@ -59,16 +52,37 @@ def wait_forever():
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="fantasia: Command Handler")
parser.add_argument("command", type=str, nargs="?", default=None, help="Command to execute: initialize or run")
parser.add_argument("--config", type=str, default="./fantasia/config.yaml", help="Path to the configuration YAML file.")
parser.add_argument("--config", type=str, default="./opt/venv/lib/python3.12/site-packages/fantasia/config.yaml", help="Path to the configuration YAML file.")
parser.add_argument("--fasta", type=str, help="Path to the input FASTA file.")
parser.add_argument("--prefix", type=str, help="Prefix for output files.")
parser.add_argument("--max_distance", type=float, help="Maximum distance for similarity matching.")
parser.add_argument("--length_filter", type=int, help="Length filter threshold for sequences.")
parser.add_argument("--redundancy_filter", type=float, help="Redundancy filter threshold.")
args = parser.parse_args()

if args.command == "initialize":
print("Initializing embeddings and database...")
initialize(args.config)
elif args.command == "run":
print("Running the fantasia pipeline...")
run_pipeline(config_path=args.config, fasta_path=args.fasta)

# Leer la configuración una sola vez
conf = read_yaml_config(args.config)

# Sobrescribir parámetros con los valores del CLI
if args.fasta:
conf["fantasia_input_fasta"] = args.fasta
if args.prefix:
conf["fantasia_prefix"] = args.prefix
if args.max_distance is not None:
conf["max_distance"] = args.max_distance
if args.length_filter is not None:
conf["length_filter"] = args.length_filter
if args.redundancy_filter is not None:
conf["redundancy_filter"] = args.redundancy_filter

# Pasar la configuración modificada directamente
run_pipeline(conf)
elif args.command is None:
wait_forever()
else:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "FANTASIA"
version = "0.1.0"
version = "0.2.0"
description = "Functional ANnoTAtion based on embedding space SImilArity"
authors = ["Francisco Miguel Pérez Canales <[email protected]>","Gemma Martínez Redondo <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 497e566

Please sign in to comment.