X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2FBGB_intersect;h=d41593e7df2ca5db6849b2597257eb48933e3e58;hb=5de6112b70b59420b245ce636a8b2e3c90acbe00;hp=b6a5bfedc931cc558fc6fc89d75ba4418d9adfde;hpb=b9062acce5ccd2ca2ebb89bec03615748c1cf20a;p=biopieces.git diff --git a/bp_bin/BGB_intersect b/bp_bin/BGB_intersect index b6a5bfe..d41593e 100755 --- a/bp_bin/BGB_intersect +++ b/bp_bin/BGB_intersect @@ -30,14 +30,14 @@ use warnings; use strict; use Data::Dumper; use Maasha::Biopieces; -use Maasha::BGB::Common; +use Maasha::BGB::Track; 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( "BGB_USER" ); @@ -61,15 +61,15 @@ while ( $record = Maasha::Biopieces::get_record( $in ) ) Maasha::Biopieces::put_record( $record, $out ); } -Maasha::Common::error( qq(Bad user: "$options->{ 'user' }") ) if not grep /^$options->{ 'user' }$/, Maasha::BGB::Common::list_users(); +Maasha::Common::error( qq(Bad user: "$options->{ 'user' }") ) if not grep /^$options->{ 'user' }$/, Maasha::BGB::Track::list_users(); -@contigs = Maasha::BGB::Common::list_contigs( $options->{ 'user' }, $options->{ 'clade' }, $options->{ 'genome' }, $options->{ 'assembly' } ); +@contigs = Maasha::BGB::Track::list_contigs( $options->{ 'user' }, $options->{ 'clade' }, $options->{ 'genome' }, $options->{ 'assembly' } ); foreach $contig ( @contigs ) { undef %hash; - @tracks = Maasha::BGB::Common::list_track_dir( $options->{ 'user' }, $options->{ 'clade' }, $options->{ 'genome' }, $options->{ 'assembly' }, $contig ); + @tracks = Maasha::BGB::Track::list_track_dir( $options->{ 'user' }, $options->{ 'clade' }, $options->{ 'genome' }, $options->{ 'assembly' }, $contig ); foreach $track ( @tracks ) { @@ -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 ); + } + } } }