Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • njh_TO
    Junior Member
    • Nov 2011
    • 4

    #1

    Perl: get specific base from FASTA file.

    I've written a piece of Perl code that retrieves a base from a FASTA file, given the contig label (e.g. chr1) and base position. However- I think it runs slowly, and am sure is not optimal: mainly because requests are usually made in an ordered manner, which is not reflected by my code.

    Is anyone aware of a function that has already been written to do this well?
  • Dameon
    Member
    • Dec 2011
    • 14

    #2
    samtools faidx /path/to/your/genome.fa chr1:base_position

    Comment

    • njh_TO
      Junior Member
      • Nov 2011
      • 4

      #3
      Fast response- thanks

      Comment

      • Dameon
        Member
        • Dec 2011
        • 14

        #4
        No problem. I was just incorporating that little bit into one of my perl scripts yesterday. Glad it could help.

        Comment

        • njh_TO
          Junior Member
          • Nov 2011
          • 4

          #5
          FYI:
          using Benchmark:

          Rate mine samtools
          mine 111/s -- -92%
          samtools 1449/s 1201% --

          Comment

          • krobison
            Senior Member
            • Nov 2007
            • 734

            #6
            Are you using Bio:: DB ::Fasta? (Apologies for the spaces; otherwise the I get a smilie version: Bio:B::Fasta)

            For your benchmark, are you calling samtools repeatedly or once? If you have multiple requests, better to batch them up and call samtools -- there's an overhead in process creation and probably in firing up samtools.

            Comment

            • njh_TO
              Junior Member
              • Nov 2011
              • 4

              #7
              Thanks. No, I'm not- but I'll take a look.

              Not sure how you would go about bundling these requests, is it possible to pass samtools an array of positions, returning a corresponding array of bases?

              Benchmarking calls the following function X times.

              Currently looks something like:

              sub getFASTABaseSamtools
              {
              my $chrID = shift;
              my $basepos = shift;
              my $fastapath = shift;
              my @result = `samtools faidx $fastapath $chrID:$basepos-$basepos`;
              chomp($result[1]);
              return uc($result[1]);
              }

              Comment

              Latest Articles

              Collapse

              • SEQadmin2
                16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
                by SEQadmin2





                NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification,...
                10-30-2026, 06:46 AM
              • SEQadmin2
                Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
                by SEQadmin2



                Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

                Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
                ...
                10-14-2026, 09:55 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, 11-05-2026, 09:25 AM
              0 responses
              20 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 11-03-2026, 11:54 AM
              0 responses
              34 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 10-28-2026, 09:57 AM
              0 responses
              82 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 10-28-2026, 09:51 AM
              0 responses
              50 views
              0 reactions
              Last Post SEQadmin2  
              Working...