On Mon, 20 Apr 2020, Pedro Hollanda Carvalho wrote:

Hi, could anyone help me with this?

I'm trying to convert SAM to BAM using samtools view and I have the
following error message

$ sudo samtools view -bS Kp01.sam > Kp01.bam
-bash: Kp01.bam: Permission denied

Judging from the error message, you either don't have permission to create Kp01.bam in the current directory, or one already exists that you can't overwrite. Note that the '> Kp01.bam' part of the command above is being run as yourself, and not as root (via 'sudo').

Also, *** you should not be running samtools as root via sudo ***. It is not designed to be used that way. Instead, you should use sudo (if necessary) to create a directory where your normal account has write permissions, and then use that to store the results from samtools.

For example (assuming directory 'output' does not exist:

sudo mkdir output
sudo chown `whoami`.`groups | awk '{ print $1 }'` output
samtools view -bS Kp01.sam > output/Kp01.bam

I have already tried from different locations and used sudo command but
always got the same error

You probably need to check permissions of the various files and directories that you have made. If you have been using 'sudo' you may now have a mixture of ownership, which is likely to be painful. In general, you shouldn't use 'sudo' unless you really have to.

Rob Davies              r...@sanger.ac.uk
The Sanger Institute    http://www.sanger.ac.uk/
Hinxton, Cambs.,        Tel. +44 (1223) 834244
CB10 1SA, U.K.          Fax. +44 (1223) 494919


--
The Wellcome Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.

_______________________________________________
Samtools-help mailing list
Samtools-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/samtools-help

Reply via email to