Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.....

  • #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

    • seqadmin
      Recent Advances in Sequencing Analysis Tools
      by seqadmin


      The sequencing world is rapidly changing due to declining costs, enhanced accuracies, and the advent of newer, cutting-edge instruments. Equally important to these developments are improvements in sequencing analysis, a process that converts vast amounts of raw data into a comprehensible and meaningful form. This complex task requires expertise and the right analysis tools. In this article, we highlight the progress and innovation in sequencing analysis by reviewing several of the...
      05-06-2024, 07:48 AM
    • seqadmin
      Essential Discoveries and Tools in Epitranscriptomics
      by seqadmin




      The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
      04-22-2024, 07:01 AM

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by seqadmin, 05-14-2024, 07:03 AM
    0 responses
    24 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 05-10-2024, 06:35 AM
    0 responses
    44 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 05-09-2024, 02:46 PM
    0 responses
    58 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 05-07-2024, 06:57 AM
    0 responses
    44 views
    0 likes
    Last Post seqadmin  
    Working...
    X