Seqanswers Leaderboard Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Graham Etherington
    Member
    • Apr 2010
    • 22

    Samtools Pileup Parser

    Hi,
    I'm trying to parse the Samtools Pileup format in Perl.

    I've created a paired-end assembly using BWA (aln, sampe) and then used Samtools to create a pileup (using import - sort - index - pileup).

    What I want to do is to open up the pileup (which is obviously in the Samtools Pileup format) and iterate over each position of the pileup, examining differences in base-calls.

    Does anyone know of anything available, or have and sample code they could post?
    Many thanks.
  • Pepe
    Member
    • Mar 2009
    • 30

    #2
    You cannot open a file in Pileup format with Bio:B::sam

    You should convert your SAM file to BAM format (samtools view) and sort it (samtools sort), maybe index it too? I'm not sure (samtools index).

    Then follow the instructions in the CPAN website, which are very, veryhelpful. Basically:

    use Bio:B::Sam;
    my $sam = Bio:B::Sam->new(-bam => "my_sorted_bam_file.bam",
    -fasta => "my_ref.fasta");
    my @targets = $sam->seq_ids;
    foreach my $chr (@targets){
    $sam->pileup($chr,$my_subroutine);
    }

    where $my_subroutine is a subroutine that you'll need to get to do what you want: snp calling, coverage calculation...

    Comment

    • Graham Etherington
      Member
      • Apr 2010
      • 22

      #3
      Originally posted by Pepe View Post
      You cannot open a file in Pileup format with Bio:B::sam

      You should convert your SAM file to BAM format (samtools view) and sort it (samtools sort), maybe index it too? I'm not sure (samtools index).

      Then follow the instructions in the CPAN website, which are very, veryhelpful. Basically:

      use Bio:B::Sam;
      my $sam = Bio:B::Sam->new(-bam => "my_sorted_bam_file.bam",
      -fasta => "my_ref.fasta");
      my @targets = $sam->seq_ids;
      foreach my $chr (@targets){
      $sam->pileup($chr,$my_subroutine);
      }

      where $my_subroutine is a subroutine that you'll need to get to do what you want: snp calling, coverage calculation...
      Hi,
      Thanks for your answer. I'd realised that Bio:B:Sam couldn't parse the pileup, so this is why I am asking if anyone has, or knows about, anything that could parse it, before I spent time writing a Samtools parser myself.
      I have a 'Parser.pm' module that parses various pileup formats (maq, bowtie, novoalign, etc), but I haven't added one for Samtools format yet.
      Cheers,
      Graham

      Comment

      • nekrut
        Member
        • Apr 2009
        • 22

        #4
        Galaxy's (http://usegalaxy.org) pileup parser might do the trick:

        Comment

        • Graham Etherington
          Member
          • Apr 2010
          • 22

          #5
          Originally posted by nekrut View Post
          Galaxy's (http://usegalaxy.org) pileup parser might do the trick:
          http://bit.ly/cXtqD9
          Thanks. That should give me enough to get started with.
          Best wishes,
          Graham

          Comment

          • cschu
            Junior Member
            • Aug 2012
            • 1

            #6
            I noticed that the referenced Galaxy code does not check for the '>' and '<' characters. Can anybody please provide some help how to process those? I.e., I don't really understand what "reference skip" means and would think that such a symbol means that the read does not cover the the respective position. Any help would be appreciated, thanks!

            Comment

            Latest Articles

            Collapse

            • seqadmin
              Pathogen Surveillance with Advanced Genomic Tools
              by seqadmin




              The COVID-19 pandemic highlighted the need for proactive pathogen surveillance systems. As ongoing threats like avian influenza and newly emerging infections continue to pose risks, researchers are working to improve how quickly and accurately pathogens can be identified and tracked. In a recent SEQanswers webinar, two experts discussed how next-generation sequencing (NGS) and machine learning are shaping efforts to monitor viral variation and trace the origins of infectious...
              03-24-2025, 11:48 AM
            • seqadmin
              New Genomics Tools and Methods Shared at AGBT 2025
              by seqadmin


              This year’s Advances in Genome Biology and Technology (AGBT) General Meeting commemorated the 25th anniversary of the event at its original venue on Marco Island, Florida. While this year’s event didn’t include high-profile musical performances, the industry announcements and cutting-edge research still drew the attention of leading scientists.

              The Headliner
              The biggest announcement was Roche stepping back into the sequencing platform market. In the years since...
              03-03-2025, 01:39 PM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by seqadmin, 03-20-2025, 05:03 AM
            0 responses
            42 views
            0 reactions
            Last Post seqadmin  
            Started by seqadmin, 03-19-2025, 07:27 AM
            0 responses
            52 views
            0 reactions
            Last Post seqadmin  
            Started by seqadmin, 03-18-2025, 12:50 PM
            0 responses
            38 views
            0 reactions
            Last Post seqadmin  
            Started by seqadmin, 03-03-2025, 01:15 PM
            0 responses
            194 views
            0 reactions
            Last Post seqadmin  
            Working...