Unconfigured Ad

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

    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
                  Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                  by SEQadmin2


                  I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

                  Here are nine questions we think about, in roughly the order they matter, before...
                  06-18-2026, 07:11 AM
                • 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

                ad_right_rmr

                Collapse

                News

                Collapse

                Topics Statistics Last Post
                Started by SEQadmin2, 06-17-2026, 06:09 AM
                0 responses
                37 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 06-09-2026, 11:58 AM
                0 responses
                100 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 06-05-2026, 10:09 AM
                0 responses
                121 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 06-04-2026, 08:59 AM
                0 responses
                113 views
                0 reactions
                Last Post SEQadmin2  
                Working...