-#!/usr/bin/env perl -w
+#!/usr/bin/env perl
# Copyright (C) 2007-2009 Martin A. Hansen.
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+use warnings;
use strict;
+use Data::Dumper;
use Maasha::Biopieces;
use Maasha::Filesys;
+use Maasha::Fasta;
use Maasha::Seq;
my ( $options, $in, $out, $record, $genome_file, $index_file, $fh, $genome,
- $beg, $end, $len, $index_beg, $index_len, @begs, @lens, $index, $seq, $i, %lookup_hash );
+ $beg, $end, $len, $index_beg, $index_len, @begs, @lens, $index, $seq, $i );
$options = Maasha::Biopieces::parse_options(
[
$fh = Maasha::Filesys::file_read_open( $genome_file );
$index = Maasha::Fasta::index_retrieve( $index_file );
- shift @{ $index }; # Get rid of the file size info
-
- map { $lookup_hash{ $_->[ 0 ] } = [ $_->[ 1 ], $_->[ 2 ] ] } @{ $index };
-
- if ( exists $lookup_hash{ $options->{ "chr" } } and defined $options->{ "beg" } and ( defined $options->{ "end" } or defined $options->{ "len" } ) )
+ if ( defined $options->{ "chr" } and exists $index->{ $options->{ "chr" } } and defined $options->{ "beg" } and ( defined $options->{ "end" } or defined $options->{ "len" } ) )
{
- ( $index_beg, $index_len ) = @{ $lookup_hash{ $options->{ "chr" } } };
+ ( $index_beg, $index_len ) = @{ $index->{ $options->{ "chr" } } };
$beg = $index_beg + $options->{ "beg" } - 1;
$beg = $index_beg;
}
- $len = $index_beg + $index_len - $beg if $beg + $len > $index_beg + $index_len;
+ if ( $beg + $len > $index_beg + $index_len ) {
+ $len = $index_beg + $index_len - $beg;
+ }
next if $beg > $index_beg + $index_len;
}
}
-
while ( $record = Maasha::Biopieces::get_record( $in ) )
{
if ( $options->{ "genome" } and not $record->{ "SEQ" } )
{
- if ( $record->{ "REC_TYPE" } eq "BED" and exists $lookup_hash{ $record->{ "CHR" } } )
+ if ( $record->{ "REC_TYPE" } eq "BED" and exists $index->{ $record->{ "CHR" } } )
{
- ( $index_beg, $index_len ) = @{ $lookup_hash{ $record->{ "CHR" } } };
+ ( $index_beg, $index_len ) = @{ $index->{ $record->{ "CHR" } } };
$beg = $record->{ "CHR_BEG" } + $index_beg;
$len = $record->{ "CHR_END" } - $record->{ "CHR_BEG" } + 1;
}
- elsif ( $record->{ "REC_TYPE" } eq "PSL" and exists $lookup_hash{ $record->{ "S_ID" } } )
+ elsif ( $record->{ "REC_TYPE" } eq "PSL" and exists $index->{ $record->{ "S_ID" } } )
{
- ( $index_beg, $index_len ) = @{ $lookup_hash{ $record->{ "S_ID" } } };
+ ( $index_beg, $index_len ) = @{ $index->{ $record->{ "S_ID" } } };
$beg = $record->{ "S_BEG" } + $index_beg;
$len = $record->{ "S_END" } - $record->{ "S_BEG" } + 1;
}
- elsif ( $record->{ "REC_TYPE" } eq "BLAST" and exists $lookup_hash{ $record->{ "S_ID" } } )
+ elsif ( $record->{ "REC_TYPE" } eq "VMATCH" and exists $index->{ $record->{ "S_ID" } } )
{
- ( $index_beg, $index_len ) = @{ $lookup_hash{ $record->{ "S_ID" } } };
+ ( $index_beg, $index_len ) = @{ $index->{ $record->{ "S_ID" } } };
+
+ $beg = $record->{ "S_BEG" } + $index_beg;
+ $len = $record->{ "S_END" } - $record->{ "S_BEG" } + 1;
+ }
+ elsif ( $record->{ "REC_TYPE" } eq "BLAST" and exists $index->{ $record->{ "S_ID" } } )
+ {
+ ( $index_beg, $index_len ) = @{ $index->{ $record->{ "S_ID" } } };
$beg = $record->{ "S_BEG" } + $index_beg;
$len = $record->{ "S_END" } - $record->{ "S_BEG" } + 1;
Maasha::Biopieces::put_record( $record, $out );
}
+Maasha::Biopieces::close_stream( $in );
+Maasha::Biopieces::close_stream( $out );
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
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();
}
__END__
-