-#!/usr/bin/env perl
+#!/usr/bin/env perl -w
+
+# Copyright (C) 2007-2009 Martin A. Hansen.
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# http://www.gnu.org/copyleft/gpl.html
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# Plot a karyogram with positions indicated according to records in the stream.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
-use warnings;
use strict;
+use Maasha::Biopieces;
+use Maasha::Plot;
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, @data, $fh, $result, %data_hash );
+
+$options = Maasha::Biopieces::parse_options(
+ [
+ { long => 'no_stream', short => 'x', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'data_out', short => 'o', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'genome', short => 'g', type => 'string', mandatory => 'yes', default => undef, allowed => 'hg18,mm9', disallowed => undef },
+ { long => 'feat_color', short => 'f', type => 'string', mandatory => 'no', default => 'black', allowed => undef, disallowed => undef },
+ ]
+);
+
+$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
+$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
+
+$options->{ "genome" } ||= "human";
+$options->{ "feat_color" } ||= "black";
+
+while ( $record = Maasha::Biopieces::get_record( $in ) )
+{
+ if ( $record->{ "CHR" } and $record->{ "CHR_BEG" } and $record->{ "CHR_END" } )
+ {
+ push @{ $data_hash{ $record->{ "CHR" } } }, [ $record->{ "CHR_BEG" }, $record->{ "CHR_END" }, $options->{ "feat_color" } ];
+ }
+
+ Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" };
+}
+
+$result = Maasha::Plot::karyogram( \%data_hash, $options );
+
+$fh = Maasha::Biopieces::write_stream( $options->{ "data_out" } );
+
+print $fh $result;
+
+close $fh;
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+BEGIN
+{
+ $run_time_beg = Maasha::Biopieces::run_time();
+
+ Maasha::Biopieces::log_biopiece();
+}
+
+
+END
+{
+ Maasha::Biopieces::close_stream( $in );
+ Maasha::Biopieces::close_stream( $out );
+
+ $run_time_end = Maasha::Biopieces::run_time();
+
+ Maasha::Biopieces::run_time_print( $run_time_beg, $run_time_end, $options );
+}
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+__END__
-use Maasha::BioRun;
elsif ( $script eq "remove_mysql_tables" ) { script_remove_mysql_tables( $in, $out, $options ) }
elsif ( $script eq "remove_ucsc_tracks" ) { script_remove_ucsc_tracks( $in, $out, $options ) }
elsif ( $script eq "plot_lendist" ) { script_plot_lendist( $in, $out, $options ) }
- elsif ( $script eq "plot_karyogram" ) { script_plot_karyogram( $in, $out, $options ) }
elsif ( $script eq "plot_matches" ) { script_plot_matches( $in, $out, $options ) }
elsif ( $script eq "plot_seqlogo" ) { script_plot_seqlogo( $in, $out, $options ) }
elsif ( $script eq "plot_phastcons_profiles" ) { script_plot_phastcons_profiles( $in, $out, $options ) }
key|k=s
);
}
- elsif ( $script eq "plot_karyogram" )
- {
- @options = qw(
- no_stream|x
- data_out|o=s
- genome|g=s
- feat_color|f=s
- );
- }
elsif ( $script eq "plot_matches" )
{
@options = qw(
Maasha::Common::error( qq(no --database specified) ) if $script eq "remove_ucsc_tracks" and not $options{ "database" };
Maasha::Common::error( qq(no --in_file or --genome specified) ) if $script eq "soap_seq" and not $options{ "genome" } and not $options{ "in_file" };
Maasha::Common::error( qq(both --in_file and --genome specified) ) if $script eq "soap_seq" and $options{ "genome" } and $options{ "in_file" };
- Maasha::Common::error( qq(no --genome specified) ) if $script =~ /get_genome_align|get_genome_phastcons|plot_phastcons_profiles|plot_karyogram/ and not $options{ "genome" };
+ Maasha::Common::error( qq(no --genome specified) ) if $script =~ /get_genome_align|get_genome_phastcons|plot_phastcons_profiles/ and not $options{ "genome" };
Maasha::Common::error( qq(no --key specified) ) if $script =~ /plot_lendist/ and not $options{ "key" };
if ( $script eq "upload_to_ucsc" )
}
-sub script_plot_karyogram
-{
- # Martin A. Hansen, August 2007.
-
- # Plot hits on karyogram.
-
- my ( $in, # handle to in stream
- $out, # handle to out stream
- $options, # options hash
- ) = @_;
-
- # Returns nothing.
-
- my ( %options, $record, @data, $fh, $result, %data_hash );
-
- $options->{ "genome" } ||= "human";
- $options->{ "feat_color" } ||= "black";
-
- while ( $record = Maasha::Biopieces::get_record( $in ) )
- {
- if ( $record->{ "CHR" } and $record->{ "CHR_BEG" } and $record->{ "CHR_END" } )
- {
- push @{ $data_hash{ $record->{ "CHR" } } }, [ $record->{ "CHR_BEG" }, $record->{ "CHR_END" }, $options->{ "feat_color" } ];
- }
-
- Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" };
- }
-
- $result = Maasha::Plot::karyogram( \%data_hash, \%options );
-
- $fh = Maasha::Biopieces::write_stream( $options->{ "data_out" } );
-
- print $fh $result;
-
- close $fh;
-}
-
-
sub script_plot_matches
{
# Martin A. Hansen, August 2007.
my ( $karyo_file, $svg, $features, $karyo );
- if ( $options->{ "genome" } eq "human" )
+ if ( $options->{ "genome" } eq "hg18" )
{
- $karyo_file = "/Users/m.hansen/maasha/perl_scripts/biopieces/karyo_data/human_cytobands.txt";
-# $karyo_file = "/home/m.hansen/maasha/perl_scripts/biopieces/karyo_data/human_cytobands.txt";
+ $karyo_file = $ENV{ 'BP_DIR' } . "/bp_data/human_cytobands.txt";
}
- else
+ elsif( $options->{ "genome" } eq "mm9" )
{
- $karyo_file = "/Users/m.hansen/maasha/perl_scripts/biopieces/karyo_data/mouse_cytobands.txt";
- # $karyo_file = "/home/m.hansen/maasha/perl_scripts/biopieces/karyo_data/mouse_cytobands.txt";
+ $karyo_file = $ENV{ 'BP_DIR' } . "/bp_data/mouse_cytobands.txt";
}
$karyo = parse_karyo_data( $karyo_file );
map { $_->[ 0 ] *= $factor; $_->[ 1 ] *= $factor } @{ $feat_list->{ $feat } };
}
- @list = sort { $A = $a; $B = $b; $A =~ s/chr//; $B =~ s/chr//; $A <=> $B } keys %{ $karyo_list };
+# @list = sort { $A = $a; $B = $b; $A =~ s/chr//; $B =~ s/chr//; $A <=> $B } keys %{ $karyo_list };
- splice @list, 0, 2;
- push @list, "chrX", "chrY";
+# splice @list, 0, 2;
+# push @list, "chrX", "chrY";
$i = 0;