]> git.donarmstrong.com Git - biopieces.git/commitdiff
migrated plot_karyogram
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 29 May 2009 09:56:36 +0000 (09:56 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 29 May 2009 09:56:36 +0000 (09:56 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@450 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/plot_karyogram
code_perl/Maasha/BioRun.pm
code_perl/Maasha/Plot.pm

index fdf5bd287f78613d2aea83bb9b15f855cad57e77..5e6c015d83fa24ba1ba8df1928bada9eae570944 100755 (executable)
@@ -1,6 +1,99 @@
-#!/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;
index be5975b745822db9f03e639c9643a5ef0de7482b..c063bc290ddd282192d2ca7fee0dd1fa91e6f30a 100644 (file)
@@ -144,7 +144,6 @@ sub run_script
     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 ) }
@@ -432,15 +431,6 @@ sub get_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(
@@ -572,7 +562,7 @@ sub get_options
     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" )
@@ -2127,44 +2117,6 @@ sub script_plot_lendist
 }
 
 
-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.
index 07673c17d4cc151eacb37893aff18b735986d531..88992c5e017c06b8f7d03e01ebc6b5e62bf327c7 100644 (file)
@@ -437,15 +437,13 @@ sub karyogram
 
     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 );
@@ -604,10 +602,10 @@ sub chromosome_layout
         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;