Header Leaderboard Ad

Collapse

BAM/SAM to Fasta

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • BAM/SAM to Fasta

    Hi there,

    I have a couple of aligned sequences from BWA. I used samtools to get the BAM format. What I really need is the Fasta format of these aligned sequences. Is there a program that would help?

    Thanks.

  • #2
    Yes, several, including one line shell scripts.

    Possibly seqret from EMBOSS 6.3.x will do what you want.

    See also this thread for SAM/BAM to FASTQ which is very relevant:
    Discussion of next-gen sequencing related bioinformatics: resources, algorithms, open source efforts, etc

    Comment


    • #3
      Thanks Maubp, I just downloaded Emboss. I will get back if I bump into trouble.
      Thanks very much.

      Comment


      • #4
        This one liner would give you a fasta formatted file from a bam alignment:

        samtools view filename.bam | awk '{OFS="\t"; print ">"$1"\n"$10}' - > filename.fasta

        Hope this helps.

        Gabriel
        gabriele bucci

        Comment


        • #5
          Or picard SamToFastq:

          Works with BAM Files as well and supports some other options:

          Comment


          • #6
            Hi Gabriel,

            Is there a way to do the opposite ? What i mean is that, i have a file called mrna_ref.fa (fasta file), can i convert it into a sam or a bam file using Samtools in the command line.

            Regards
            Teja

            Comment


            • #7
              Hi Teja.
              In theory you can convert a multifasta file in a sam (tabular) file, and then convert to bam with samtools view -b.
              But the fasta file only contains information on the nucletide sequence itself, nothing about the mapping, read quality etc... which are indeed the columns of the sam file (you will also need to rebuild the sam header).
              In conclusion I think it's useless to convert a fasta file into a sam file, but I can't exclude that you are dealing with something that requires such conversion.
              Would please briefly explain your case?

              Thank you.

              Best regards.
              Gabriel
              gabriele bucci

              Comment


              • #8
                Hi

                Hi Gabriel,

                I want to send u the file. which is very small. Probably u can have a look at it .. Can u just send me a mail to this id, if its not a problem.

                [email protected]

                Regards
                Teja

                Comment


                • #9
                  Basically i have a Stand Alone Blast program running. The "fasta" file served as a reference file using which i blasted the large database file that i had. I am trying to find out if i can call SNP's using "Blast" program.

                  And i want to confirm it by getting the SNP's using Samtools.

                  Is the above explanation even valid. ?

                  Do let me know

                  Regards
                  Teja

                  Comment


                  • #10
                    Hi Gabriel,

                    I want to send u the file. which is very small. Probably u can have a look at it .. Can u just send me a mail to this id, if its not a problem.

                    [email protected]

                    Basically i have a Stand Alone Blast program running. The "fasta" file served as a reference file using which i blasted the large database file that i had. I am trying to find out if i can call SNP's using "Blast" program.

                    And i want to confirm it by getting the SNP's using Samtools.

                    Is the above explanation even valid. ?

                    Do let me know


                    Regards
                    Teja

                    Comment


                    • #11
                      Originally posted by tejaminnu View Post
                      Hi Gabriel,

                      I want to send u the file. which is very small. Probably u can have a look at it .. Can u just send me a mail to this id, if its not a problem.

                      [email protected]

                      Basically i have a Stand Alone Blast program running. The "fasta" file served as a reference file using which i blasted the large database file that i had. I am trying to find out if i can call SNP's using "Blast" program.

                      And i want to confirm it by getting the SNP's using Samtools.

                      Is the above explanation even valid. ?

                      Do let me know


                      Regards
                      Teja
                      Hi.
                      If I understand it right, you have to:
                      1) align your fasta query file (mrna_fa) to a reference with blast
                      2) parse the blast output to be compliant with sam
                      3) use samtools to call SNPs (to a properly indexed reference)

                      for point 2) you can look at here:
                      Discussion of next-gen sequencing related bioinformatics: resources, algorithms, open source efforts, etc


                      In general I can say that blast it's not suited for efficient SNP calling , but I may be wrong.

                      Gabriel
                      gabriele bucci

                      Comment

                      Latest Articles

                      Collapse

                      • seqadmin
                        How RNA-Seq is Transforming Cancer Studies
                        by seqadmin



                        Cancer research has been transformed through numerous molecular techniques, with RNA sequencing (RNA-seq) playing a crucial role in understanding the complexity of the disease. Maša Ivin, Ph.D., Scientific Writer at Lexogen, and Yvonne Goepel Ph.D., Product Manager at Lexogen, remarked that “The high-throughput nature of RNA-seq allows for rapid profiling and deep exploration of the transcriptome.” They emphasized its indispensable role in cancer research, aiding in biomarker...
                        09-07-2023, 11:15 PM
                      • seqadmin
                        Methods for Investigating the Transcriptome
                        by seqadmin




                        Ribonucleic acid (RNA) represents a range of diverse molecules that play a crucial role in many cellular processes. From serving as a protein template to regulating genes, the complex processes involving RNA make it a focal point of study for many scientists. This article will spotlight various methods scientists have developed to investigate different RNA subtypes and the broader transcriptome.

                        Whole Transcriptome RNA-seq
                        Whole transcriptome sequencing...
                        08-31-2023, 11:07 AM

                      ad_right_rmr

                      Collapse

                      News

                      Collapse

                      Topics Statistics Last Post
                      Started by seqadmin, Yesterday, 09:05 AM
                      0 responses
                      12 views
                      0 likes
                      Last Post seqadmin  
                      Started by seqadmin, 09-21-2023, 06:18 AM
                      0 responses
                      10 views
                      0 likes
                      Last Post seqadmin  
                      Started by seqadmin, 09-20-2023, 09:17 AM
                      0 responses
                      12 views
                      0 likes
                      Last Post seqadmin  
                      Started by seqadmin, 09-19-2023, 09:23 AM
                      0 responses
                      26 views
                      0 likes
                      Last Post seqadmin  
                      Working...
                      X