Extracting unmapped reads from a sam file and converting to fastq
0
0
Entering edit mode
8 days ago
drmodupe06 • 0

Hi, I am new to bioinformatics so please be kind.

I am trying to retrieve unmapped reads from a sam file named aln.sam on command line (HPC). I have installed samtools and I ran it with this code:

module load bioconda
conda install -c bioconda samtools
cd /path to working directory
samtools view -f 4 -i aln.sam > unmapped_reads.sam

The error message I get is

/tmp/slurmd/job...../slurm_script: samtools: command not found.

I need help correcting this and how do I convert the unmapped reads to a fastq file.

samtools • 431 views
ADD COMMENT
0
Entering edit mode

It means that the directory where conda installed samtools is not available from the nodes that are running your SLURM job. Can you show us your exact SLURM submission command/script? At a minimum you will need to conda activate for this to work.

You should need to install conda only once while creating a new environment. After that you will only need to conda activate env.

ADD REPLY
0
Entering edit mode

Thanks. The slurm script script is :

#!/bin/bash
#SBATCH --job-name
#SBATCH --account
#SBATCH --partition=compute
#SBATCH --cpus-per-task
#SBATCH --time =

module load bioconda
conda install -c bioconda samtools
conda activate nanopore_env

cd /path to working directory

samtools view -f 4 -i aln.sam > unmapped_reads.sam
ADD REPLY
1
Entering edit mode

conda activate nanopore_env

What environment is this and how is it related to original question?

As noted already, see if your cluster already has a module for samtools (or another program that depends on samtools, which is bound to include samtools) and just load that module. Doing the conda install inside slurm script is not good practice. If you want to do that do it outside script and activate the environment before submitting the job (or inside the script).

ADD REPLY
0
Entering edit mode

It just means that it does not find the tool samtools. Create conda environment(cona create), activate it (conda activate), install samtools inside the env (conda install).

ADD REPLY
0
Entering edit mode

Thank you so much

ADD REPLY
0
Entering edit mode

Are you sure they haven't installed samtools as a module already?

ADD REPLY
0
Entering edit mode

no it wasnt, if it was wouldnt it recognize the command?

ADD REPLY
1
Entering edit mode

Not by default. You will have to module load samtools for that command to become available.

ADD REPLY
0
Entering edit mode

Thank you everyone, the command has been recognized.

ADD REPLY
0
Entering edit mode

Which solution worked (from above)? I can move that comment to an answer. You can accept the answer (green check mark) to provide closure to this thread.

ADD REPLY

Login before adding your answer.

Traffic: 3429 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6