From a98f7f6675ce0035dad9fc26e0a2cd1952a9f6ad Mon Sep 17 00:00:00 2001 From: martinahansen Date: Mon, 15 Jun 2009 14:13:56 +0000 Subject: [PATCH] fixed bug in Fasta.pm git-svn-id: http://biopieces.googlecode.com/svn/trunk@524 74ccb610-7750-0410-82ae-013aeee3265d --- code_perl/Maasha/Common.pm | 32 -------------------------------- code_perl/Maasha/Fasta.pm | 9 +++++---- code_perl/Maasha/Filesys.pm | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/code_perl/Maasha/Common.pm b/code_perl/Maasha/Common.pm index 83c9633..9fc7eab 100644 --- a/code_perl/Maasha/Common.pm +++ b/code_perl/Maasha/Common.pm @@ -294,38 +294,6 @@ sub pipe_open } -sub file_store -{ - # Martin A. Hansen, December 2004. - - # writes a data structure to file. - - my ( $path, # full path to file - $data, # data structure - ) = @_; - - Storable::store( $data, $path ) or Maasha::Common::error( qq(Could not write-open file "$path": $!) ); -} - - -sub file_retrieve -{ - # Martin A. Hansen, December 2004. - - # retrieves hash data structure - # (this routines needs to test if its a hash, array or else) - - my ( $path, # full path to data file - ) = @_; - - my ( $data ); - - $data = Storable::retrieve( $path ) or Maasha::Common::error( qq(Could not read-open file "$path": $!) ); - - return wantarray ? %{ $data } : $data; -} - - sub read_args { # Martin A. Hansen, December 2006 diff --git a/code_perl/Maasha/Fasta.pm b/code_perl/Maasha/Fasta.pm index a81a546..55a17b5 100644 --- a/code_perl/Maasha/Fasta.pm +++ b/code_perl/Maasha/Fasta.pm @@ -31,6 +31,7 @@ package Maasha::Fasta; use strict; use Data::Dumper; use Maasha::Common; +use Maasha::Filesys; use Maasha::Seq; use vars qw ( @ISA @EXPORT ); @@ -365,11 +366,11 @@ sub index_create my ( $file_size, $fh, $entry, $beg, $len, %hash, @index ); - $file_size = Maasha::Common::file_size( $path ); + $file_size = Maasha::Filesys::file_size( $path ); push @index, "FILE_SIZE=$file_size"; - $fh = Maasha::Common::read_open( $path ); + $fh = Maasha::Filesys::file_read_open( $path ); $beg = 0; $len = 0; @@ -465,7 +466,7 @@ sub index_store # returns nothing - Maasha::Common::file_store( $path, $index ); + Maasha::Filesys::file_store( $path, $index ); } @@ -482,7 +483,7 @@ sub index_retrieve my $index; - $index = Maasha::Common::file_retrieve( $path ); + $index = Maasha::Filesys::file_retrieve( $path ); return wantarray ? @{ $index } : $index; } diff --git a/code_perl/Maasha/Filesys.pm b/code_perl/Maasha/Filesys.pm index b189a41..b545609 100644 --- a/code_perl/Maasha/Filesys.pm +++ b/code_perl/Maasha/Filesys.pm @@ -31,6 +31,7 @@ package Maasha::Filesys; use strict; use IO::File; +use Storable; use Maasha::Common; use Exporter; @@ -202,6 +203,38 @@ sub file_read } +sub file_store +{ + # Martin A. Hansen, December 2004. + + # writes a data structure to file. + + my ( $path, # full path to file + $data, # data structure + ) = @_; + + Storable::store( $data, $path ) or Maasha::Common::error( qq(Could not write-open file "$path": $!) ); +} + + +sub file_retrieve +{ + # Martin A. Hansen, December 2004. + + # retrieves hash data structure + # (this routines needs to test if its a hash, array or else) + + my ( $path, # full path to data file + ) = @_; + + my ( $data ); + + $data = Storable::retrieve( $path ) or Maasha::Common::error( qq(Could not read-open file "$path": $!) ); + + return wantarray ? %{ $data } : $data; +} + + sub file_copy { # Martin A. Hansen, November 2008. -- 2.39.5