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
                        Genetic Variation in Immunogenetics and Antibody Diversity
                        by seqadmin



                        The field of immunogenetics explores how genetic variations influence immune responses and susceptibility to disease. In a recent SEQanswers webinar, Oscar Rodriguez, Ph.D., Postdoctoral Researcher at the University of Louisville, and Ruben Martínez Barricarte, Ph.D., Assistant Professor of Medicine at Vanderbilt University, shared recent advancements in immunogenetics. This article discusses their research on genetic variation in antibody loci, antibody production processes,...
                        11-06-2024, 07:24 PM
                      • seqadmin
                        Choosing Between NGS and qPCR
                        by seqadmin



                        Next-generation sequencing (NGS) and quantitative polymerase chain reaction (qPCR) are essential techniques for investigating the genome, transcriptome, and epigenome. In many cases, choosing the appropriate technique is straightforward, but in others, it can be more challenging to determine the most effective option. A simple distinction is that smaller, more focused projects are typically better suited for qPCR, while larger, more complex datasets benefit from NGS. However,...
                        10-18-2024, 07:11 AM

                      ad_right_rmr

                      Collapse

                      News

                      Collapse

                      Topics Statistics Last Post
                      Started by seqadmin, Today, 11:09 AM
                      0 responses
                      21 views
                      0 likes
                      Last Post seqadmin  
                      Started by seqadmin, Today, 06:13 AM
                      0 responses
                      19 views
                      0 likes
                      Last Post seqadmin  
                      Started by seqadmin, 11-01-2024, 06:09 AM
                      0 responses
                      30 views
                      0 likes
                      Last Post seqadmin  
                      Started by seqadmin, 10-30-2024, 05:31 AM
                      0 responses
                      21 views
                      0 likes
                      Last Post seqadmin  
                      Working...
                      X