text: user14985: Generally, I use samtools to sort and index BAM files. Samtools works also with BGZF compressed SAM but not with plain ones.
  I have terabytes of plain SAMs at the moment and I would love to avoid compression/conversion. I have all the data in several external HD and I am not allowed to delete the original SAM files. I would need much more space than I have now to also store the BAM files.
  So, I was wondering if there is a way to avoid it. Is there some tool/trick to sort and index uncompressed SAM files, without converting them to BAM or compressing them?
  
  user3967: Not only will you save disk space by converting to BAM, but BAM files are faster to manipulate than SAM. Source: Dave Tang's SAMTools wiki.
  sort supports uncompressed SAM format from a file or stdin, though index requires BGZIP-compressed SAM or BAM. I don't think you can get around this.
  If you're dead-set on reading from and writing to uncompressed SAM format, you can use pipes to avoid writing BAM files. Specify the output of view to be an uncompressed bam, then pipe it to your next command, then pipe it to view again to output your sorted SAM file.
  samtools view -u in.sam | samtools sort | samtools view -h > sort.sam
  samtools view -u sort.sam | samtools index
  
  
original_text: 14985: <p>Generally, I use <code>samtools</code> to <code>sort</code> and <code>index</code> BAM files. Samtools works also with BGZF compressed SAM but not with plain ones.</p>
  <p>I have terabytes of plain SAMs at the moment and I would love to avoid compression/conversion. I have all the data in several external HD and I am not allowed to delete the original SAM files. I would need much more space than I have now to also store the BAM files.</p>
  <p>So, I was wondering if there is a way to avoid it. Is there some tool/trick to sort and index uncompressed SAM files, without converting them to BAM or compressing them?</p>
   3967: <p>Not only will you save disk space by converting to BAM, but BAM files are faster to manipulate than SAM. Source: <a href="https://davetang.org/wiki/tiki-index.php?page=SAMTools#Converting_a_SAM_file_to_a_BAM_file" rel="noreferrer">Dave Tang's SAMTools wiki</a>.</p>
  <p><code>sort</code> supports uncompressed SAM format from a file or <code>stdin</code>, though <code>index</code> requires BGZIP-compressed SAM or BAM. I don't think you can get around this.</p>
  <p>If you're dead-set on reading from and writing to uncompressed SAM format, you can use pipes to avoid writing BAM files. Specify the output of <code>view</code> to be an uncompressed bam, then pipe it to your next command, then pipe it to <code>view</code> again to output your sorted SAM file.</p>
  <pre><code>samtools view -u in.sam | samtools sort | samtools view -h &gt; sort.sam
  samtools view -u sort.sam | samtools index
  </code></pre>
  