[Bioperl-l] how not to use Files when file handlers are required

Jason Stajich jason@cgt.mc.duke.edu
Tue, 19 Feb 2002 11:32:29 -0500 (EST)


On Tue, 19 Feb 2002, Guoneng Zhong wrote:

> Hi,
> I am starting to use Bioperl and I notice that often files are used as
> keepers of sequences and reports.  Either a file name is supplied as

As is the case in most of bioinformatics right now.

> input or some file handler is required for input or output.  Case in
> point is the following example I copied from the tutorial:
>
> use Bio::Tools::pSW;
>    $factory = new Bio::Tools::pSW( '-matrix' => 'blosum62.bla',
>                                    '-gap' => 12,
>                                    '-ext' => 2, );
>    $factory->align_and_show($seq1, $seq2, STDOUT);
>    $aln = $factory->pairwise_alignment($seq1, $seq2);
>

All the alignment algorithms are implemented in a more efficient language
than perl so we don't actually do any alignments in perl other than with
the pSW module which is through XS.

So you need to have a logical transfer of data - files are the primary
mechanism for this. You can do what you want with the EMBOSS interface and
the 'water' program much better and I've just written the helper function
which doesn't require you to explicitly dump the seq to a file (it is done
behind the scenes).  Please see the previous messages in the list archive.
Note that the sequence data still has to be dumped to a file because that
is where emboss programs read it from.

> My problem is that I don't work with files very much; I get my sequence
> either from someone's website or from a database.  So in the above
> example, how would I supply the matrix as a string if I don't have a
> file?  Do I have to write the string to a file first and then tell it?
> Same for the STDOUT; what if I want to use a String instead?  I come
> from a java background, and it has a String IO Stream reader/writer.  I
> wonder in Perl there is something like that or if Bioperl accommodates
> for this.
>

> Thanks,
> Guoneng
>

-- 
Jason Stajich
Duke University
jason@cgt.mc.duke.edu