1 package Maasha::Solexa;
4 # Copyright (C) 2007-2008 Martin A. Hansen.
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # http://www.gnu.org/copyleft/gpl.html
23 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
26 # Routines for manipulation Solid sequence files with di-base encoding.
29 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
32 use vars qw( @ISA @EXPORT_OK );
36 @ISA = qw( Exporter );
39 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SUBROUTINES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
44 # Martin A. Hansen, August 2008
46 # Get the next Solexa entry form a file and returns
47 # a triple of [ seq_name, seq, score ].
48 # We asume a Solexa entry consists of four lines:
50 # @HWI-EAS157_20FFGAAXX:2:1:888:434
51 # TTGGTCGCTCGCTCCGCGACCTCAGATCAGACGTGG
52 # +HWI-EAS157_20FFGAAXX:2:1:888:434
53 # hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhKhe
55 my ( $fh, # filehandle to Solexa file
60 my ( $seq_header, $seq, $score_head, $score, @scores );
64 $score_header = <$fh>;
67 return if not defined $score;
74 @scores = split //, $score;
76 map { $_ = score_oct2dec( $_ ) } @scores;
78 $seq_header =~ s/^@//;
80 $score = join( ":", @scores );
82 return wantarray ? ( $seq_header, $seq, $score ) : [ $seq_header, $seq, $score ];
88 # Martin A. Hansen, August 2008
90 # Converts a Solexa score in octal format to decimal format.
92 # http://maq.sourceforge.net/fastq.shtml
94 my ( $char, # octal score
99 return 10 * log(1 + 10 ** ((ord( $char ) - 64) / 10.0)) / log(10);
103 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<