annotate get_db_info.py @ 0:934050a8037e draft

planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
author tduigou
date Thu, 17 Jul 2025 09:34:14 +0000
parents
children 54e716c11b71
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
1 import subprocess
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
2 import argparse
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
3 import time
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
4 import json
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
5 import os
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
6 import socket
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
7 import re
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
8 from Bio.Seq import Seq
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
9 import pandas as pd
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
10 from Bio.SeqRecord import SeqRecord
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
11 from sqlalchemy import create_engine, inspect
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
12 from sqlalchemy.engine.url import make_url
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
13 from sqlalchemy.sql import text
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
14 from sqlalchemy.exc import OperationalError
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
15
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
16
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
17 def fix_db_uri(uri):
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
18 """Replace __at__ with @ in the URI if needed."""
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
19 return uri.replace("__at__", "@")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
20
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
21
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
22 def is_port_in_use(uri):
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
23 """Check if a TCP port is already in use on host."""
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
24 url = make_url(uri)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
25 host = url.host
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
26 port = url.port
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
27 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
28 s.settimeout(2)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
29 return s.connect_ex((host, port)) == 0
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
30
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
31
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
32 def extract_db_name(uri):
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
33 """Extract the database name from the SQLAlchemy URI."""
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
34 url = make_url(uri)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
35 return url.database
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
36
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
37
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
38 # this fuction is to activate the Docker id the DB is in container. BUT IT IS NOT USED IN MAIN()
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
39 def start_postgres_container(db_name):
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
40 """Start a PostgreSQL container with the given database name as the container name."""
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
41 container_name = db_name
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
42
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
43 # Check if container is already running
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
44 container_running = subprocess.run(
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
45 f"docker ps -q -f name={container_name}", shell=True, capture_output=True, text=True
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
46 )
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
47
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
48 if container_running.stdout.strip():
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
49 print(f"Container '{container_name}' is already running.")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
50 return
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
51
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
52 # Check if container exists (stopped)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
53 container_exists = subprocess.run(
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
54 f"docker ps -a -q -f name={container_name}", shell=True, capture_output=True, text=True
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
55 )
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
56
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
57 if container_exists.stdout.strip():
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
58 print(f"Starting existing container '{container_name}'...")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
59 subprocess.run(f"docker start {container_name}", shell=True)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
60 print(f"PostgreSQL Docker container '{container_name}' activated.")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
61 return
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
62
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
63 # If container does not exist, create and start a new one
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
64 port = 5432 if not is_port_in_use(5432) else 5433
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
65 postgres_password = os.getenv("POSTGRES_PASSWORD", "RK17")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
66
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
67 start_command = [
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
68 "docker", "run", "--name", container_name,
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
69 "-e", f"POSTGRES_PASSWORD={postgres_password}",
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
70 "-p", f"{port}:5432",
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
71 "-d", "postgres"
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
72 ]
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
73
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
74 try:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
75 subprocess.run(start_command, check=True)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
76 print(f"PostgreSQL Docker container '{container_name}' started on port {port}.")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
77 except subprocess.CalledProcessError as e:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
78 print(f"Failed to start Docker container: {e}")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
79
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
80
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
81 def wait_for_db(uri, timeout=60):
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
82 """Try connecting to the DB until it works or timeout."""
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
83 engine = create_engine(uri)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
84 start_time = time.time()
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
85 while time.time() - start_time < timeout:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
86 try:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
87 with engine.connect():
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
88 print("Connected to database.")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
89 return
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
90 except OperationalError:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
91 print("Database not ready, retrying...")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
92 time.sleep(2)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
93 raise Exception("Database connection failed after timeout.")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
94
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
95
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
96 def fetch_annotations(csv_file, sequence_column, annotation_columns, db_uri, table_name, fragment_column_name, output):
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
97 """Fetch annotations from the database and save the result as GenBank files."""
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
98 db_uri = fix_db_uri(db_uri)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
99 df = pd.read_csv(csv_file, sep=',', header=None)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
100
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
101 engine = create_engine(db_uri)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
102 connection = engine.connect()
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
103
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
104 annotated_data = []
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
105
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
106 try:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
107 with connection:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
108 inspector = inspect(engine)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
109 columns = [column['name'] for column in inspector.get_columns(table_name)]
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
110
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
111 # Fetch all fragments from the table once
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
112 if fragment_column_name not in columns:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
113 raise ValueError(f"Fragment column '{fragment_column_name}' not found in table '{table_name}'.")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
114
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
115 fragment_column_index = columns.index(fragment_column_name)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
116 all_rows = connection.execute(text(f"SELECT * FROM {table_name}")).fetchall()
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
117 fragment_map = {row[fragment_column_index]: row for row in all_rows}
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
118
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
119 # Compare fragments between CSV and DB
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
120 csv_fragments = set()
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
121 all_ids = set(df[0].dropna().astype(str))
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
122 for _, row in df.iterrows():
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
123 for col in df.columns:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
124 if col != 0:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
125 fragment = row[col]
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
126 if pd.notna(fragment):
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
127 fragment_str = str(fragment)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
128 if fragment_str not in all_ids:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
129 csv_fragments.add(fragment_str)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
130
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
131 db_fragments = set(fragment_map.keys())
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
132 missing_fragments = sorted(list(csv_fragments - db_fragments))
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
133 if missing_fragments:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
134 raise ValueError(
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
135 f" Missing fragments in DB: {', '.join(missing_fragments)}"
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
136 )
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
137
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
138 # === CONTINUE WITH GB FILE CREATION ===
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
139 for _, row in df.iterrows():
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
140 annotated_row = {"Backbone": row[0], "Fragments": []}
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
141 for col in df.columns:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
142 if col != 0:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
143 fragment = row[col]
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
144 if fragment not in csv_fragments:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
145 continue
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
146 db_row = fragment_map.get(fragment)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
147
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
148 if db_row:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
149 fragment_data = {"id": fragment}
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
150 for i, column_name in enumerate(columns[1:]): # skip ID column
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
151 fragment_data[column_name] = db_row[i + 1]
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
152 else:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
153 fragment_data = {"id": fragment, "metadata": "No data found"}
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
154
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
155 annotated_row["Fragments"].append(fragment_data)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
156
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
157 annotated_data.append(annotated_row)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
158
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
159 except Exception as e:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
160 print(f"Error occurred during annotation: {e}")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
161 raise # Ensures the error exits the script
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
162
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
163 # GenBank file generation per fragment
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
164 try:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
165 for annotated_row in annotated_data:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
166 backbone_id = annotated_row["Backbone"]
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
167 for fragment in annotated_row["Fragments"]:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
168 fragment_id = fragment["id"]
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
169 sequence = fragment.get(sequence_column, "")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
170 annotation = fragment.get(annotation_columns, "")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
171
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
172 # Create the SeqRecord
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
173 record = SeqRecord(
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
174 Seq(sequence),
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
175 id=fragment_id,
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
176 name=fragment_id,
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
177 description=f"Fragment {fragment_id} from Backbone {backbone_id}"
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
178 )
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
179
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
180 # Add annotations to GenBank header
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
181 record.annotations = {
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
182 k: str(fragment[k]) for k in annotation_columns if k in fragment
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
183 }
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
184
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
185 # LOCUS line extraction from annotation (copy-paste the LOCUS from annotation)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
186 locus_line_match = re.search(r"LOCUS\s+.+", annotation)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
187 if locus_line_match:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
188 locus_line = locus_line_match.group()
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
189 else:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
190 print(f"LOCUS info missing for fragment {fragment_id}")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
191 locus_line = f"LOCUS {fragment_id: <20} {len(sequence)} bp DNA linear UNK 01-JAN-2025"
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
192
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
193 # Format sequence as per GenBank standards (with ORIGIN and line breaks)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
194 if "ORIGIN" in sequence:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
195 origin_block = sequence.strip()
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
196 else:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
197 # Format sequence as per GenBank standards (with ORIGIN and line breaks)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
198 formatted_sequence = "ORIGIN\n"
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
199 seq_str = str(record.seq)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
200 for i in range(0, len(seq_str), 60): # 60 bases per line
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
201 line_seq = seq_str[i:i + 60]
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
202 formatted_sequence += f"{str(i + 1).rjust(9)} { ' '.join([line_seq[j:j+10] for j in range(0, len(line_seq), 10)]) }\n"
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
203 origin_block = formatted_sequence.strip()
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
204
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
205 # Find and copy the FEATURES section directly from annotation
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
206 features_section = ""
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
207 features_start = annotation.find("FEATURES")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
208 if features_start != -1:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
209 features_section = annotation[features_start:]
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
210
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
211 # Writing the GenBank file
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
212 if not os.path.exists(output):
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
213 os.makedirs(output)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
214
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
215 gb_filename = os.path.join(output, f"{fragment_id}.gb")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
216 with open(gb_filename, "w") as f:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
217 # Write the LOCUS line
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
218 f.write(locus_line + "\n")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
219 # Write DEFINITION, ACCESSION, and other annotations
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
220 f.write(f"DEFINITION {record.description}\n")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
221 f.write(f"ACCESSION {record.id}\n")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
222 f.write(f"VERSION DB\n")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
223 f.write(f"KEYWORDS .\n")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
224 f.write(f"SOURCE .\n")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
225 # Write the FEATURES section directly from annotation
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
226 f.write(features_section)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
227 # Write the ORIGIN section
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
228 f.write(origin_block + "\n")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
229 f.write("//\n")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
230
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
231 except Exception as e:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
232 print(f"Error saving GenBank files: {e}")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
233 return
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
234
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
235
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
236 def main():
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
237 parser = argparse.ArgumentParser(description="Fetch annotations from PostgreSQL database and save as JSON.")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
238 parser.add_argument("--input", required=True, help="Input CSV file")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
239 parser.add_argument("--use_json_paramers", required=True, help="Use parameters from JSON: true/false")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
240 parser.add_argument("--sequence_column", required=False, help="DB column contains sequence for ganbank file")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
241 parser.add_argument("--annotation_columns", required=False, help="DB column contains head for ganbank file")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
242 parser.add_argument("--db_uri", required=False, help="Database URI connection string")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
243 parser.add_argument("--table", required=False, help="Table name in the database")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
244 parser.add_argument("--fragment_column", required=False, help="Fragment column name in the database")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
245 parser.add_argument("--output", required=True, help="Output dir for gb files")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
246 parser.add_argument("--json_conf", required=False, help="JSON config file with DB parameters")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
247 args = parser.parse_args()
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
248
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
249 # get param and chek for json
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
250 config_params = {}
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
251 use_json = args.use_json_paramers == 'true'
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
252 if use_json:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
253 if not args.json_conf:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
254 raise ValueError("You must provide --json_conf when --use_json_paramers is 'true'")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
255 with open(args.json_conf, "r") as f:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
256 config_params = json.load(f)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
257 else:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
258 config_params = {
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
259 "table": args.table,
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
260 "sequence_column": args.sequence_column,
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
261 "annotation_column": args.annotation_columns,
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
262 "fragment_column": args.fragment_column,
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
263 "db_uri": args.db_uri,
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
264 }
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
265
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
266 # Extract final resolved parameters
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
267 table = config_params["table"]
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
268 sequence_column = config_params["sequence_column"]
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
269 annotation_column = config_params["annotation_column"]
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
270 fragment_column = config_params["fragment_column"]
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
271 db_uri = fix_db_uri(config_params["db_uri"])
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
272
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
273 # Wait until the database is ready
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
274 db_uri = fix_db_uri(db_uri)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
275 # db_name = extract_db_name(db_uri)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
276 # start_postgres_container(db_name)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
277 MAX_RETRIES = 3
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
278 for attempt in range(1, MAX_RETRIES + 1):
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
279 try:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
280 wait_for_db(db_uri)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
281 break # Success
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
282 except Exception as e:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
283 if attempt == MAX_RETRIES:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
284 print(f"Attempt {attempt} failed: Could not connect to database at {db_uri}.")
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
285 raise e
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
286 else:
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
287 time.sleep(2)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
288
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
289 # Fetch annotations from the database and save as gb
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
290 fetch_annotations(args.input, sequence_column, annotation_column, db_uri, table, fragment_column, args.output)
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
291
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
292 if __name__ == "__main__":
934050a8037e planemo upload for repository https://github.com/brsynth/galaxytools/tree/main/tools commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
diff changeset
293 main()