]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/create_vmatch_index
refactoring of assemble_pairs
[biopieces.git] / bp_bin / create_vmatch_index
index f956745fbf1741cc2714f5fc14ea81107adaedaa..b5d4d0e97d213a1ca2544ed378c7c1b1cc9fcd07 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl -w
+#!/usr/bin/env perl
 
 # Copyright (C) 2007-2009 Martin A. Hansen.
 
@@ -26,6 +26,7 @@
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
+use warnings;
 use strict;
 use Maasha::Common;
 use Maasha::Biopieces;
@@ -37,20 +38,20 @@ use Maasha::Fasta;
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $run_time_beg, $run_time_end, $default, $formats, $options, $in, $out, $record, $file_tmp, $fh_tmp, $type, $entry );
+my ( $default, $formats, $options, $in, $out, $record, $tmp_dir, $file_tmp, $fh_tmp, $type, $entry );
 
 $options = Maasha::Biopieces::parse_options(
     [
         { long => 'no_stream',     short => 'x', type => 'flag',   mandatory => 'no',  default => undef, allowed => undef, disallowed => undef },
         { long => 'index_name',    short => 'i', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
-        { long => 'prefix_length', short => 'p', type => 'uint',   mandatory => 'no',  default => undef, allowed => undef, disallowed => 0 },
     ]   
 );
 
 $in  = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
 $out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
 
-$file_tmp = $options->{ 'index_name' };
+$tmp_dir  = Maasha::Biopieces::get_tmpdir();
+$file_tmp = "$tmp_dir/create_vmatch_index.seq";
 $fh_tmp   = Maasha::Filesys::file_write_open( $file_tmp );
 
 while ( $record = Maasha::Biopieces::get_record( $in ) ) 
@@ -67,13 +68,17 @@ while ( $record = Maasha::Biopieces::get_record( $in ) )
 
 close $fh_tmp;
 
-if ( $type eq "protein" ) {
-    Maasha::Common::run( "mkvtree", "-db $file_tmp -protein -pl $options->{ 'prefix_length' } -allout -indexname $file_tmp > /dev/null 2>&1" );
+if ( $options->{ 'verbose' } ) {
+    Maasha::Common::run( "mkvtree", "-db $file_tmp -" . ( lc $type ) . " -pl -allout -indexname $options->{ 'index_name' }" );
 } else {
-    Maasha::Common::run( "mkvtree", "-db $file_tmp -dna -pl $options->{ 'prefix_length' } -allout -indexname $file_tmp > /dev/null 2>&1" );
+    Maasha::Common::run( "mkvtree", "-db $file_tmp -" . ( lc $type ) . " -pl -allout -indexname $options->{ 'index_name' } > /dev/null 2>&1" );
 }
 
 unlink $file_tmp;
+Maasha::Filesys::dir_remove( $tmp_dir );
+
+Maasha::Biopieces::close_stream( $in );
+Maasha::Biopieces::close_stream( $out );
 
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -81,19 +86,13 @@ unlink $file_tmp;
 
 BEGIN
 {
-    $run_time_beg = Maasha::Biopieces::run_time();
-
-    Maasha::Biopieces::log_biopiece();
+    Maasha::Biopieces::status_set();
 }
 
+
 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 );
+    Maasha::Biopieces::status_log();
 }
 
 
@@ -101,5 +100,3 @@ END
 
 
 __END__
-
-