Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manore
    Member
    • Jun 2011
    • 19

    #1

    fastq and hash table

    Hello,

    I would like to parse the file fastq in order to obtain a hash table with the key ID and value for the next 3 lines.

    I use the Bio::SeqIO::fastq module but how to obtain the score line?

    Code:
    my $seqio  = Bio::SeqIO::fastq->new('-format'=>'fastq' , '-file'=>'test.fastq');
    while((my $rec = $seqio->next_seq())) {
    	my $name = $rec->id();
    	my $seq= $rec->seq ;
    }
    --input--
    @HCDPQ1D0501
    GATTTGGGGTTCAAAGCAGTATCGATCAAATAGTAAATCCATTTGTTCAACTCACAGTTT.
    +HCDPQ1D0501
    !''*((((***+))%%%++)(%%%%).1***-+*''))**55CCF>>>>>>CCCCCCC65.....
  • kmcarr
    Senior Member
    • May 2008
    • 1181

    #2
    The when reading a fastq file Bio::SeqIO returns a Bio::Seq::Quality object. You can get an array reference to the quality values with the 'qual' method. To display the quality you would dereference the array and then format the list as a string. Here's my version of this:

    Code:
    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    use Bio::SeqIO;
    
    my $inputFile = shift;
    my $in = Bio::SeqIO->new(-format=>'fastq', -file=>"$inputFile");
    
    while ( my $data = $in->next_seq() ) {
    	my $id = $data->id();
    	my $seq = $data->seq();
    	my $qualref =  $data->qual();
    	my $format = "%2d" . ("%3d" x (@$qualref-1)) . "\n";
    	print "$id\n$seq\n";
    	printf $format, @$qualref;
    }
    $qualref is the array reference, dereference using @$qualref and print formatted (printf) output.

    [A note about your code above. You should not call Bio::SeqIO::fastq explicitly, just call Bio::SeqIO. The "-format=>'fastq'" parameter then calls the correct module.]

    Comment

    Latest Articles

    Collapse

    • SEQadmin2
      Beyond CRISPR/Cas9: Understand, Choose, and Use the Right Genome Editing Tool
      by SEQadmin2



      CRISPR/Cas9 sparked the gene editing revolution for both research and therapeutics.1 But this system still showed severe issues that limited its applications. The most prominent were the heavy reliance on PAM sequences, delivery limitations, double-stranded breaks that prompt unintended edits and cell death, and editing inefficiency (both in targeting and in knock-in reliability).

      Despite this, “CRISPR helped turn genome editing from a specialized technique into
      ...
      07-31-2026, 11:01 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
      ...
      07-20-2026, 11:48 AM

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by SEQadmin2, Yesterday, 12:22 PM
    0 responses
    14 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 08-11-2026, 10:35 AM
    0 responses
    16 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 08-06-2026, 07:41 AM
    0 responses
    31 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 08-03-2026, 10:13 AM
    0 responses
    50 views
    0 reactions
    Last Post SEQadmin2  
    Working...