X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fget_genome_seq;h=e219c5188a993fd54e0af1b2c363abbb45ba9720;hb=2f0fd91b461033529a4a72e161bd133252a22eb6;hp=0e8d1f739e86ec5744dd17c5d739c75de72b4d82;hpb=112de27df38163c34f7463c8797dae5eb7dc358b;p=biopieces.git diff --git a/bp_bin/get_genome_seq b/bp_bin/get_genome_seq index 0e8d1f7..e219c51 100755 --- a/bp_bin/get_genome_seq +++ b/bp_bin/get_genome_seq @@ -28,6 +28,7 @@ use warnings; use strict; +use Data::Dumper; use Maasha::Biopieces; use Maasha::Filesys; use Maasha::Fasta; @@ -38,7 +39,7 @@ 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( [ @@ -66,13 +67,9 @@ if ( $options->{ "genome" } ) $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 ( defined $options->{ "chr" } and 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; @@ -112,30 +109,30 @@ 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 "VMATCH" 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 $lookup_hash{ $record->{ "S_ID" } } ) + elsif ( $record->{ "REC_TYPE" } eq "BLAST" 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;