Question: Problem converting bam to sam (samtools)
gravatar for hinkel2
4.0 years ago by
hinkel210 wrote:

Hi guys!

I'm new to RNAseq data analysis and related bioinformatic pipelines. I just aligned my PE-reads to genome using Tophat2:

tophat2 -p 4 -G ../Arabidopsis_thaliana.TAIR10.31.gtf ../Arabidopsis_thaliana.TAIR10.31.dna.genome PE.reads.1.fastq.gz PE.reads.2.fastq.gz

I then get the default output files: accepted_hits.bam etc.,

"alignment_summary.txt" says:

Left reads: Input: 37579106 Mapped : 35638921 (94.8% of input) of these: 703952 ( 2.0%) have multiple alignments (23 have >20) Right reads: Input : 37579106 Mapped : 32462213 (86.4% of input) of these: 614654 ( 1.9%) have multiple alignments (23 have >20) 90.6% overall read mapping rate.

Aligned pairs: 31803489 of these: 601459 ( 1.9%) have multiple alignments 5799 ( 0.0%) are discordant alignments 84.6% concordant pair alignment rate.

For some further downstream processing steps of my data I need sam instead of bam. That's why I wanted to use samtools to convert bam to sam (as already described in some threads here). I know that it is also possible to create a sam output by using "--no-convert-bam" but I forgot to add this in my tophat2 run.

So what I did: samtools view -h -o accepted_hits.sam accepted_hits.bam

Error message:

samtools view: writing to "accepted_hits_sam" failed: File too large samtools view: error closing "accepted_hits.sam": -1

I basically don't know why the file should be too large now. Did anyone face this problem before? Thanks in advance!

rna-seq • 1.6k views
ADD COMMENTlink written 4.0 years ago by hinkel210

How about (if you are using an older version of samtools) : samtools view -h accepted_hits.bam > accepted_hits.sam

ADD REPLYlink modified 4.0 years ago • written 4.0 years ago by genomax92k
gravatar for Pierre Lindenbaum
4.0 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum131k wrote:

File too large

looks like a problem with your filesystem. e.g:

ADD COMMENTlink modified 4.0 years ago • written 4.0 years ago by Pierre Lindenbaum131k

Thank you!

I have a 64bit system (Ubuntu 16.04 LTS) on a dual boot machine. Is this file system problem due to the FAT32 and is there an easy way to fix it? Sorry for my noob questions.

ADD REPLYlink written 4.0 years ago by hinkel210

If I'm not mistaken FAT32 is limited to 4Gb files, which is likely too small for your sam file.

ADD REPLYlink written 4.0 years ago by WouterDeCoster44k

Two solutions come to mind:

  1. Break you BAM file into two by filtering on a chromosome or by coordinates.
  2. "Fake" the SAM file by streaming from the samtools view output.
ADD REPLYlink modified 4.0 years ago • written 4.0 years ago by Istvan Albert ♦♦ 85k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1961 users visited in the last hour