X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=code_perl%2FMaasha%2FKISS.pm;h=35d21108d9b853f59dd74738278a29a9054d4fd5;hb=9052a73697c99a1f0634e2d1f2cf2932f8288810;hp=5b5bca750b741ef3a13e66e0e0a57c916a5755fd;hpb=0c5ef477f5a42b657376d9c2926d2efe04218b81;p=biopieces.git diff --git a/code_perl/Maasha/KISS.pm b/code_perl/Maasha/KISS.pm index 5b5bca7..35d2110 100644 --- a/code_perl/Maasha/KISS.pm +++ b/code_perl/Maasha/KISS.pm @@ -100,6 +100,39 @@ sub kiss_entry_get } +sub kiss_retrieve +{ + # Martin A. Hansen, February 2010. + + # Retrieves KISS entries from a given sorted KISS file + # within an optional interval. + + my ( $file, # path to KISS file + $beg, # interval begin - OPTIONAL + $end, # interval end - OPTIONAL + ) = @_; + + # Returns a list. + + my ( $fh, $entry, @entries ); + + $beg ||= 0; + $end ||= 999999999; + + $fh = Maasha::Filesys::file_read_open( $file ); + + while ( $entry = kiss_entry_get( $fh ) ) + { + last if $entry->[ S_BEG ] > $end; + push @entries, $entry if $entry->[ S_END ] > $beg; + } + + close $fh; + + return wantarray ? @entries : \@entries; +} + + sub kiss_entry_parse { # Martin A. Hansen, December 2009. @@ -676,7 +709,7 @@ sub biopiece2kiss $entry->[ S_BEG ] = $record->{ 'S_BEG' }; $entry->[ S_END ] = $record->{ 'S_END' }; $entry->[ Q_ID ] = $record->{ 'Q_ID' } || "."; - $entry->[ SCORE ] = $record->{ 'SCORE' } || $record->{ 'BIT_SCORE' } || "."; + $entry->[ SCORE ] = $record->{ 'SCORE' } || $record->{ 'BIT_SCORE' } || $record->{ 'ID' } || "."; $entry->[ STRAND ] = $record->{ 'STRAND' } || "."; $entry->[ HITS ] = $record->{ 'HITS' } || "."; $entry->[ ALIGN ] = $record->{ 'ALIGN' } || $record->{ 'DESCRIPTOR' } || ".";