Seqanswers Leaderboard Ad

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
                        Recent Developments in Metagenomics
                        by seqadmin





                        Metagenomics has improved the way researchers study microorganisms across diverse environments. Historically, studying microorganisms relied on culturing them in the lab, a method that limits the investigation of many species since most are unculturable1. Metagenomics overcomes these issues by allowing the study of microorganisms regardless of their ability to be cultured or the environments they inhabit. Over time, the field has evolved, especially with the advent...
                        09-23-2024, 06:35 AM
                      • seqadmin
                        Understanding Genetic Influence on Infectious Disease
                        by seqadmin




                        During the COVID-19 pandemic, scientists observed that while some individuals experienced severe illness when infected with SARS-CoV-2, others were barely affected. These disparities left researchers and clinicians wondering what causes the wide variations in response to viral infections and what role genetics plays.

                        Jean-Laurent Casanova, M.D., Ph.D., Professor at Rockefeller University, is a leading expert in this crossover between genetics and infectious...
                        09-09-2024, 10:59 AM

                      ad_right_rmr

                      Collapse

                      News

                      Collapse

                      Topics Statistics Last Post
                      Started by seqadmin, 10-02-2024, 04:51 AM
                      0 responses
                      13 views
                      0 likes
                      Last Post seqadmin  
                      Started by seqadmin, 10-01-2024, 07:10 AM
                      0 responses
                      22 views
                      0 likes
                      Last Post seqadmin  
                      Started by seqadmin, 09-30-2024, 08:33 AM
                      0 responses
                      26 views
                      0 likes
                      Last Post seqadmin  
                      Started by seqadmin, 09-26-2024, 12:57 PM
                      0 responses
                      19 views
                      0 likes
                      Last Post seqadmin  
                      Working...
                      X