]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_perl/Maasha/KISS.pm
fixed seq qual length check
[biopieces.git] / code_perl / Maasha / KISS.pm
index e4ac684c6548c5d182c155c3e751573b7fa93a9e..35d21108d9b853f59dd74738278a29a9054d4fd5 100644 (file)
@@ -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,12 +709,12 @@ 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' } || ".";
     $entry->[ BLOCK_COUNT ] = $record->{ 'BLOCK_COUNT' } || ".";
-    $entry->[ BLOCK_BEGS ]  = $record->{ 'BLOCK_BEGS' }  || ".";
+    $entry->[ BLOCK_BEGS ]  = $record->{ 'BLOCK_BEGS' }  || $record->{ 'Q_BEGS' } || ".";
     $entry->[ BLOCK_LENS ]  = $record->{ 'BLOCK_LENS' }  || ".";
     $entry->[ BLOCK_TYPE ]  = $record->{ 'BLOCK_TYPE' }  || ".";