]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/BGB_upload
refactoring of assemble_pairs
[biopieces.git] / bp_bin / BGB_upload
index 7f779955ab9aa59f45cca0086b6d4cfe866e2ce2..0d5415cc74632cc751b97d138d4359e99234d247 100755 (executable)
@@ -33,7 +33,8 @@ use Maasha::Common;
 use Maasha::KISS;
 use Maasha::Biopieces;
 use Maasha::Fasta;
-use Maasha::BGB::Common;
+use Maasha::BGB::Track;
+use Maasha::BGB::Wiggle;
 use Maasha::Filesys;
 
 use constant {
@@ -47,20 +48,21 @@ use constant {
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $data_dir, $user, $options, $path, $in, $out, $tmp_dir, %fh_hash, $fh_out, $record, $entry, $key, $dst_dir, @nums, $num, $contig_dir );
+my ( $data_dir, $user, $options, $path, $in, $out, $tmp_dir, %fh_hash, $fh_out, $record, $entry, $key, $dst_dir, @nums, $num, $contig_dir, $wig );
 
 $data_dir = Maasha::Biopieces::biopiecesrc( "BGB_DATA_DIR" );
 $user     = Maasha::Biopieces::biopiecesrc( "BGB_USER" );
 
 $options = Maasha::Biopieces::parse_options(
     [
-        { long => 'user',       short => 'u', type => 'string', mandatory => 'no',  default => $user, allowed => undef, disallowed => undef },
-        { long => 'clade',      short => 'c', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
-        { long => 'genome',     short => 'g', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
-        { long => 'assembly',   short => 'a', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
-        { long => 'track_name', short => 't', type => 'string', mandatory => 'no',  default => undef, allowed => undef, disallowed => undef },
-        { long => 'force',      short => 'f', type => 'flag',   mandatory => 'no',  default => undef, allowed => undef, disallowed => undef },
-        { long => 'no_stream',  short => 'x', type => 'flag',   mandatory => 'no',  default => undef, allowed => undef, disallowed => undef },
+        { long => 'user',       short => 'u', type => 'string', mandatory => 'no',  default => $user,    allowed => undef,           disallowed => undef },
+        { long => 'clade',      short => 'c', type => 'string', mandatory => 'yes', default => undef,    allowed => undef,           disallowed => undef },
+        { long => 'genome',     short => 'g', type => 'string', mandatory => 'yes', default => undef,    allowed => undef,           disallowed => undef },
+        { long => 'assembly',   short => 'a', type => 'string', mandatory => 'yes', default => undef,    allowed => undef,           disallowed => undef },
+        { long => 'track_name', short => 't', type => 'string', mandatory => 'no',  default => undef,    allowed => undef,           disallowed => undef },
+        { long => 'track_type', short => 'T', type => 'string', mandatory => 'no',  default => 'linear', allowed => 'linear,wiggle', disallowed => undef },
+        { long => 'force',      short => 'f', type => 'flag',   mandatory => 'no',  default => undef,    allowed => undef,           disallowed => undef },
+        { long => 'no_stream',  short => 'x', type => 'flag',   mandatory => 'no',  default => undef,    allowed => undef,           disallowed => undef },
     ]   
 );
 
@@ -95,7 +97,7 @@ if ( $options->{ 'track_name' } )
         Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" };
     }
 
-    $num = Maasha::BGB::Common::max_track( $options->{ 'user' }, $options->{ 'clade' }, $options->{ 'genome' }, $options->{ 'assembly' } );
+    $num = Maasha::BGB::Track::max_track( $options->{ 'user' }, $options->{ 'clade' }, $options->{ 'genome' }, $options->{ 'assembly' } );
     $num = sprintf( "%04d", $num + 10 );
 
     foreach $key ( keys %fh_hash )
@@ -109,10 +111,17 @@ if ( $options->{ 'track_name' } )
 
         Maasha::Filesys::dir_create( $dst_dir );
 
-        Maasha::Filesys::file_copy( "$tmp_dir/$key", "$dst_dir/track_data.kiss" );
+        if ( $options->{ 'track_type' } eq 'linear' )
+        {
+            Maasha::Filesys::file_copy( "$tmp_dir/$key", "$dst_dir/track_data.kiss" );
 
-        Maasha::KISS::kiss_sort( "$dst_dir/track_data.kiss" );
-        Maasha::KISS::kiss_index( "$dst_dir/track_data.kiss" );
+            Maasha::KISS::kiss_sort( "$dst_dir/track_data.kiss" );
+        }
+        elsif ( $options->{ 'track_type' } eq 'wiggle' )
+        {
+            $wig = Maasha::BGB::Wiggle::wiggle_encode( "$tmp_dir/$key" );
+            Maasha::BGB::Wiggle::wiggle_store( "$dst_dir/track_data.wig", $wig );
+        }
 
         unlink "$tmp_dir/$key";
     }