Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • KnowNothing2
    Member
    • Sep 2013
    • 49

    Getting SAMtools to work on Ubuntu

    So I have my .sam file aligned from Bowtie2 and have dowloaded SAMtools and BCFtools. I added SAMtools to PATH using:

    export PATH:$PATH:#path/#to/SAMtools (I renamed whatever the samtools name was to just "SAMtools"

    Now, the instructions say that to convert from .sam to .bam, you simply type:

    samtools view -bS filename.SAM > filename.BAM

    However, no matter what I try I keep getting "samtools: command not found"

    What am I doing wrong?
  • ECO
    --Site Admin--
    • Oct 2007
    • 1360

    #2
    Can you run samtools from the full path?

    Did you download a compiled version?

    Comment

    • KnowNothing2
      Member
      • Sep 2013
      • 49

      #3
      Originally posted by ECO View Post
      Can you run samtools from the full path?

      Did you download a compiled version?
      So I'm very new at bioinformatics and linux. From what I'm reading, I need to "make" SAMtools. I'm doing to exact same thing it says under "Installing SAMtools"


      However, I get an error that says

      make[1]: Entering directory `/home/adam/SAMtools'
      make[2]: Entering directory `/home/adam/SAMtools'
      gcc -c -g -Wall -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_USE_KNETFILE -D_CURSES_LIB=1 -DBGZF_CACHE -I. bgzf.c -o bgzf.o
      In file included from bgzf.c:32:0:
      bgzf.h:33:18: fatal error: zlib.h: No such file or directory
      compilation terminated.
      make[2]: *** [bgzf.o] Error 1
      make[2]: Leaving directory `/home/adam/SAMtools'
      make[1]: *** [lib-recur] Error 1
      make[1]: Leaving directory `/home/adam/SAMtools'
      make: *** [all-recur] Error 1
      adam@ubuntu:~/SAMtools$ make samtools
      make[1]: Entering directory `/home/adam/SAMtools'
      gcc -c -g -Wall -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_USE_KNETFILE -D_CURSES_LIB=1 -DBGZF_CACHE -I. bgzf.c -o bgzf.o
      In file included from bgzf.c:32:0:
      bgzf.h:33:18: fatal error: zlib.h: No such file or directory
      compilation terminated.
      make[1]: *** [bgzf.o] Error 1
      make[1]: Leaving directory `/home/adam/SAMtools'
      make: *** [lib-recur] Error 1

      Comment

      • GenoMax
        Senior Member
        • Feb 2008
        • 7142

        #4
        You need to install zlib (which is missing) via apt-get. Then try the "make" again.

        $sudo apt-get install zlib1g-dev
        or you can use "Ubuntu software center". Search for "zlib1g-dev" and then install.

        PS: Taking a chance and assuming that you are using Ubuntu (since many "new to unix" people do).
        Last edited by GenoMax; 10-16-2013, 10:33 AM.

        Comment

        • KnowNothing2
          Member
          • Sep 2013
          • 49

          #5
          Originally posted by GenoMax View Post
          You need to install zlib (which is missing) via apt-get. Then try the "make" again.



          or you can use "Ubuntu software center". Search for "zlib1g-dev" and then install.

          PS: Taking a chance and assuming that you are using Ubuntu (since many "new to unix" people do).
          I did sudo apt-get install build-essential, which supposedly has the make function in it. Do i still need zlib1g-dev?

          yes, ubuntu 12.04 LTS
          Last edited by KnowNothing2; 10-16-2013, 10:57 AM.

          Comment

          • eco32i
            Member
            • Jul 2012
            • 10

            #6
            Better yet, just do:
            $ sudo apt-get install samtools

            this should take care of the required dependencies.

            Comment

            • GenoMax
              Senior Member
              • Feb 2008
              • 7142

              #7
              Originally posted by KnowNothing2 View Post
              I did sudo apt-get install build-essential, which supposedly has the make function in it. Do i still need zlib1g-dev?

              yes, ubuntu 12.04 LTS
              You do. "zlib1g-dev" provides "libraries" (e.g. zlib.h) which are needed by the "make" to compile samtools. This is basically code that can be used by multiple applications. WikiPedia link for explanation of "libraries": http://en.wikipedia.org/wiki/Library_%28computing%29

              Comment

              • GenoMax
                Senior Member
                • Feb 2008
                • 7142

                #8
                Originally posted by eco32i View Post
                Better yet, just do:
                $ sudo apt-get install samtools

                this should take care of the required dependencies.
                Indeed. Samtools appears to be available from ubuntu software center. I am not sure what version though. Is it the latest?

                Comment

                • eco32i
                  Member
                  • Jul 2012
                  • 10

                  #9
                  Version: 0.1.18 (r982:295)

                  But I am on 13.04. It's probably behind on LTS.

                  Comment

                  • KnowNothing2
                    Member
                    • Sep 2013
                    • 49

                    #10
                    Originally posted by GenoMax View Post
                    You do. "zlib1g-dev" provides "libraries" (e.g. zlib.h) which are needed by the "make" to compile samtools. This is basically code that can be used by multiple applications. WikiPedia link for explanation of "libraries": http://en.wikipedia.org/wiki/Library_%28computing%29
                    Cool, so I installed that and reran "make" in my SAMtools directory. It made a bunch of 'object' files. Now I tried rerunning my code:

                    samtools view -bS filename.sam > filename.bam

                    And it still stays:

                    samtools: command not found

                    Theres mention of moving the samtools binary into PATH. Which file is the binary?

                    I added #path/to/SAMtools to my PATH, but it still doesnt work.
                    Last edited by KnowNothing2; 10-16-2013, 11:23 AM.

                    Comment

                    • GenoMax
                      Senior Member
                      • Feb 2008
                      • 7142

                      #11
                      Originally posted by KnowNothing2 View Post
                      Cool, so I installed that and reran "make" in my SAMtools directory. It made a bunch of 'object' files. Now I tried rerunning my code:

                      samtools view -bS filename.sam > filename.bam

                      And it still stays:

                      samtools: command not found

                      Theres mention of moving the samtools binary into PATH. Which file is the binary?
                      In your SAMtools directory there should be a file called "samtools". Name should be "green" in color if you are using the default terminal in ubuntu, which indicates that it is an "executable" file.

                      You can run the command this way:

                      Code:
                      $/home/adam/SAMtools/samtools view -bS filename.sam > filename.bam

                      Comment

                      • eco32i
                        Member
                        • Jul 2012
                        • 10

                        #12
                        Originally posted by KnowNothing2 View Post
                        Cool, so I installed that and reran "make" in my SAMtools directory. It made a bunch of 'object' files. Now I tried rerunning my code:

                        samtools view -bS filename.sam > filename.bam

                        And it still stays:

                        samtools: command not found

                        Theres mention of moving the samtools binary into PATH. Which file is the binary?

                        I added #path/to/SAMtools to my PATH, but it still doesnt work.
                        Run $ sudo make install after you run make. This will put the binaries where they are expected to be on the system.

                        Comment

                        • KnowNothing2
                          Member
                          • Sep 2013
                          • 49

                          #13
                          Thanks everyone. I just made it easy on myself and ran apt-get install samtools. Worked right away.

                          Comment

                          • sophiespo
                            Member
                            • Apr 2013
                            • 15

                            #14
                            export PATH:$PATH:#path/#to/SAMtools (I renamed whatever the samtools name was to just "SAMtools"
                            is wrong.

                            It should be:

                            export PATH=$PATH:/path/to/SAMtools
                            Last edited by sophiespo; 10-16-2013, 11:51 PM.

                            Comment

                            • KnowNothing2
                              Member
                              • Sep 2013
                              • 49

                              #15
                              Originally posted by sophiespo View Post
                              is wrong.

                              It should be:
                              Yeah, I did it the correct way, sorry just sloppy notation. When I performed

                              echo $PATH

                              I saw my directory.

                              Comment

                              Latest Articles

                              Collapse

                              • SEQadmin2
                                Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                                by SEQadmin2


                                Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

                                The systematic characterization of the human proteome has
                                ...
                                07-20-2026, 11:48 AM
                              • SEQadmin2
                                Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                                by SEQadmin2



                                Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                                ...
                                07-09-2026, 11:10 AM
                              • SEQadmin2
                                Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                                by SEQadmin2



                                Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                                There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                                07-08-2026, 05:17 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by SEQadmin2, 07-24-2026, 12:17 PM
                              0 responses
                              16 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 07-23-2026, 11:41 AM
                              0 responses
                              17 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 07-20-2026, 11:10 AM
                              0 responses
                              23 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 07-13-2026, 10:26 AM
                              0 responses
                              37 views
                              0 reactions
                              Last Post SEQadmin2  
                              Working...