Bio-Palantir
view release on metacpan or search on metacpan
bin/draw_bgc_maps.pl view on Meta::CPAN
# draw modules
if (@modules) {
for my $module (@modules) {
# rectangle
$img->penSize(5,5);
$img->bgcolor('lightyellow');
$img->fgcolor('black');
my $x1 = $module->{begin} + $left_margin;
my $y1 = 250 + $module->{y_cluster};
my $x2 = $module->{end} + $left_margin;
my $y2 = 350 + $module->{y_cluster};
$img->rectangle($x1, $y1, $x2, $y2); # (top_left_x, top_left_y, bottom_right_x, bottom_right_y)
$img->moveTo( ($x1 + $x2)/2 - (15 * length $module->{name}),
((250 + 350)/2) + 12.5 + $module->{y_cluster} );
$img->font($font);
$img->fontsize(40);
$img->string($module->{name});
}
}
my %color_for = (
'substrate-selection' => 'deepskyblue',
'carrier-protein' => 'mediumseagreen',
condensation => 'orangered',
termination => 'peru',
'tailoring/other' => 'navajowhite',
);
# draw domains
for my $domain (@domains) {
$img->bgcolor( $color_for{$domain->{class}} );
$img->fgcolor('black');
my $y_start = 400;
my $y_end = 450;
my $y_font = 150;
my $x1 = $domain->{begin} + $left_margin;
my $y1 = $y_start + $domain->{y_cluster} + $domain->{y_overlap};
my $x2 = $domain->{end} + $left_margin;
my $y2 = $y_end + $domain->{y_cluster} + $domain->{y_overlap};
$img->rectangle($x1, $y1, $x2, $y2); # (top_left_x, top_left_y, bottom_right_x, bottom_right_y)
$img->moveTo( ($x1 + $x2)/2 - (15 * length $domain->{$ARGV_label}),
($y_start + $y_end)/2 + 12.5 +
$domain->{y_cluster} + $domain->{y_overlap} )
;
$img->font($font);
$img->fontsize(30);
$img->string($domain->{$ARGV_label});
}
# draw legend
my %legend_for = (
'substrate-selection' => { x_start => 0 + $left_margin,
y_start => 150 + $y_cluster, color => 'deepskyblue' },
'carrier-protein' => { x_start => 525 + $left_margin,
y_start => 150 + $y_cluster, color => 'mediumseagreen' },
'condensation' => { x_start => 0 + $left_margin,
y_start => 300 + $y_cluster, color => 'orangered' },
'termination' => { x_start => 525 + $left_margin,
y_start => 300 + $y_cluster, color => 'peru' },
'tailoring/other' => { x_start => 0 + $left_margin,
y_start => 450 + $y_cluster, color => 'navajowhite' },
);
for my $legend (keys %legend_for) {
$img->bgcolor( $legend_for{$legend}{color} );
$img->fgcolor('black');
my $x1 = $legend_for{$legend}{x_start};
my $y1 = $legend_for{$legend}{y_start};
my $x2 = $x1 + 125;
my $y2 = $y1 + 75;
$img->rectangle($x1, $y1, $x2, $y2); # (top_left_x, top_left_y, bottom_right_x, bottom_right_y)
$img->moveTo( $x2 + 15, ($y1 + $y2)/2 + 12.5);
$img->font($font);
$img->fontsize(30);
$img->string($legend);
}
# convert into png data
my $output = $ARGV_outdir . $ARGV_prefix . 'Cluster' . $cluster_rank . '_'
. $cluster_type . '.png';
open my $out, '>', $output;
binmode $out;
print $out $img->png;
return;
}
__END__
=pod
=head1 NAME
draw_bgc_maps.pl - This script draws NRPS/PKS BGC clusters maps in PNG
=head1 VERSION
version 0.211420
=head1 NAME
draw_bgc_maps.pl - This tool draws NRPS/PKS gene clusters in PNG format.
Four modes are allowed: antiSMASH, Palantir, Palantir'exploratory mode, or all.
=head1 USAGE
$0 [options] --report-file [=] <infile>
=head1 REQUIRED ARGUMENTS
=over
=item --report[-file] [=] <infile>
Path to the output file of antismash, which can be either a
biosynML.xml (antiSMASH 3-4) or a regions.js file (antiSMASH 5).
=for Euclid: infile.type: readable
=back
=head1 OPTIONAL ARGUMENTS
=over
=item --mode [=] <str>
Mode from which drawings must be made: antismash (untreated antiSMASH data),
palantir (extended domain coordinates + potentially new detected domains),
exploratory (noisy overview of all domain protein signatures found without
a consensus architecture) [default: all].
=for Euclid: str.type: /all|antismash|palantir|exploratory/
str.type.error: <str> must be of all, antismash, palantir, exploratory (not str)
str.default: 'all'
( run in 0.956 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )