package Murasaki::RunUtils;
BEGIN{ push(@INC, $ENV{LOCAL_PERL_MODULES}); }
use Carp;
use warnings;
use strict;
use FASTA::FileIO;

###################################################
sub anchors {
    my $outDir = shift;
    my $outName = shift;
    my $pattern = shift;
    my @seqs = @_;

    my $seqFiles = [];
    my $id = 0;
    foreach my $seqs (@seqs){
	my $seqFile = $outDir . '/' . $outName . '.' . (++$id) . '.fa';
	FASTA::FileIO::output( $seqFile, $seqs );
	push( @$seqFiles, $seqFile );
    }
    executeCommand( getAnchorsCommand($outDir, $outName, $pattern, $seqFiles) );
}

###################################################
sub getAnchorsCommand {
    my $outDir = shift;
    my $outName = shift;
    my $pattern = shift;
    my $seqFiles = shift;
    my $command = 'murasaki '
	. ' -p ' . $pattern
	. ' -d ' . $outDir
	. ' -n ' . $outName
	. ' '    . join( ' ', @$seqFiles );
    return $command;
}

###################################################
sub executeCommand {
    my $command = shift;
    print "\t" . "CMD: " . $command . "\n";
    system "$command";
}



1;
