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
                        Strategies for Sequencing Challenging Samples
                        by seqadmin


                        Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
                        03-22-2024, 06:39 AM
                      • seqadmin
                        Techniques and Challenges in Conservation Genomics
                        by seqadmin



                        The field of conservation genomics centers on applying genomics technologies in support of conservation efforts and the preservation of biodiversity. This article features interviews with two researchers who showcase their innovative work and highlight the current state and future of conservation genomics.

                        Avian Conservation
                        Matthew DeSaix, a recent doctoral graduate from Kristen Ruegg’s lab at The University of Colorado, shared that most of his research...
                        03-08-2024, 10:41 AM

                      ad_right_rmr

                      Collapse

                      News

                      Collapse

                      Topics Statistics Last Post
                      Started by seqadmin, 03-27-2024, 06:37 PM
                      0 responses
                      12 views
                      0 likes
                      Last Post seqadmin  
                      Started by seqadmin, 03-27-2024, 06:07 PM
                      0 responses
                      11 views
                      0 likes
                      Last Post seqadmin  
                      Started by seqadmin, 03-22-2024, 10:03 AM
                      0 responses
                      52 views
                      0 likes
                      Last Post seqadmin  
                      Started by seqadmin, 03-21-2024, 07:32 AM
                      0 responses
                      68 views
                      0 likes
                      Last Post seqadmin  
                      Working...
                      X