Bio::EnsEMBL::Analysis::Runnable
Mercator
Toolbar
Summary
Bio::EnsEMBL::Analysis::Runnable::Mercator
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
my $runnable = new Bio::EnsEMBL::Analysis::Runnable::Mercator
(-input_dir => $input_dir,
-output_dir => $output_dir,
-genome_names => ["homo_sapiens","mus_musculus","rattus_norvegicus"],
-program => "/path/to/program");
$runnable->run;
my @output = @{$runnable->output};
Description
Methods
Methods description
Arg [1] : -input_dir => "/path/to/input/directory" Arg [2] : -output_dir => "/path/to/output/directory" Arg [3] : -genome_names => ["homo_sapiens","mus_musculus","rattus_norvegicus"] Function : contruct a new Bio::EnsEMBL::Analysis::Runnable::Mercator runnable Returntype: Bio::EnsEMBL::Analysis::Runnable::Mercator Exceptions: none Example : |
Arg [1] : Bio::EnsEMBL::Analysis::Runnable::Mercator Arg [2] : string, results filename Function : parse the specifed file and produce RepeatFeatures Returntype: nine Exceptions: throws if fails to open or close the results file Example : |
Arg [1] : Bio::EnsEMBL::Analysis::Runnable::TRF Arg [2] : string, program name Function : create and open a commandline for the program trf Returntype: none Exceptions: throws if the program in not executable or if the results file doesnt exist Example : |
Methods code
sub genome_names
{ my ($self, $arg) = @_;
$self->{'_genome_names'} = $arg if defined $arg;
return $self->{'_genome_names'}; } |
sub input_dir
{ my ($self, $arg) = @_;
$self->{'_input_dir'} = $arg if defined $arg;
return $self->{'_input_dir'}; } |
sub new
{ my ($class,@args) = @_;
my $self = $class->SUPER::new(@args);
my ($input_dir, $output_dir, $genome_names, $pre_map) = rearrange(['INPUT_DIR', 'OUTPUT_DIR', 'GENOME_NAMES', 'PRE_MAP'], @args);
unless (defined $self->program) {
$self->program('/software/ensembl/compara/mercator');
}
$self->input_dir($input_dir) if (defined $input_dir);
$self->output_dir($output_dir) if (defined $output_dir);
$self->genome_names($genome_names) if (defined $genome_names);
if (ref($genome_names) eq "ARRAY") {
print "GENOME_NAMES: ", join(", ", @{$genome_names}), "\n";
} else {
print "GENOME_NAMES: $genome_names\n";
}
if (defined $pre_map){
$self->pre_map($pre_map);
} else {
$self->pre_map(1);
}
return $self; } |
sub output_dir
{ my ($self, $arg) = @_;
$self->{'_output_dir'} = $arg if defined $arg;
return $self->{'_output_dir'}; } |
sub parse_results
{ my ($self) = @_;
my $map_file = $self->output_dir . "/pre.map";
unless ($self->pre_map) {
$map_file = $self->output_dir . "/map";
}
my $genomes_file = $self->output_dir . "/genomes";
open F, $genomes_file ||
throw("Can't open $genomes_file\n");
my @species;
while (<F>) {
@species = split;
last;
}
close F;
open F, $map_file ||
throw("Can't open $map_file\n");
my %hash;
while (<F>) {
my @synteny_region = split;
my $species_idx = 0;
for (my $i = 1; $i < scalar @species*4 - 2; $i = $i + 4) {
my $species = $species[$species_idx];
my ($name, $start, $end, $strand) = map {$synteny_region[$_]} ($i, $i+1, $i+2, $i+3);
push @{$hash{$synteny_region[0]}}, [$synteny_region[0], $species, $name, $start, $end, $strand];
$species_idx++;
}
}
close F;
my $output = [ values %hash ];
print "scalar output", scalar @{$output},"\n";
print "No synteny regions found" if (scalar @{$output} == 0);
$self->output($output);
}
1; } |
sub pre_map
{ my ($self, $arg) = @_;
$self->{'_pre_map'} = $arg if defined $arg;
return $self->{'_pre_map'}; } |
sub run_analysis
{ my ($self, $program) = @_;
if(!$program){
$program = $self->program;
}
throw($program." is not executable Mercator::run_analysis ")
unless($program && -x $program);
my $command = "$program -i " . $self->input_dir . " -o " . $self->output_dir;
print "genome_names: ".join(", ", @{$self->genome_names})."\n";
foreach my $species (@{$self->genome_names}) {
$command .= " $species";
}
print "Running analysis ".$command."\n";
unless (system($command) == 0) {
throw("mercator execution failed\n");
}
$self->parse_results; } |
General documentation