]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/BGB_intersect
moving back to binned index and using JSON for storing
[biopieces.git] / bp_bin / BGB_intersect
index 54a9822baa10692091b4e62d9628daa62adcf84d..7bf85744b28d72fad2eaa5ba44f18a1c2df050b3 100755 (executable)
@@ -21,7 +21,7 @@
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
-# List all tracks availible in a local installation of the Biopieces Genome Browser.
+# Intersects two tracks in the Biopieces Genome Browser.
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
@@ -37,13 +37,13 @@ use Maasha::KISS;
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $user, $options, $in, $out, $record, @contigs, $contig, $track, @tracks, %hash, $fh1, $fh2, @records );
+my ( $user, $options, $in, $out, $record, @contigs, $contig, $track, @tracks, %hash, $fh1, $fh2, $entries, $entry );
 
-$user    = Maasha::Biopieces::biopiecesrc( "BPB_USER" );
+$user    = Maasha::Biopieces::biopiecesrc( "BGB_USER" );
 
 $options = Maasha::Biopieces::parse_options(
     [
-        { long => 'user',     short => 'u', type => 'string', mandatory => 'yes', default => $user, allowed => undef, disallowed => undef },
+        { long => 'user',     short => 'u', type => 'string', mandatory => 'no',  default => $user, allowed => undef, disallowed => undef },
         { long => 'clade',    short => 'c', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
         { long => 'genome',   short => 'g', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
         { long => 'assembly', short => 'a', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
@@ -82,12 +82,19 @@ foreach $contig ( @contigs )
 
     if ( exists $hash{ '1' } and exists $hash{ '2' } )
     {
+        print STDERR "Intersecting:\n$hash{ '1' } and\n$hash{ '2' }\n\n" if $options->{ 'verbose' };
+
         $fh1 = Maasha::Filesys::file_read_open( "$hash{ '1' }/track_data.kiss" );
         $fh2 = Maasha::Filesys::file_read_open( "$hash{ '2' }/track_data.kiss" );
 
-        @records = Maasha::KISS::kiss_intersect( $fh1, $fh2, $options->{ 'invert' } );
+        $entries = Maasha::KISS::kiss_intersect( $fh1, $fh2, $options->{ 'invert' } );
 
-        map { Maasha::Biopieces::put_record( $_, $out ) } @records;
+        foreach $entry ( @{ $entries } )
+        {
+            if ( $record = Maasha::KISS::kiss2biopiece( $entry ) ) {
+                 Maasha::Biopieces::put_record( $record, $out );
+            }
+        }
     }
 }