Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Greg
    Member
    • Oct 2009
    • 31

    BAM quality how to convert illumina 1.5 to 1.9?

    Welcoming 2014 the best way I know...

    I've aligned a good deal of illumina data I have accumulated in order to call SNPs with GATK. I had over looked the fact that some of the older runs are with the illumina 1.5 (phred+64) quality encoding. GATK does not like this. I would like to convert the BAM files to 1.9/sanger/phred+33 quality. Can anyone recommend a tool that would do this? If I have to do it to fastq files so be it... I will happily take recommendations for that conversion although there seems to be more options available.

    Thank you and happy new year.

    p.s. if there is a way to inform GATK that specific files have different encoding I am all ears.
  • Zapages
    Member
    • Oct 2012
    • 98

    #2
    I think you could convert BAM to FastQ using Samtools and then use FASTQ Groomer to convert FastQsanger format on the Galaxy.

    http://www.biostars.org/p/770/ and https://usegalaxy.org/u/dan/p/fastq

    I hope this helps.

    Comment

    • Greg
      Member
      • Oct 2009
      • 31

      #3
      Thanks Zapages,
      Looks like a do-able work around BUT i would like to avoid uploading data to galaxy if possible...

      Comment

      • dpryan
        Devon Ryan
        • Jul 2011
        • 3478

        #4
        Given that you have multiple files and they're probably not terribly small, a C-based solution is likely preferred:

        Code:
        #include "bam.h"
        
        int main(int argc, char *argv[]) {
            int i;
            uint8_t *qual;
            bam_header_t *header;
            char *oname, *p;
            bam1_t *read;
            bamFile f, of;
        
            if(argc != 2 || strcmp(argv[1], "-h") == 0) {
                printf("Usage: %s file.bam\n", argv[0]);
                printf("Converts a BAM file with Phred scores encoded as QUAL+64 into the standard QUAL+33 format\n");
                return -1;
            }
        
            //Open the input
            f = bam_open(argv[1], "rb");
            header = bam_header_read(f);
            read = bam_init1();
        
            //Create the output file
            oname = strdup(argv[1]);
            oname = realloc(oname, sizeof(char) * (strlen(argv[1]) + strlen(".recalibrated ")));
            p = strrchr(oname, '.');
            *p = '\0';
            sprintf(oname, "%s.recalibrated.bam", oname);
            of = bam_open(oname, "wb");
            bgzf_mt(of, 4, 256); //Use 4 compression threads
        
            //Write the header
            bam_header_write(of, header);
        
            //Iterate over the reads
            while(bam_read1(f, read) > 1) {
                qual = bam1_qual(read);
                for(i=0; i<read->core.l_qseq; i++) *(qual+i) -= 31;
                bam_write1(of, read);
            }
        
            bam_close(of);
            bam_close(f);
            bam_destroy1(read);
            free(oname);
            return 0;
        }
        This uses the samtools C API. If you download the samtools source code and compile it in "/home/your_user_name/Downloads/samtools", then compilation would be something of the form:

        Code:
        gcc -Wall -o convert convert.c -lbam -lz -lpthread -I/home/your_user_name/Downloads/samtools -L/home/your_user_name/Downloads/samtools
        If you saved the above code as convert.c, at least. The you could just:

        Code:
        convert somefile.bam
        Assuming the program is in your PATH, this will produce "somefile.recalibrated.bam".

        Comment

        • Greg
          Member
          • Oct 2009
          • 31

          #5
          Wow, awesome. This is exactly what I was hoping for. I will give it a try right away and let you know how it goes.

          Comment

          • Greg
            Member
            • Oct 2009
            • 31

            #6
            dpryan, I successfully compiled and ran your program. Unfortunately, as far as I can tell the resulting bam files are no longer indexed and I think have also been stripped of the read group header info. Is it possible to use this and still retain that information?
            Thanks!

            Comment

            • dpryan
              Devon Ryan
              • Jul 2011
              • 3478

              #7
              The indexing will be different every time, so I doubt there's a good way to maintain that. The read groups should actually be maintained, I'm surprised they've not been. Can you post the header and a couple example alignments from a file before/after conversion where the read group wasn't kept? I'm not sure why that would happen, but that'd give me something to use to find the cause.

              Comment

              • Greg
                Member
                • Oct 2009
                • 31

                #8
                In getting examples ready for you I realized I made an embarrassingly simple error. Your script works great. Thanks again! Happy new year.

                Comment

                • dpryan
                  Devon Ryan
                  • Jul 2011
                  • 3478

                  #9
                  Cool, glad it worked!

                  Comment

                  Latest Articles

                  Collapse

                  • mylaser
                    Reply to Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                    by mylaser
                    The world of online gaming has grown tremendously over the past few years, giving players access to exciting sports, casino games, and interactive entertainment from the comfort of their homes. Among the platforms gaining attention, Kheloyaar has become a trusted destination for users seeking a fast, secure, and engaging gaming experience.
                    Whether you're a first-time visitor or an existing user, understanding the features of Kheloyar and the Kheloyaar login process can help you enjoy everything...
                    Today, 12:33 AM
                  • SEQadmin2
                    Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                    by SEQadmin2


                    Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

                    The systematic characterization of the human proteome has
                    ...
                    Yesterday, 11:48 AM
                  • SEQadmin2
                    Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                    by SEQadmin2



                    Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                    ...
                    07-09-2026, 11:10 AM

                  ad_right_rmr

                  Collapse

                  News

                  Collapse

                  Topics Statistics Last Post
                  Started by SEQadmin2, Yesterday, 11:10 AM
                  0 responses
                  8 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 07-13-2026, 10:26 AM
                  0 responses
                  30 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 07-09-2026, 10:04 AM
                  0 responses
                  39 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 07-08-2026, 10:08 AM
                  0 responses
                  25 views
                  0 reactions
                  Last Post SEQadmin2  
                  Working...