package PGF::GapResolution::SffReads; =head1 NAME PGF::GapResolution::SffReads =head1 SYNOPSIS use PGF::GapResolution::SffReads; my $obj = PGF::GapResolution::SffReads->new(); # Define 454's sffinfo executable. # $obj->set454SffInfoCmd("/jgi/tools/454/rig-BETA/bin/sffinfo"); # Initialize all sff files. # foreach my $sffFile (@sffFiles) { $obj->addSffFile($sffFile); } # Lookup sff file containing read. # foreach my $read (@readNames) { my $sffFile = getSffFile($read); # returns the sff file name containing $read. If none found, returns an # empty string. } =head1 DESCRIPTION This module is used to map read names to sff files. =head1 AUTHOR(s) Stephan Trong =head1 HISTORY =over =item * Stephan Trong 12/11/2008 Creation =back =cut #============================================================================# use strict; use Carp; use Carp qw(cluck); use FindBin qw($RealBin); use lib "$FindBin::RealBin/../lib"; #============================================================================# sub new { my $class = shift; my %reads2sff = (); my $self = { reads2sff=>\%reads2sff }; bless $self, $class; return $self; } #============================================================================# sub set454SffInfoCmd { my $self = shift; my $cmd = shift; if ( !-e $cmd ) { confess "ERROR: $cmd does not exist.\n"; } $self->{_sffinfoCmd} = $cmd; } #============================================================================# sub addSffFile { my $self = shift; my $sffFile = shift; confess "ERROR: no newbler sffinfo executable defined.\n" if !$self->{_sffinfoCmd}; confess "ERROR: $sffFile does not exist or is zero size.\n" if !-s $sffFile; my $cmd = $self->{_sffinfoCmd} . " -a $sffFile|"; open FH, $cmd or confess "ERROR: failed to open handle $cmd.\n"; while ( my $read = ) { chomp $read; $self->{reads2sff}->{$read} = $sffFile; } close FH; } #============================================================================# sub getSffFile { my $self = shift; my $read = shift; my $sffFile = ''; $sffFile = $self->{reads2sff}{$read} if exists $self->{reads2sff}{$read}; return $sffFile; } #============================================================================# 1;