### Download Miniforge Installer for Linux Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Downloads the Miniforge installer script for Linux x86_64 systems. This is part of the manual Conda setup process. ```bash wget https://github.com/conda-forge/miniforge/releases/download/24.9.2-0/Miniforge3-24.9.2-0-Linux-x86_64.sh ``` -------------------------------- ### Install Miniforge Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Executes the downloaded Miniforge installer script and follows the on-screen prompts to install Conda. ```bash sh Miniforge3-24.9.2-0-Linux-x86_64.sh ``` -------------------------------- ### Install Pharokka from Source Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Installs the development version of Pharokka by cloning the GitHub repository and installing it using pip. Dependencies must be installed manually. ```bash git clone https://github.com/gbouras13/pharokka.git cd pharokka pip install -e . ``` -------------------------------- ### Set Up Virtual Environment and Install Source: https://github.com/gbouras13/pharokka/blob/master/CONTRIBUTING.md Create a virtual environment and install the Pharokka project in development mode. ```shell mkvirtualenv pharokka cd pharokka/ python setup.py develop ``` -------------------------------- ### Download Miniforge Installer for Mac Intel Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Downloads the Miniforge installer script for Intel-based MacOS systems. ```bash wget https://github.com/conda-forge/miniforge/releases/download/24.9.2-0/Miniforge3-24.9.2-0-MacOSX-x86_64.sh ``` -------------------------------- ### Install Pharokka Databases (Custom Directory) Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Installs the Pharokka database files to a user-specified directory. This is recommended for better organization. ```bash install_databases.py -o ``` -------------------------------- ### Install Pharokka Databases (Default Directory) Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Installs the Pharokka database files to the default location on your system. ```bash install_databases.py -d ``` -------------------------------- ### Install Pharokka Dependencies from Source Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Installs Pharokka dependencies using Conda from the environment.yml file, then installs Pharokka from source. ```bash conda env create -f environment.yml conda activate pharokka_env # assuming you are in the pharokka directory # installs pharokka from source pip install -e . pharokka.py --help ``` -------------------------------- ### Download Miniforge Installer for Mac M1/M2/M3/M4 Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Downloads the Miniforge installer script for Apple Silicon (M1/M2/M3/M4) MacOS systems. ```bash wget https://github.com/conda-forge/miniforge/releases/download/24.9.2-0/Miniforge3-24.9.2-0-MacOSX-arm64.sh ``` -------------------------------- ### Running Pharokka with Advanced Arguments Source: https://github.com/gbouras13/pharokka/blob/master/docs/run.md Example of running Pharokka with specific arguments for input, output, database, threads, and MINCED parameters. This is useful for fine-tuning the annotation process. ```bash pharokka.py -i -o -d -t --minced_args "minNR 2 -minRL 21" ``` -------------------------------- ### Install Miniforge Source: https://github.com/gbouras13/pharokka/blob/master/run_pharokka_and_phold_and_phynteny.ipynb Installs Miniforge, a minimal installer for Conda, which is a prerequisite for setting up the Python environment for the annotation tools. It ensures a specific version of Miniforge is used to avoid compatibility issues. ```python #@title 1. Install miniforge #@markdown This cell installs miniforge %%bash set -e PYTHON_VERSION=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") echo "python version ${PYTHON_VERSION}" if [ ! -f CONDA_READY ]; then echo "installing miniforge" # miniforge 25.9.1 introduces some issue - latest as of 7 Nov 2025 - see https://github.com/gbouras13/phold/issues/106 # issue is fixed if you use the previous release (25.3.1) #wget -qnc https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh wget -qnc https://github.com/conda-forge/miniforge/releases/download/25.3.1-0/Miniforge3-25.3.1-0-Linux-x86_64.sh bash Miniforge3-25.3.1-0-Linux-x86_64.sh -bfp /usr/local 2>&1 1>/dev/null conda config --set auto_update_conda false touch CONDA_READY fi pip install --upgrade matplotlib matplotlib-inline ``` -------------------------------- ### Example Command for Creating Custom HMMs Source: https://github.com/gbouras13/pharokka/blob/master/docs/custom.md This command demonstrates how to use `create_custom_hmm.py` with specific input and output parameters. It processes MSAs from `my_tail_msa`, outputs HMMs to `tail_hmms`, and prefixes the combined HMM file with `tail`. ```bash create_custom_hmm.py -i my_tail_msa -o tail_hmms -p tail ``` -------------------------------- ### Install Pharokka Python Components with Pip Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Installs only the Python components of Pharokka version 1.4.0 and later. Non-Python dependencies must be installed manually. ```bash pip install pharokka ``` -------------------------------- ### Install Pharokka with Conda Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md The recommended method for installing Pharokka and its dependencies. This command installs the package and all required libraries from the bioconda channel. ```bash conda install -c bioconda pharokka ``` -------------------------------- ### Install Pharokka, Phold, and Phynteny Source: https://github.com/gbouras13/pharokka/blob/master/run_pharokka_and_phold_and_phynteny.ipynb Installs the Pharokka, Phold, and Phynteny tools using Conda. It also sets up the necessary environment variables and creates a flag file to indicate successful installation. Note that Pharokka requires a specific Python version compatibility. ```python #@title 2. Install pharokka and phold and phynteny #@markdown This cell installs pharokka and phold. It will take a few minutes. Please be patient PHAROKKA_VERSION="1.9.1" PHOLD_VERSION="1.2.2" PHYNTENY_VERSION="0.1.3" # add paths import sys sys.path.append("/usr/local/bin") # Update environment variables for shell usage import os os.environ["PATH"] = "/usr/local/bin:" + os.environ["PATH"] # create envs # pharokka isn't compatible with Python 3.13 (Google Colab default) # so it needs a separate env from pathlib import Path flag_file = Path("PHAROKKA_PHOLD_PHYNTENY_READY") if not flag_file.exists(): !conda install -y -c bioconda phold=={PHOLD_VERSION} pharokka=={PHAROKKA_VERSION} pytorch=*=cuda* phynteny_transformer=={PHYNTENY_VERSION} # Touch the flag file flag_file.touch() ``` -------------------------------- ### Install Pharokka using Mamba (faster Conda) Source: https://github.com/gbouras13/pharokka/blob/master/README.md Use Mamba for faster environment solving if Conda is slow. First install Mamba, then Pharokka. ```bash conda install mamba mamba install -c bioconda pharokka ``` -------------------------------- ### Create and Activate Pharokka Conda Environment Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Creates a new conda environment named 'pharokkaENV', installs Pharokka into it, and activates the environment. Also shows help for database and pharokka scripts. ```bash conda create -n pharokkaENV pharokka conda activate pharokkaENV install_databases.py -h pharokka.py -h ``` -------------------------------- ### Example MSA Input Format Source: https://github.com/gbouras13/pharokka/blob/master/docs/custom.md The `create_custom_hmm.py` script expects input MSAs to be in FASTA format. Each sequence within an MSA should be labeled with a unique identifier. ```fasta >gene1 --------------------MERCMYDLSHFSFMTGRIGQLQTLTCIPVVSGDSFSVNFQGVFRLSPLRRNMVIDCMVDLFAFYVPYRHVYG-----DDWENFMLQGTDETVTFGTAD-FTTN-AVEYLGSQ-----R-TTGVAPLWRLASYNQIWNRYFRVPSDTSAILSNTALE---A-GVNKNKWGRYCARPKVIWSTGVDTTTD--AAD--REVTVTANQLDITDLDAVKGRYASEQRRDWFG-QRYNDILKNQFGGGAGTDADERPTLIMRKQHFLSGYDVDGTGDATLGQYSGKSAAVCDLQIPRKWFPEHGSL-WIMALLRFPTIHEEEIHYLFKKSQPTYDEISGDPDIWERKAPIEHQVQDFFTESTDTTSLGFMPYGQWYRYHPNVVHNQFTEVTGFSFVSA-RPT-----SKDTARYIQDDEYTPTFQTTSLGHWQSQARVDVEAVRPIPGPLKSIFAGV------------ >gene2 MSKSSGYATTSKPQEVVTRDIERKPYDLSHWSFKTGHIGRLQTFSVIPVVAGDSIELNMSAVLRLSPLRHFMYLDAVVDLFAFYVPHRHVYG-----SNWTAFLKAGVDEGSTLGTTT-FTGSNRPECLGVY-----FAAGQVLPSWSVHPYTMIWNNYFRDPQVDADAKTDATYLIGLTYPDPILKYGLPVCHLKRSWNTGVASGLS--TAD--YSLALSGGEVDLYQMSQLKGRLQTEQARDWFAFARYRDILKYTWDSEVNIDADQRPELIMRSTAWLSGKDVDGTDDATLGSYTGKSTGIFNLSFPSRFFAEHGSI-WIMGVVRFPPIVEAEAGYLNSKSEPTYKEISGDPSIIKHEPPISLNANEQFQG-ASSVDLGKIPYGQWYRESINMLSADYLEVSGHPFLLKSSIT-----SRATGVYVVPSQYDTVFSDTLMGHWNSQAFVDVRAKRFIPAPEDSIFAGTI----------- >gene3 ----------------MKGTDTRCLYDLDHWSHVSGNIGSLQTLSAIPVVAGDSMELNFTSLFRLSPLRRNLYLDAMVDLFAFYVPYRHVYG-----DTWIDFIKEGYDESQTLGTYT-IAAGEFINCTGAY-----LESQAVIPKWSIASYTRIWNRYFRHPTDSNEKDDDDLI----TASSGNQIYGYNCCHMKNIWSTGVDSELT--DDD--HKVDVTASKVDLLEIIQKKARFKTERQREWFG-QRYTDILDSVWGSNVNIDADERPELIMRTSTWLSGYDVDGTTETNIGTFSGKAFTTARLQFPMKYFNEHGTI-YIVALVRFPTIHAFERHYLFGKSEPTYKEIAGDPNVIRNEPPQAINPTDYIEN-ATATDVGLQPYAQWYRTHPSYTSLGFSNLDGHPFLQK-IIA-----NTDDAVYVDSNDYDEIFQTQQLQQWQSQGYVGLKAKRNIPDPRKSIFAGVK----------- ``` -------------------------------- ### Example labels.txt content Source: https://github.com/gbouras13/pharokka/blob/master/docs/plotting.md A text file containing one locus tag per line, used with the --label_ids option. ```text EHOONAYF_CDS_0007 EHOONAYF_CDS_0009 EHOONAYF_CDS_0023 ``` -------------------------------- ### Add Conda Channels Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Configures the conda environment to use the default, bioconda, and conda-forge channels, which are necessary for installing Pharokka. ```bash conda config --add channels defaults conda config --add channels bioconda conda config --add channels conda-forge ``` -------------------------------- ### Install Pharokka on M1/M2/M3 Macs with Conda Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Specific command for MacOS systems with Apple Silicon (M1/M2/M3) to create a dedicated conda environment for Pharokka. ```bash conda create --platform osx-64 --name pharokkaENV -c bioconda pharokka conda activate pharokkaENV ``` -------------------------------- ### Download Pharokka, Phold, and Phynteny Databases Source: https://github.com/gbouras13/pharokka/blob/master/run_pharokka_and_phold_and_phynteny.ipynb Downloads the necessary databases and models for Pharokka, Phold, and Phynteny. This step is crucial for the tools to function correctly and may take a significant amount of time. ```bash #@title 3. Download pharokka phold databases #@markdown This cell downloads the pharokka then the phold database. It will take some time (10-15 minutes probably depending on Zenodo's traffic). Please be patient. Perhaps go for a walk or have a coffee or tea. %%time print("Downloading pharokka database. This will take a few minutes. Please be patient :)") !install_databases.py -o pharokka_db print("Downloading phold database. This will take a few minutes. Please be patient :)") !phold install -d phold_db -t 8 --foldseek_gpu print("Downloading phynteny database. This will take a few minutes. Please be patient :)") !install_models -o phynteny_models ``` -------------------------------- ### Pharokka Command-Line Usage Help Source: https://github.com/gbouras13/pharokka/blob/master/docs/run.md Displays the full help message for the Pharokka script, listing all available options and their descriptions. Use this to understand all configurable parameters. ```bash usage: pharokka.py [-h] [-i INFILE] [-o OUTDIR] [-d DATABASE] [-t THREADS] [-f] [-p PREFIX] [-l LOCUSTAG] [-g GENE_PREDICTOR] [-m] [-s] [-c CODING_TABLE] [-e EVALUE] [--fast] [--mmseqs2_only] [--meta_hmm] [--dnaapler] [--custom_hmm CUSTOM_HMM] [--genbank] [--terminase] [--terminase_strand TERMINASE_STRAND] [--terminase_start TERMINASE_START] [--skip_extra_annotations] [--skip_mash] [--minced_args MINCED_ARGS] [--mash_distance MASH_DISTANCE] [--trna_scan_model {general,bacterial}] [--keep_raw_prodigal] [--reverse_mmseqs2] [-V] [--citation] pharokka: fast phage annotation program options: -h, --help show this help message and exit -i, --infile INFILE Input genome file in fasta format. -o, --outdir OUTDIR Directory to write the output to. -d, --database DATABASE Database directory. If the databases have been installed in the default directory, this is not required. Otherwise specify the path. -t, --threads THREADS Number of threads. Defaults to 1. -f, --force Overwrites the output directory. -p, --prefix PREFIX Prefix for output files. This is not required. -l, --locustag LOCUSTAG User specified locus tag for the gff/gbk files. This is not required. A random locus tag will be generated instead. -g, --gene_predictor GENE_PREDICTOR User specified gene predictor. Use "-g phanotate" or "-g prodigal" or "-g prodigal-gv" or "-g pyrodigal-rv" or "-g genbank". Defaults to phanotate usually and prodigal-gv in meta mode. -m, --meta meta mode for metavirome input samples -s, --split split mode for metavirome samples. -m must also be specified. Will output separate split FASTA, gff and genbank files for each input contig. -c, --coding_table CODING_TABLE translation table for prodigal. Defaults to 11. -e, --evalue EVALUE E-value threshold for MMseqs2 database PHROGs, VFDB and CARD and PyHMMER PHROGs database search. Defaults to 1E-05. --fast, --hmm_only Runs PyHMMER (HMMs) with PHROGs only, not MMseqs2 with PHROGs, CARD or VFDB. Designed for phage isolates, will not likely be faster for large metagenomes. --mmseqs2_only Runs MMseqs2 with PHROGs, CARD and VFDB only (same as Pharokka v1.3.2 and prior). Default in meta mode. --meta_hmm Overrides --mmseqs2_only in meta mode. Will run both MMseqs2 and PyHMMER. --dnaapler Runs dnaapler to automatically re-orient all contigs to begin with terminase large subunit if found. Recommended over using '--terminase'. --custom_hmm CUSTOM_HMM Run pharokka with a custom HMM profile database suffixed .h3m. Please use create this with the create_custom_hmm.py script. --genbank Flag denoting that -i/--input is a genbank file instead of the usual FASTA file. The CDS calls in this file will be preserved and re-annotated. --terminase Runs terminase large subunit re-orientation mode. Single genome input only and requires --terminase_strand and --terminase_start to be specified. --terminase_strand TERMINASE_STRAND Strand of terminase large subunit. Must be "pos" or "neg". --terminase_start TERMINASE_START Start coordinate of the terminase large subunit. --skip_extra_annotations Skips tRNAscan-SE 2, MinCED and Aragorn. --skip_mash Skips running mash to find the closest match for each contig in INPHARED. --minced_args MINCED_ARGS extra commands to pass to MINced (please omit the leading hyphen for the first argument). You will need to use quotation marks e.g. --minced_args "minNR 2 -minRL 21" --mash_distance MASH_DISTANCE mash distance for the search against INPHARED. Defaults to 0.2. --trna_scan_model {general,bacterial} tRNAscan-SE model --keep_raw_prodigal Keeps raw prodigal header information. --reverse_mmseqs2 MMseqs2 database as target not query. -V, --version Print pharokka Version --citation Print pharokka Citation ``` -------------------------------- ### Basic Pharokka Execution Source: https://github.com/gbouras13/pharokka/blob/master/docs/run.md Run pharokka with essential parameters: input FASTA file, output folder, threads, and prefix. ```bash pharokka.py -i -o -t -p ``` -------------------------------- ### Pharokka Execution with Custom Database Source: https://github.com/gbouras13/pharokka/blob/master/README.md Specify a custom database directory and prefix for output files. ```bash pharokka.py -i -o -d -t -p ``` -------------------------------- ### Basic Pharokka Execution Source: https://github.com/gbouras13/pharokka/blob/master/README.md Run Pharokka with input FASTA file, output directory, and number of threads. ```bash pharokka.py -i -o -t ``` -------------------------------- ### create_custom_hmm.py Script Usage Source: https://github.com/gbouras13/pharokka/blob/master/docs/custom.md This displays the command-line options available for the `create_custom_hmm.py` script, including input/output directories, prefix for HMM files, and force overwrite functionality. ```bash usage: create_custom_hmm.py [-h] [-i INDIR] [-o OUTDIR] [-p PREFIX] [-f] [-V] create_custom_hmm.py: Creates HMMs from FASTA formatted MSAs with PyHMMER for use with Pharokka v1.4.0 and higher. options: -h, --help show this help message and exit -i INDIR, --indir INDIR Input directory containing FASTA formatted Multiple Sequence Alignments. -o OUTDIR, --outdir OUTDIR Output directory to store HMM profiles. -p PREFIX, --prefix PREFIX Prefix used to name HMMs. The relevant file be 'prefix'.h3m -f, --force Overwrites the output directory. -V, --version Print pharokka Version ``` -------------------------------- ### Basic Plotting Command Source: https://github.com/gbouras13/pharokka/blob/master/docs/plotting.md Run the plotter with input FASTA, plot name, and output directory. ```bash pharokka_plotter.py -i input.fasta -n pharokka_plot -o pharokka_output_directory ``` -------------------------------- ### Reorient Phage Genome with dnaapler Source: https://github.com/gbouras13/pharokka/blob/master/docs/run.md Automatically reorient your phage genome to start with the large terminase subunit using the dnaapler tool. The reoriented FASTA file will be saved in the output directory. ```bash pharokka.py -i -o -d -t --dnaapler ``` -------------------------------- ### Download and Extract Pharokka Databases Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Downloads the Pharokka database archive from Zenodo and extracts it to the current directory. ```bash wget "https://zenodo.org/record/8276347/files/pharokka_v1.4.0_databases.tar.gz" tar -xzf pharokka_v1.4.0_databases.tar.gz ``` -------------------------------- ### Reorient Phage Genome to Specific Start Coordinate Source: https://github.com/gbouras13/pharokka/blob/master/docs/run.md Manually reorient your phage genome to begin at a specific coordinate and strand. This is useful if dnaapler is not suitable or if you need precise control over the reorientation point. ```bash pharokka.py -i -o -d -t --terminase --terminase_start 9503 --terminase_strand pos ``` -------------------------------- ### Commit and Push Changes Source: https://github.com/gbouras13/pharokka/blob/master/CONTRIBUTING.md Stage, commit, and push your local changes to your forked repository. ```shell git add . git commit -m "Your detailed description of your changes." git push origin name-of-your-bugfix-or-feature ``` -------------------------------- ### Run Tests and Linting Source: https://github.com/gbouras13/pharokka/blob/master/CONTRIBUTING.md Ensure your changes pass linting and all tests, including checks for different Python versions using tox. ```shell flake8 pharokka tests python setup.py test or pytest tox ``` -------------------------------- ### Reorient Phage Genome with Negative Strand Terminase Source: https://github.com/gbouras13/pharokka/blob/master/docs/run.md Reorient your phage genome to begin with the large terminase subunit located on the negative strand. Specify the end coordinate of the terminase gene on the negative strand as the start coordinate for reorientation. ```bash pharokka.py \ -i \ -o \ -d \ -t \ --terminase \ --terminase_start 82226 \ --terminase_strand neg ``` -------------------------------- ### Run Pharokka in Meta Mode with Split Output Source: https://github.com/gbouras13/pharokka/blob/master/docs/run.md Enable meta mode and split output files for each input contig. This option generates separate FASTA, GenBank, and GFF files for individual contigs. ```bash pharokka.py -i -o -d -t -m -s ``` -------------------------------- ### Specifying GFF and Genbank Files Source: https://github.com/gbouras13/pharokka/blob/master/docs/plotting.md Provide specific GFF and Genbank files instead of a directory. The output PNG will be saved in the working directory. ```bash pharokka_plotter.py -i input.fasta -n pharokka_plot --gff pharokka.gff --genbank pharokka.gbk ``` -------------------------------- ### Specifying Database Directory Source: https://github.com/gbouras13/pharokka/blob/master/docs/run.md Specify a custom directory for pharokka databases using the -d flag. This is recommended for better organization. ```bash pharokka.py -i -o -d -t -p ``` -------------------------------- ### Run Pharokka with various options Source: https://github.com/gbouras13/pharokka/blob/master/run_pharokka_and_phold_and_phynteny.ipynb This snippet executes the Pharokka command-line tool with configurable parameters such as input file, output directory, gene predictor, prefix, locus tag, and flags for fast mode, meta-analysis, meta-HMM, and force overwrite. It includes error handling and zips the output directory upon successful completion. ```python #@title 4. Run Pharokka #@markdown First, upload your phage(s) as a nucleotide input FASTA file #@markdown Click on the folder icon to the left and use the file upload button. #@markdown Once it is uploaded, write the file name in the INPUT_FILE field on the right. #@markdown Then provide a directory for pharokka's output using PHAROKKA_OUT_DIR. #@markdown The default is 'output_pharokka'. #@markdown Then type in a gene prediction tool for pharokka. #@markdown Please choose either 'phanotate', 'prodigal', or 'prodigal-gv'. #@markdown You can also provide a prefix for your output files with PHAROKKA_PREFIX. #@markdown If you provide nothing it will default to 'pharokka'. #@markdown You can also provide a locus tag for your output files. #@markdown If you provide nothing it will generate a random locus tag. #@markdown You can click FAST to turn off --fast. #@markdown By default it is True so that Pharokka runs faster in the Colab environment. #@markdown You can click META to turn on --meta if you have multiple phages in your input. #@markdown You can click META_HMM to turn on --meta_hmm. #@markdown You can click FORCE to overwrite the output directory. #@markdown This may be useful if your earlier pharokka run has crashed for whatever reason. #@markdown The results of Pharokka will be in the folder icon on the left hand panel. #@markdown Additionally, it will be zipped so you can download the whole directory. #@markdown The file to download is PHAROKKA_OUT_DIR.zip, where PHAROKKA_OUT_DIR is what you provided #@markdown If you do not see the output directory, #@markdown refresh the window by either clicking the folder with the refresh icon below "Files" #@markdown or double click and select "Refresh". %%time import os import sys import subprocess import zipfile INPUT_FILE = '' #@param {type:"string"} if os.path.exists(INPUT_FILE): print(f"Input file {INPUT_FILE} exists") else: print(f"Error: File {INPUT_FILE} does not exist") print(f"Please check the spelling and that you have uploaded it correctly") sys.exit(1) PHAROKKA_OUT_DIR = 'output_pharokka' #@param {type:"string"} GENE_PREDICTOR = 'phanotate' #@param {type:"string"} allowed_gene_predictors = ['phanotate', 'prodigal', 'prodigal-gv'] # Check if the input parameter is valid if GENE_PREDICTOR.lower() not in allowed_gene_predictors: raise ValueError("Invalid GENE_PREDICTOR. Please choose from: 'phanotate', 'prodigal', 'prodigal-gv'.") PHAROKKA_PREFIX = 'pharokka' #@param {type:"string"} LOCUS_TAG = 'Default' #@param {type:"string"} FAST = True #@param {type:"boolean"} META = False #@param {type:"boolean"} META_HMM = False #@param {type:"boolean"} FORCE = True #@param {type:"boolean"} # Construct the command # need to suppress PYTHONWARNINGS for phanotate version handling command = ( f'pharokka.py -d pharokka_db -i {INPUT_FILE} -t 4 ' f'-o {PHAROKKA_OUT_DIR} -p {PHAROKKA_PREFIX} -l {LOCUS_TAG} -g {GENE_PREDICTOR}' ) if FORCE is True: command = f"{command} -f" if FAST is True: command = f"{command} --fast" if META is True: command = f"{command} -m" if META_HMM is True: command = f"{command} --meta_hmm" # Execute the command try: print("Running pharokka") subprocess.run(command, shell=True, check=True) print("pharokka completed successfully.") print(f"Your output is in {PHAROKKA_OUT_DIR}.") print(f"Zipping the output directory so you can download it all in one go.") zip_filename = f"{PHAROKKA_OUT_DIR}.zip" # Zip the contents of the output directory with zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED) as zipf: for root, dirs, files in os.walk(PHAROKKA_OUT_DIR): for file in files: zipf.write(os.path.join(root, file), os.path.relpath(os.path.join(root, file), PHAROKKA_OUT_DIR)) print(f"Output directory has been zipped to {zip_filename}") except subprocess.CalledProcessError as e: print(f"Error occurred: {e}") ``` -------------------------------- ### Pharokka Plotter Command-Line Usage Source: https://github.com/gbouras13/pharokka/blob/master/docs/plotting.md This snippet shows the basic usage and all available command-line options for the pharokka_plotter.py script. Use this to understand how to run the plotter and customize its output. ```bash usage: pharokka_plotter.py [-h] -i INFILE [-n PLOT_NAME] [-o OUTDIR] [--gff GFF] [--genbank GENBANK] [-p PREFIX] [-t PLOT_TITLE] [-f] [--label_hypotheticals] [--remove_other_features_labels] [--title_size TITLE_SIZE] [--label_size LABEL_SIZE] [--interval INTERVAL] [--truncate TRUNCATE] [--dpi DPI] [--annotations ANNOTATIONS] [--label_ids LABEL_IDS] pharokka_plotter.py: pharokka plotting function options: -h, --help show this help message and exit -i INFILE, --infile INFILE Input genome file in FASTA format. -n PLOT_NAME, --plot_name PLOT_NAME Output plot file name. ".""png"" suffix will be added to this automatically. Will be output in the pharokka output directory if -o is specified, or in the working directory if --gff andf --genbank are specified. -o OUTDIR, --outdir OUTDIR Pharokka output directory. --gff GFF Pharokka gff. --genbank GENBANK Pharokka genbank. -p PREFIX, --prefix PREFIX Prefix used to create pharokka output. Will default to pharokka. -t PLOT_TITLE, --plot_title PLOT_TITLE Plot name. -f, --force Overwrites the output plot file. --label_hypotheticals Flag to label hypothetical or unknown proteins. By default these are not labelled. --remove_other_features_labels Flag to remove labels for tRNA/tmRNA/CRISPRs. By default these are labelled. They will still be plotted in black. --title_size TITLE_SIZE Controls title size. Must be an integer. Defaults to 20. --label_size LABEL_SIZE Controls annotation label size. Must be an integer. Defaults to 8. --interval INTERVAL Axis tick interval. Must be an integer. Must be an integer. Defaults to 5000. --truncate TRUNCATE Number of characters to include in annoation labels before truncation with ellipsis. Must be an integer. Defaults to 20. --dpi DPI Resultion (dots per inch). Must be an integer. Defaults to 600. --annotations ANNOTATIONS Controls the proporition of annotations labelled. Must be a number between 0 and 1 inclusive. 0 = no annotations, 0.5 = half of the annotations, 1 = all annotations. Defaults to 1. Chosen in order of CDS size. --label_ids LABEL_IDS Text file with list of CDS IDs (from gff file) that are guaranteed to be labelled. ``` -------------------------------- ### Run Pharokka in Meta Mode with PyHMMER Source: https://github.com/gbouras13/pharokka/blob/master/docs/run.md Enable meta mode and force Pharokka to use PyHMMER on PHROGs. Be aware that this can be time-consuming for large metagenomes. ```bash pharokka.py -i -o -d -t -m --meta_hmm ``` -------------------------------- ### Fast Mode for Small Inputs Source: https://github.com/gbouras13/pharokka/blob/master/docs/run.md Use the --fast flag for accelerated processing of small inputs, focusing only on PyHMMER against PHROGs. ```bash pharokka.py -i -o -d -t --fast ``` -------------------------------- ### Running Pharokka with Custom HMM Database Source: https://github.com/gbouras13/pharokka/blob/master/docs/custom.md Integrate your custom HMM database into the pharokka analysis pipeline by specifying the path to the generated `.h3m` file using the `--custom_hmm` parameter. ```bash pharokka.py -i -o -d -t --custom_hmm tail_hmms/tail.h3m ``` -------------------------------- ### Run Pharokka with GenBank Input Source: https://github.com/gbouras13/pharokka/blob/master/docs/run.md Provide a GenBank file as input to Pharokka. This bypasses PHANOTATE/Pyrodigal gene prediction and uses existing CDS calls from the GenBank file, recommended for manually curated data. ```bash pharokka.py -i -o -d -t --genbank ``` -------------------------------- ### Pharokka Multiplotter Command Line Arguments Source: https://github.com/gbouras13/pharokka/blob/master/docs/plotting.md Displays all available command-line arguments for pharokka_multiplotter.py, including required and optional parameters for plot customization. ```bash usage: pharokka_multiplotter.py [-h] -g GENBANK -o OUTDIR [-f] [--label_hypotheticals] [--remove_other_features_labels] [--title_size TITLE_SIZE] [--label_size LABEL_SIZE] [--interval INTERVAL] [--truncate TRUNCATE] [--dpi DPI] [--annotations ANNOTATIONS] [-t PLOT_TITLE] [--label_ids LABEL_IDS] pharokka_multiplotter.py: pharokka plotting function for muliple phages options: -h, --help show this help message and exit -g GENBANK, --genbank GENBANK Input genbank file from Pharokka. -o OUTDIR, --outdir OUTDIR Pharokka output directory. -f, --force Overwrites the output plot file. --label_hypotheticals Flag to label hypothetical or unknown proteins. By default these are not labelled. --remove_other_features_labels Flag to remove labels for tRNA/tmRNA/CRISPRs. By default these are labelled. They will still be plotted in black. --title_size TITLE_SIZE Controls title size. Must be an integer. Defaults to 20. --label_size LABEL_SIZE Controls annotation label size. Must be an integer. Defaults to 8. --interval INTERVAL Axis tick interval. Must be an integer. Must be an integer. Defaults to 5000. --truncate TRUNCATE Number of characters to include in annoation labels before truncation with ellipsis. Must be an integer. Defaults to 20. --dpi DPI Resultion (dots per inch). Must be an integer. Defaults to 600. --annotations ANNOTATIONS Controls the proporition of annotations labelled. Must be a number between 0 and 1 inclusive. 0 = no annotations, 0.5 = half of the annotations, 1 = all annotations. Defaults to 1. Chosen in order of CDS size. -t PLOT_TITLE, --plot_title PLOT_TITLE Plot name. --label_ids LABEL_IDS Text file with list of CDS IDs (from gff file) that are guaranteed to be labelled. ``` -------------------------------- ### Deploy Pharokka Source: https://github.com/gbouras13/pharokka/blob/master/CONTRIBUTING.md Deploy a new version of Pharokka to PyPI by updating the version and pushing tags. ```shell bump2version patch # possible: major / minor / patch git push git push --tags ``` -------------------------------- ### Create and Activate Pharokka Conda Environment on Mac Apple Silicon Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Creates a new conda environment for Pharokka on Mac with Apple Silicon, specifying the osx-64 platform, and activates it. Includes help commands. ```bash conda create --platform osx-64 -n pharokkaENV pharokka conda activate pharokkaENV install_databases.py -h pharokka.py -h ``` -------------------------------- ### Run Phold Analysis Source: https://github.com/gbouras13/pharokka/blob/master/run_pharokka_and_phold_and_phynteny.ipynb Executes the Phold tool to analyze genetic elements from Pharokka's output. It allows for specifying output directories, prefixes, and options to force overwriting or separate results for multiple phages. The output is then zipped for easy download. ```python #@title 5. Run phold #@markdown This cell will run phold on the output of cell 3's Pharokka run #@markdown You do not need to provide any further input files #@markdown You can now provide a directory for phold's output with PHOLD_OUT_DIR. #@markdown The default is 'output_phold'. #@markdown You can also provide a prefix for your output files with PHOLD_PREFIX. #@markdown If you provide nothing it will default to 'phold'. #@markdown You can click FORCE to overwrite the output directory with . #@markdown This may be useful if your earlier phold run has crashed for whatever reason. #@markdown If your input has multiple phages, you can click SEPARATE. #@markdown This will output separate GenBank files in the output directory. #@markdown The results of Phold will be in the folder icon on the left hand panel. #@markdown Additionally, it will be zipped so you can download the whole directory. #@markdown The file to download is PHOLD_OUT_DIR.zip, where PHOLD_OUT_DIR is what you provided #@markdown If you do not see the output directory, #@markdown refresh the window by either clicking the folder with the refresh icon below "Files" #@markdown or double click and select "Refresh". %%time import os import subprocess import zipfile # phold input is pharokka output PHOLD_INPUT = f"{PHAROKKA_OUT_DIR}/{PHAROKKA_PREFIX}.gbk" PHOLD_OUT_DIR = 'output_phold' #@param {type:"string"} PHOLD_PREFIX = 'phold' #@param {type:"string"} FORCE = True #@param {type:"boolean"} SEPARATE = False #@param {type:"boolean"} # Construct the command command = f"phold run -i {PHOLD_INPUT} -t 4 -o {PHOLD_OUT_DIR} -p {PHOLD_PREFIX} -d phold_db --foldseek_gpu" if FORCE is True: command = f"{command} -f" if SEPARATE is True: command = f"{command} --separate" # Execute the command try: print("Running phold") subprocess.run(command, shell=True, check=True) print("phold completed successfully.") print(f"Your output is in {PHOLD_OUT_DIR}.") print(f"Zipping the output directory so you can download it all in one go.") zip_filename = f"{PHOLD_OUT_DIR}.zip" # Zip the contents of the output directory with zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED) as zipf: for root, dirs, files in os.walk(PHOLD_OUT_DIR): for file in files: zipf.write(os.path.join(root, file), os.path.relpath(os.path.join(root, file), PHOLD_OUT_DIR)) print(f"Output directory has been zipped to {zip_filename}") except subprocess.CalledProcessError as e: print(f"Error occurred: {e}") ``` -------------------------------- ### Run Phynteny Analysis Source: https://github.com/gbouras13/pharokka/blob/master/run_pharokka_and_phold_and_phynteny.ipynb Executes the Phynteny tool to predict the function of hypothetical proteins using the output from Phold. It allows for specifying the output directory and an option to force overwriting. The results are then zipped for download. ```python #@title 6. Run Phynteny #@markdown This cell will run phynteny on the output of cell 5's Phold run to predict the function of remaining hypothetical proteins #@markdown You do not need to provide any further input files #@markdown You can now provide a directory for phynteny's output with PHYNTENY_OUT_DIR. #@markdown The default is 'output_phynteny'. #@markdown You can click FORCE to overwrite the output directory with . #@markdown This may be useful if your phynteny run has crashed for whatever reason. #@markdown The results of Phynteny will be in the folder icon on the left hand panel. #@markdown Additionally, it will be zipped so you can download the whole directory. #@markdown The file to download is PHYNTENY_OUT_DIR.zip, where PHYNTENY_OUT_DIR is what you provided #@markdown If you do not see the output directory, #@markdown refresh the window by either clicking the folder with the refresh icon below "Files" #@markdown or double click and select "Refresh". %%time import os import subprocess import zipfile # phynteny input is pharokka output PHYNTENY_INPUT = f"{PHOLD_OUT_DIR}/{PHOLD_PREFIX}.gbk" PHYNTENY_OUT_DIR = 'output_phynteny' #@param {type:"string"} FORCE = False #@param {type:"boolean"} # Construct the command command = f"phynteny_transformer -m /content/phynteny_models/models -o {PHYNTENY_OUT_DIR} {PHYNTENY_INPUT}" if FORCE is True: command = f"{command} -f" # Execute the command try: print("Running phynteny") subprocess.run(command, shell=True, check=True) print("phynteny completed successfully.") print(f"Your output is in {PHYNTENY_OUT_DIR}.") print(f"Zipping the output directory so you can download it all in one go.") zip_filename = f"{PHYNTENY_OUT_DIR}.zip" # Zip the contents of the output directory with zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED) as zipf: for root, dirs, files in os.walk(PHYNTENY_OUT_DIR): for file in files: zipf.write(os.path.join(root, file), os.path.relpath(os.path.join(root, file), PHYNTENY_OUT_DIR)) print(f"Output directory has been zipped to {zip_filename}") except subprocess.CalledProcessError as e: print(f"Error occurred: {e}") ``` -------------------------------- ### Pull Pharokka Container with Singularity Source: https://github.com/gbouras13/pharokka/blob/master/docs/install.md Downloads the Pharokka container image using Singularity. Specify the directory for the .sif file. ```bash IMAGE_DIR="" # e.g. to pull into the working directory IMAGE_DIR=$PWD singularity pull --dir $IMAGE_DIR docker://quay.io/biocontainers/pharokka:1.7.3--pyhdfd78af_0 ``` -------------------------------- ### Annotate Phage Genome Source: https://github.com/gbouras13/pharokka/blob/master/README.md Run the main pharokka annotation tool. Provide input phage FASTA file, output directory, database path, and number of threads. ```bash pharokka.py -i -o -d -t ``` -------------------------------- ### Create a New Branch Source: https://github.com/gbouras13/pharokka/blob/master/CONTRIBUTING.md Create a new branch for your bug fix or feature development. ```shell git checkout -b name-of-your-bugfix-or-feature ``` -------------------------------- ### Run Pharokka Multiplotter Source: https://github.com/gbouras13/pharokka/blob/master/docs/plotting.md Basic command to run the multiplotter script with input Genbank file and output directory. ```bash pharokka_multiplotter.py -g pharokka.gbk -o pharokka_plots_output_directory ``` -------------------------------- ### Clone Pharokka Repository Source: https://github.com/gbouras13/pharokka/blob/master/CONTRIBUTING.md Clone your forked repository of Pharokka to your local machine. ```shell git clone git@github.com:your_name_here/pharokka.git ``` -------------------------------- ### Create Custom HMM Database Source: https://github.com/gbouras13/pharokka/blob/master/docs/custom.md Use this script to generate HMM profiles from multiple sequence alignments (MSAs) in a specified input directory. The output is a single HMM file (`.h3m`) that can be used with pharokka. ```bash create_custom_hmm.py -i -o -p ```