[Bioperl-l] ProtDist.pm

Jason Stajich jason@cgt.mc.duke.edu
Tue, 3 Dec 2002 14:20:16 -0500 (EST)


We need to change the phylip programs to run in a separate directory per
Factory Object instance.  Right now it is using cwd.
I currently do this for the PAML running - so it shouldn't be too hard to
migrate that back in to the _run function.


The problem is that PHYLIP doesn't allow you to change what the outputfile
name is (grr) so you have to work around this by changing the cwd for
the processes...  So changing outfile_name doesn't do any good - it is
only useful if you have compiled your PHYLIP to use a different
outputfile name or to deal with potential differences in expected
outputfile name between versions of PHYLIP.

Make sense?

If you want to have a go with the code feel free - otherwise I can look
into it in the next few days.

The dumb workaround is to startup your separate ProtDist instances in
different directories, if you are forking in perl I suppose  this
gets hairyer but you can just issue the chdir($tempdir) before
instantiating the new ProtDist object and it should work.


-jason
On Tue, 3 Dec 2002, Tyler wrote:

> I'd like to ask Jason or Shawn (or anyone else) whether or not it's
> possible to run ProtDist from two perl scripts (with different process
> ids) at the same time with the same working directory? I've tried
> setting a unique name for the outfiles, yet I still get a message
> saying "protdist did not create matrix correctly" for the script that
> is started second.  I am making the assumption that it is trying to
> write to an outfile that already exists and is in use by the script
> started first, but I can't figure out why!  I'm using version 1.14 from
> the cvs.
>
> (Actually, to be more accurate, it's one script that forks child
> processes that handle client requests. Regardless, the PD* filenames
> are unique.)
>
> Here's a code snippet:
> 	...
> 	print $client "STATUS\nCalculating distance matrix...\n";
> 	my $pdfile = "PD" . $$ . time() . ".out";  #creating a unique filename
> 	my $protdist_factory = Bio::Tools::Run::Phylo::Phylip::ProtDist->new();
> 	$protdist_factory->quiet(1);
> 	$protdist_factory->outfile_name($pdfile);
> 	my $matrix;
> 	eval { $matrix  = $protdist_factory->create_distance_matrix($aln);};
> #$aln created earlier in script
> 		if ($@) {
> 			my $e = $@;
> 			$e =~ s/\n/ /;
> 			print $client "ERROR\n$e\n";
> 			close($client);
> 			return "Error: $e";
> 		 }
> 	...
>
> -Tyler Alioto
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>

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