]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed upload pipe
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 15 Dec 2009 10:43:43 +0000 (10:43 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 15 Dec 2009 10:43:43 +0000 (10:43 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@814 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/BGB_intersect
bp_bin/BGB_upload
code_perl/Maasha/BGB/Common.pm

index 54a9822baa10692091b4e62d9628daa62adcf84d..7561872d49fb2f28315d79866064715765333213 100755 (executable)
@@ -39,11 +39,11 @@ use Maasha::KISS;
 
 my ( $user, $options, $in, $out, $record, @contigs, $contig, $track, @tracks, %hash, $fh1, $fh2, @records );
 
-$user    = Maasha::Biopieces::biopiecesrc( "BPB_USER" );
+$user    = Maasha::Biopieces::biopiecesrc( "BGB_USER" );
 
 $options = Maasha::Biopieces::parse_options(
     [
-        { long => 'user',     short => 'u', type => 'string', mandatory => 'yes', default => $user, 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 },
index 916ffa803bd540c2847e2506292b89a68c19aadc..611f60425bc5122326ca8876944fcf94960bd68d 100755 (executable)
@@ -33,6 +33,7 @@ use Maasha::Common;
 use Maasha::KISS;
 use Maasha::Biopieces;
 use Maasha::Fasta;
+use Maasha::BGB::Common;
 use Maasha::Filesys;
 
 use constant {
@@ -44,10 +45,10 @@ use constant {
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $data_dir, $user, $options, $path, $in, $out, $tmp_dir, %fh_hash, $fh_out, $record, $entry, $key, @dirs, $dir, $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 );
 
-$data_dir = Maasha::Biopieces::biopiecesrc( "KISS_DATA_DIR" );
-$user     = Maasha::Biopieces::biopiecesrc( "KISS_USER" );
+$data_dir = Maasha::Biopieces::biopiecesrc( "BGB_DATA_DIR" );
+$user     = Maasha::Biopieces::biopiecesrc( "BGB_USER" );
 
 $options = Maasha::Biopieces::parse_options(
     [
@@ -68,7 +69,7 @@ if ( $options->{ 'track_name' } )
 {
     $options->{ 'track_name' } =~ tr/ /_/;
 
-    $path = join "/", $data_dir, "Users/", $options->{ 'user' }, $options->{ 'clade' }, $options->{ 'genome' }, $options->{ 'assembly' };
+    $path = join "/", $data_dir, "Users", $options->{ 'user' }, $options->{ 'clade' }, $options->{ 'genome' }, $options->{ 'assembly' };
 
     Maasha::Common::error( qq(Path not found: "$path") ) if not -d $path;
 
@@ -92,6 +93,9 @@ 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 = sprintf( "%04d", $num + 10 );
+
     foreach $key ( keys %fh_hash )
     {
         close $fh_hash{ $key };
@@ -99,23 +103,6 @@ if ( $options->{ 'track_name' } )
         $dst_dir = Maasha::Filesys::dir_create_if_not_exists( "$path/$key" );
         $dst_dir = Maasha::Filesys::dir_create_if_not_exists( "$dst_dir/Tracks" );
 
-        @dirs = Maasha::Filesys::ls_dirs( $dst_dir );
-
-        foreach $dir ( @dirs )
-        {
-            $dir = ( split "/", $dir )[ -1 ];
-
-            if ( $dir =~ /^(\d+)/ ) {
-                push @nums, $1;
-            }
-        }
-
-        @nums = sort { $a <=> $b } @nums;
-
-        $num = $nums[ -1 ] || 0;
-
-        $num += 10;
-
         $dst_dir = "$dst_dir/$num" . "_$options->{ 'track_name' }";
 
         Maasha::Filesys::dir_create( $dst_dir );
index aa5842c7df139bd6568c93a61ca56b296317d49a..018380d34f991591bfbaec8e4b40cc8abc03962e 100644 (file)
@@ -349,6 +349,43 @@ sub list_tracks
 
     return wantarray ? @tracks : \@tracks;
 }
+
+
+sub max_track
+{
+    # Martin A. Hansen, December 2009.
+    
+    # Traverses all contigs for a given user->clade->genome->assembly and
+    # returns the maximum track's prefix value eg. 20 for 20_Genbank.
+
+    my ( $user,
+         $clade,
+         $genome,
+         $assembly
+       ) = @_;
+
+    # Returns an integer
+    
+    my ( @contigs, $contig, @tracks, $max );
+
+    @contigs = list_contigs( $user, $clade, $genome, $assembly );
+
+    foreach $contig ( @contigs ) {
+        push @tracks, list_tracks( $user, $clade, $genome, $assembly, $contig );
+    }
+
+    @tracks = sort @tracks;
+
+    if ( scalar @tracks > 0 and $tracks[ -1 ] =~ /^(\d+)/ ) {
+        $max = $1;
+    } else {
+        $max = 0;
+    }
+
+    return $max;
+}
+
+
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<