Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sharmi
    Junior Member
    • Apr 2014
    • 7

    #1

    samtools view giving error in reading .fa file

    Hi,

    I am new to Bioinformatics and I am trying to use the samtools view command. I have generated the SAM file but the header is missing so I followed this link (http://davetang.org/wiki/tiki-index.php?page=SAMTools) and tried the commands, but I get the following error -

    samtools view -bS new_test.sam > new_test.bam
    [samopen] no @SQ lines in the header.
    [sam_read1] missing header? Abort!
    cbil@cbil-desktop:~/bowtie-linux/bowtie-1.0.1$ samtools view -bT e_coli_1000.fa new_test.sam > new_test.bam
    [samfaipath] fail to read file e_coli_1000.fa.
    [main_samview] fail to open "new_test.sam" for reading.

    Can someone please help me?

    Thanks!
  • blancha
    Senior Member
    • May 2013
    • 367

    #2
    Converting a FASTA file (sequence file) directly to a BAM (Binary Alignment Map) file makes no sense to me.

    You would normally align your sequences in the FASTQ format to a reference genome in the FASTA format, using a program like Bowtie2, to generate a BAM file.

    Comment

    • dpryan
      Devon Ryan
      • Jul 2011
      • 3478

      #3
      @blancha: Sharmi isn't trying to convert a fasta file to BAM. His/her problem is that the SAM file lacks a header, which Sharmi is trying to replace with the -T option, though that won't work here since the e_coli_1000.fasta file isn't a reference sequence...

      @Sharmi: Don't use the --sam-nohead option with bowtie if that's what you did. The header from the example should be:

      Code:
      @HD     VN:1.0  SO:unsorted
      @SQ     SN:gi|110640213|ref|NC_008253.1|        LN:4938920
      @PG     ID:Bowtie       VN:1.0.1        CL:"./bowtie -S e_coli reads/e_coli_1000.fq"
      You could just add it in manually, since there output file is so small (remember to separate fields with a tab rather than a space).

      Comment

      • blancha
        Senior Member
        • May 2013
        • 367

        #4
        @dpryan: Yes, you are right. I was trying to be helpful, and answer a question instead of asking one for once, but my answer was wrong .

        Comment

        • dpryan
          Devon Ryan
          • Jul 2011
          • 3478

          #5
          @blancha: No worries and don't let that dissuade you from answering posts!

          Comment

          • Sharmi
            Junior Member
            • Apr 2014
            • 7

            #6
            Hi,
            Thank you for the reply. I am sorry I have a few questions-

            I have a e_coli_1000.fa.fai file in the bowtie folder, but if I use -
            cbil@cbil-desktop:~/bowtie-linux/bowtie-1.0.1$ samtools view -bt e_coli_1000.fa.fai new_test.sam > new_test.bam
            I get the following error -
            [main_samview] fail to open "new_test.sam" for reading.
            cbil@cbil-desktop:~/bowtie-linux/bowtie-1.0.1$

            Is it because of missing headers in the SAM file?

            If I compare the SAM file I have with the format mentioned in the link (http://biobits.org/samtools_primer.html), my files start with r0,r1 and the the -/+ for the reverse/forward and then gi... But in the link after the header section there is no r0 or r1. Is there something wrong with my SAM files?

            Also should I manually add the first three lines of the header in the SAM file? The current SAM file starts like this (sorry if the questions sound stupid, I am trying to learn the tools for my research) -
            r0 - gi|110640213|ref|NC_008253.1| 3658049 ATGCTGGAATGGCGATAGTTGGGTGGGTATCGTTC 45567778999:9;;<===>?@@@@AAAABCCCDE 0 32:T>G,34:G>A
            r1 - gi|110640213|ref|NC_008253.1| 1902085 CGGATGATTTTTATCCCATGAGACATCCAGTTCGG 45567778999:9;;<===>?@@@@AAAABCCCDE 0
            r2 - gi|110640213|ref|NC_008253.1| 3989609 CATAAAGCAACAGTGTTATACTATAACAATTTTGA 45567778999:9;;<===>?@@@@AAAABCCCDE 0
            r5 + gi|110640213|ref|NC_008253.1| 4249841 CAGCATAAGTGGATATTCAAAGTTTTGCTGTTTTA EDCCCBAAAA@@@@?>===<;;9:99987776554 0
            r7 + gi|110640213|ref|NC_008253.1| 4086913 GCATATTGCCAATTTTCGCTTCGGGGATCAGGCTA EDCCCBAAAA@@@@?>===<;;9:99987776554 0
            r8 + gi|110640213|ref|NC_008253.1| 2679194 GGTTCAGTTCAGTATACGCCTTATCCGGCCTACGG EDCCCBAAAA@@@@?>===<;;9:99987776554 0 14:A>T,33:C>G
            r9 - gi|110640213|ref|NC_008253.1| 2430559

            Thanks,
            Sharmi

            Comment

            • dpryan
              Devon Ryan
              • Jul 2011
              • 3478

              #7
              That error might be fixed by using the -S option, but if not it just means that "new_test.sam" doesn't exist in the current working directory.

              BTW, the example alignments you posted aren't in SAM format. That's probably the old bowtie format. Never use that.

              Comment

              • Sharmi
                Junior Member
                • Apr 2014
                • 7

                #8
                I have installed bowtie 1, do I need to install bowtie 2?

                Thanks!

                Comment

                Latest Articles

                Collapse

                • SEQadmin2
                  Beyond CRISPR/Cas9: Understand, Choose, and Use the Right Genome Editing Tool
                  by SEQadmin2



                  CRISPR/Cas9 sparked the gene editing revolution for both research and therapeutics.1 But this system still showed severe issues that limited its applications. The most prominent were the heavy reliance on PAM sequences, delivery limitations, double-stranded breaks that prompt unintended edits and cell death, and editing inefficiency (both in targeting and in knock-in reliability).

                  Despite this, “CRISPR helped turn genome editing from a specialized technique into
                  ...
                  07-31-2026, 11:01 AM
                • 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

                ad_right_rmr

                Collapse

                News

                Collapse

                Topics Statistics Last Post
                Started by SEQadmin2, 08-03-2026, 10:13 AM
                0 responses
                15 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-31-2026, 02:55 AM
                0 responses
                32 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-24-2026, 12:17 PM
                0 responses
                23 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-23-2026, 11:41 AM
                0 responses
                21 views
                0 reactions
                Last Post SEQadmin2  
                Working...