VirSorter2: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
No edit summary
(for python 3.8 need StdEnv/2020)
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages />
<languages />
[[Category:Software]]
[[Category:Software]]
{{Draft}}


<translate>
<translate>


<!--T:1-->
__TOC__  
__TOC__  


<!--T:2-->
[https://microbiomejournal.biomedcentral.com/articles/10.1186/s40168-020-00990-y VirSorter2] is a tool to identify new viral sequences.
[https://microbiomejournal.biomedcentral.com/articles/10.1186/s40168-020-00990-y VirSorter2] is a tool to identify new viral sequences.


<!--T:3-->
This page discusses how to install and use VirSorter2 v2.2.4.
This page discusses how to install and use VirSorter2 v2.2.4.


<!--T:4-->
Source code and documentation for VirSorter2 can be found on their [https://github.com/jiarong/VirSorter2 GitHub page].
Source code and documentation for VirSorter2 can be found on their [https://github.com/jiarong/VirSorter2 GitHub page].


<!--T:5-->
Remember to [https://microbiomejournal.biomedcentral.com/articles/10.1186/s40168-020-00990-y#citeas cite] VirSorter2 if you use it for your analyses.
Remember to [https://microbiomejournal.biomedcentral.com/articles/10.1186/s40168-020-00990-y#citeas cite] VirSorter2 if you use it for your analyses.


== Installing VirSorter2 in a Python virtual environment ==
== Installing VirSorter2 in a Python virtual environment == <!--T:6-->
These instructions install VirSorter2 in your <tt>$HOME</tt> directory using Alliance's prebuilt [http://pythonwheels.com/ Python wheels]. Custom Python wheels are stored in <code>/cvmfs/soft.computecanada.ca/custom/python/wheelhouse/</code>. To install a VirSorter2 wheel, we will use the <code>pip</code> command and install it into a [[Python#Creating_and_using_a_virtual_environment | Python virtual environment]].
These instructions install VirSorter2 in your $HOME directory using Alliance's prebuilt [http://pythonwheels.com/ Python wheels]. Custom Python wheels are stored in <code>/cvmfs/soft.computecanada.ca/custom/python/wheelhouse/</code>. To install a VirSorter2 wheel, we will use the <code>pip</code> command and install it into a [[Python#Creating_and_using_a_virtual_environment | Python virtual environment]].


<!--T:7-->
1. Load the necessary modules.
1. Load the necessary modules.
{{Command
{{Command
|module load python/3.8 hmmer/3.3.2 prodigal/2.6.3
|module load StdEnv/2020 python/3.8 hmmer/3.3.2 prodigal/2.6.3
}}
}}
2. Create and activate a Python virtual environment.
2. Create and activate a Python virtual environment.
Line 34: Line 38:
|pip install --no-index virsorter{{=}}{{=}}2.2.4
|pip install --no-index virsorter{{=}}{{=}}2.2.4
}}
}}
4. Validate it.
4. Validate the installation.
{{Command
{{Command
|prompt=(ENV_virsorter) [name@server ~]
|prompt=(ENV_virsorter) [name@server ~]
Line 44: Line 48:
|pip freeze > ~/virsorter-2.2.4-requirements.txt
|pip freeze > ~/virsorter-2.2.4-requirements.txt
}}
}}
6. Download the database in <code>$SCRATCH</code> with the <code>--skip-deps-install</code> option to bypass conda installation and also because dependencies are already installed.
6. Download the database in $SCRATCH with the <code>--skip-deps-install</code> option to bypass conda installation and also because dependencies are already installed.
{{Command
{{Command
|prompt=(ENV_virsorter) [name@server ~]
|prompt=(ENV_virsorter) [name@server ~]
Line 50: Line 54:
}}
}}


== Testing VirSorter2 ==
== Testing VirSorter2 == <!--T:8-->
1. Download the test dataset in <code>$SCRATCH</code>.
1. Deactivate your virtual environment
{{Command
|deactivate
}}
 
<!--T:9-->
2. Download the test dataset in <code>$SCRATCH</code>.
{{Command
{{Command
|prompt=(ENV_virsorter) [name@server ~]
|wget -O $SCRATCH/test.fa https://raw.githubusercontent.com/jiarong/VirSorter2/master/test/8seq.fa
|wget -O $SCRATCH/test.fa https://raw.githubusercontent.com/jiarong/VirSorter2/master/test/8seq.fa
}}
}}
2. Create a submission script
3. Create a submission script
{{File
{{File
|name=test-virsorter.sh
|name=test-virsorter.sh
Line 63: Line 72:
#!/bin/bash
#!/bin/bash


<!--T:10-->
#SBATCH --time=00:30:00
#SBATCH --time=00:30:00
#SBATCH --mem-per-cpu=2G
#SBATCH --mem-per-cpu=2G
#SBATCH --cpus-per-task=2
#SBATCH --cpus-per-task=2


<!--T:11-->
# Load modules dependencies
# Load modules dependencies
module load python/3.8 hmmer/3.3.2 prodigal/2.6.3
module load StdEnv/2020 python/3.8 hmmer/3.3.2 prodigal/2.6.3


<!--T:12-->
# Generate your virtual environment in $SLURM_TMPDIR
# Generate your virtual environment in $SLURM_TMPDIR
virtualenv --no-download $SLURM_TMPDIR/ENV
virtualenv --no-download $SLURM_TMPDIR/ENV
Line 75: Line 87:
pip install --no-index --upgrade pip
pip install --no-index --upgrade pip


<!--T:13-->
# Install VirSorter2 and its dependencies
# Install VirSorter2 and its dependencies
pip install --no-index -r ~/virsorter-2.2.4-requirements.txt
pip install --no-index -r ~/virsorter-2.2.4-requirements.txt


<!--T:14-->
# Run VirSorter2 with the test dataset, using at most $SLURM_CPUS_PER_TASK and ignore conda.
# Run VirSorter2 with the test dataset, using at most $SLURM_CPUS_PER_TASK and ignore conda.
# The database must already exist and you must specify its location.
# The database must already exist and you must specify its location.
virsorter run -w $SCRATCH/test.out -i $SCRATCH/test.fa --min-length 1500 -j $SLURM_CPUS_PER_TASK --verbose --use-conda-off --db-dir $SCRATCH/db all
virsorter run -w $SCRATCH/test.out -i $SCRATCH/test.fa --min-length 1500 -j $SLURM_CPUS_PER_TASK --verbose --use-conda-off --db-dir $SCRATCH/db all
}}
}}
3. If needed, start an interactive job to make sure the submission script launches correctly.
3. Start an interactive job.
{{Command
{{Command
|prompt=(ENV_virsorter) [name@server ~]
|salloc --mem-per-cpu{{=}}2G --cpus-per-task{{=}}2 --account{{=}}<your-account>
|salloc --mem-per-cpu=2G --cpus-per-task=2 --account=<>
}}
 
and run the submission script:
{{Command
|prompt=(ENV_virsorter) [name@server ~]
|bash test-virsorter.sh
}}
When the submission script works in an interactive job, you can complete the test run in a non-interactive job.
4. Then, submit the job to the scheduler.
{{Command
|prompt=(ENV_virsorter) [name@server ~]
|sbatch --job-name test-virsorter2 test-virsorter.sh
}}
}}
salloc: Granted job allocation 1234567
$ bash test-virsorter.sh            # Run the submission script
$ exit                              # Terminate the allocation
salloc: Relinquishing job allocation 1234567


Upon a successful test run, you can run VirSorter2 using your own dataset.
<!--T:15-->
Upon a successful test run, you can submit a non-interactive job with your own dataset using [https://docs.alliancecan.ca/wiki/Running_jobs#Use_sbatch_to_submit_jobs <code>sbatch</code>].
</translate>
</translate>

Latest revision as of 17:57, 12 July 2024

Other languages:


VirSorter2 is a tool to identify new viral sequences.

This page discusses how to install and use VirSorter2 v2.2.4.

Source code and documentation for VirSorter2 can be found on their GitHub page.

Remember to cite VirSorter2 if you use it for your analyses.

Installing VirSorter2 in a Python virtual environment

These instructions install VirSorter2 in your $HOME directory using Alliance's prebuilt Python wheels. Custom Python wheels are stored in /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/. To install a VirSorter2 wheel, we will use the pip command and install it into a Python virtual environment.

1. Load the necessary modules.

Question.png
[name@server ~]$ module load StdEnv/2020 python/3.8 hmmer/3.3.2 prodigal/2.6.3

2. Create and activate a Python virtual environment.

[name@server ~]$ virtualenv --no-download ~/ENV_virsorter
[name@server ~]$ source ~/ENV_virsorter/bin/activate

3. Install VirSorter2 v2.2.4 in the virtual environment.

(ENV_virsorter) [name@server ~] pip install --no-index --upgrade pip
(ENV_virsorter) [name@server ~] pip install --no-index virsorter==2.2.4

4. Validate the installation.

Question.png
(ENV_virsorter) [name@server ~] virsorter -h

5. Freeze the environment and requirements set.

Question.png
(ENV_virsorter) [name@server ~] pip freeze > ~/virsorter-2.2.4-requirements.txt

6. Download the database in $SCRATCH with the --skip-deps-install option to bypass conda installation and also because dependencies are already installed.

Question.png
(ENV_virsorter) [name@server ~] virsorter setup --db-dir $SCRATCH/db -j 4 --skip-deps-install

Testing VirSorter2

1. Deactivate your virtual environment

Question.png
[name@server ~]$ deactivate

2. Download the test dataset in $SCRATCH.

Question.png
[name@server ~]$ wget -O $SCRATCH/test.fa https://raw.githubusercontent.com/jiarong/VirSorter2/master/test/8seq.fa

3. Create a submission script

File : test-virsorter.sh

#!/bin/bash

#SBATCH --time=00:30:00
#SBATCH --mem-per-cpu=2G
#SBATCH --cpus-per-task=2

# Load modules dependencies
module load StdEnv/2020 python/3.8 hmmer/3.3.2 prodigal/2.6.3

# Generate your virtual environment in $SLURM_TMPDIR
virtualenv --no-download $SLURM_TMPDIR/ENV
source $SLURM_TMPDIR/ENV/bin/activate
pip install --no-index --upgrade pip

# Install VirSorter2 and its dependencies
pip install --no-index -r ~/virsorter-2.2.4-requirements.txt

# Run VirSorter2 with the test dataset, using at most $SLURM_CPUS_PER_TASK and ignore conda.
# The database must already exist and you must specify its location.
virsorter run -w $SCRATCH/test.out -i $SCRATCH/test.fa --min-length 1500 -j $SLURM_CPUS_PER_TASK --verbose --use-conda-off --db-dir $SCRATCH/db all


3. Start an interactive job.

Question.png
[name@server ~]$ salloc --mem-per-cpu=2G --cpus-per-task=2 --account=<your-account>
salloc: Granted job allocation 1234567
$ bash test-virsorter.sh             # Run the submission script
$ exit                               # Terminate the allocation
salloc: Relinquishing job allocation 1234567

Upon a successful test run, you can submit a non-interactive job with your own dataset using sbatch.