This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Samtools sort error

Hello,

I've got a SAM file that was aligned using HISAT2, I've converted it into a BAM file using samtools view, I then wanted to sort it using samtools sort and this output comes out and just keeps going and going so I stop it.

G{�q�[�p�Π�������3FqB��m6�p�0���ꜘ-â��&�S��]��qn�Շ��67^�Q<GK?��=c<�>d�9�.�!�.���� 0�_�f*:�h?��'�4��닱�؍7Kp•�}�
              <�}�q۵��"�<���W�(�N��v�Zf��YTW�P�:�����v23l��2�
�q��@��
       /�6D&������]�ש���
�Dtc+q�ʔ)�}���zX��g�=;ήT�D��9��B�)�|��J��   N<e���֐٘3����e>��D�R"@�E9bꁞJ���H��r�0F`���n�{�aW��(���AIu�����\xq�o��A������\{�;�u9�W%����/ٍ%��o8
                                                     ��Z(�j[�EV=����@�A�Fsf�W9�-�t4�;���b�!���
��'6�����m�$v�f�e&���������u�Ni�5sZ�Dq���s&������s�y@Lʑas{�qM��S����1��95|^>��w�9�¢52��1k��|r���z�gC�bV�]�7���B,F��{��'�f1Ƶв�XH%�
                                            �'lzů��
X8���`ʁL�  
                k^{{�h���L�IS���?���v�ե0����H���f��hأ)<kI���~   �˟���4hQ�"�j*�tN�fltT��)�>�J��PVՄ������cbT�ډ�5��b�2xg�!���).����cS����c7���jS�pq

The ultimate goal is that I want to convert my sam file into a bam file and then index it to help with viewing. Would anyone know of a way around this or how to fix this?

samtools rnaseq

samtools has very convenient help information on the command line. Just type samtools or samtools sort to get usage information. In addition, which version are you using?

I almost feel sorry for the Biostars syntax highlighter :(

Write this stuff out to a file with "> sorted.bam"

I am pleased that the site did not blow up to pieces when a BAM file is posted - though the RSS feed did.

As for the answer, what you have there is a binary, BAM file that is being output to your screen. Redirect it or use the manual to see how to save that into a file rather than a screen.

Yes yes lets all troll the ubuntu newbie :) Thanks! Got it to work.

We promise not to .. only if use ADD REPLY/ADD COMMENT when responding to existing posts next time :) This helps keep threads logically organized.

Sorry...growing pains!

2 answers

Try rereading the samtools sort documentation (see man samtools, or here for the current version) and checking that you are giving the sort options and arguments correctly.

Don't worry! This is how a bam file should look like:) It is a binary version of the "human readable" sam file. If I look at the first few lines of one of my own bam files with "head mysample.bam", what I see looks very similar to your output. If you want to see the "human readable" format again, use samtools: "samtools view mysample.bam | head" should show you the first lines of your bam file as you had it in the original sam file. As John suggested, write the output to a file and not to the screen.

Log in to answer this question.