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
                                From Collection to Sequencing: Why Sample Preparation and Preservation Define Sequencing Data
                                by SEQadmin2


                                Data variability is still an issue in sequencing technologies despite the advances in reproducibility and accuracy of these platforms. But the problem does not originate in the sequencing itself, but in the previous steps, before the sample reaches the sequencer.


                                The first step is collection, followed by preservation and sample preparation for analysis. Most scientists overlook those steps, but not being careful might just be skewing the experiment’s results.
                                ...
                                06-02-2026, 10:05 AM
                              • SEQadmin2
                                Single-Cell Sequencing at an Inflection Point: Early Impacts of New Platforms and Emerging Trends
                                by SEQadmin2


                                With the launch of new single-cell sequencing platforms in 2026, the field stands at an exciting inflection point. This article surveys the most impactful advances in the field and discusses how they’re reshaping research in cancer, immunology, and beyond.


                                Introduction

                                Single-cell sequencing technologies have undergone remarkable advances over the past decade, transitioning from low-throughput experimental approaches to highly scalable platforms capable of...
                                05-22-2026, 06:42 AM
                              • SEQadmin2
                                Environmental Genomics in the Age of NGS: From Microbes to Conservation Strategies
                                by SEQadmin2

                                Studying ecosystems means dealing with complex, multi-species communities that are hard to observe at scale. This complexity, however, hides many important questions to be answered, from how biogeochemical cycles work and how climate change can affect species distribution to how conservation strategies can work best.


                                Genomics, particularly since the expansion of NGS, has transformed ecosystem ecology. By sequencing environmental DNA, we can now assess biodiversity without direct...
                                05-06-2026, 09:04 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by SEQadmin2, Today, 08:59 AM
                              0 responses
                              8 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 06-02-2026, 12:03 PM
                              0 responses
                              21 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 06-02-2026, 11:40 AM
                              0 responses
                              16 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 05-28-2026, 11:40 AM
                              0 responses
                              29 views
                              0 reactions
                              Last Post SEQadmin2  
                              Working...