Author image Alexandre Masselot
and 1 contributors




Miscelaneous I/O utilities.



The getFD function takes either a file string, a piped command or a file description as argument and returns a file descriptor. In case of error while opening, it returns undef.

uncompressFile($fname, [\%args])

Uncompresses a gziped file. Returns the new uncompressed file name; Erase the original; %args can overwrite default values

remove => [1];
dest => filename [undef];

If defined, the uncompressed file is not the original one =~s/\.gz$//i, but it has this file name.

headGz($fname, [$nblines], [$re])

Uncompresses file $fname and takes the $nblines first lines (default 10) satisfying regular expression $re (if defined).

Returns either an array or lines concatenated with \n characters, depending on the context.

compressFile($fname, [\%args])

Compresses to a gziped file. Returns the new compressed file name; Erases the original by default; %args can overwrite default values.

remove => [1];

zipFiles($dest, \@files, [$baseNameOnly])

Opens a zip archive $dest and puts all the files contained in @files into it. $dest can be either undef (means STDOUT), or a filehandle, or a file name. If($baseNameOnly) [default undef], stores the file under its basename (removes directory name).


Returns a MD5 checksum of $file.


Croaks with the given message, but appends a stack trace if $InSilicoSpectro::Utils::io::VERBOSE is true.


Copyright (C) 2004-2005 Geneva Bioinformatics

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


Alexandre Masselot,