{
@options = qw(
keys|k=s
+ merge|m=s
);
}
elsif ( $script eq "grab" )
{
Maasha::Common::error( qq(Character '$options{ $opt }' is not allowed in table names) );
}
+ elsif ( $opt eq "merge" and $options{ $opt } !~ /^(AandB|AorB|BorA|AnotB|BnotA)$/ )
+ {
+ Maasha::Common::error( qq(Argument to --$opt must be AandB, AorB, BorA, AnotB, or BnotA - not "$options{ $opt }") );
+ }
}
Maasha::Common::error( qq(no --database specified) ) if $script eq "create_blast_db" and not $options{ "database" };
# Returns nothing.
- my ( $record, $file1, $file2, $fh1, $fh2, $key1, $key2, @keys1, @keys2, @vals1, @vals2,
+ my ( $merge, $record, $file1, $file2, $fh1, $fh2, $key1, $key2, @keys1, @keys2, @vals1, @vals2,
$num1, $num2, $num, $cmp, $i );
+ $merge = $options->{ "merge" } || "AandB";
+
$file1 = "$BP_TMP/merge_records1.tmp";
$file2 = "$BP_TMP/merge_records2.tmp";
while ( $num1 > 0 and $num2 > 0 )
{
+ undef $record;
+
if ( $num ) {
$cmp = $vals1[ 0 ] <=> $vals2[ 0 ];
} else {
if ( $cmp < 0 )
{
+ if ( $merge =~ /^(AorB|AnotB)$/ )
+ {
+ for ( $i = 0; $i < @keys1; $i++ ) {
+ $record->{ $keys1[ $i ] } = $vals1[ $i ];
+ }
+
+ put_record( $record, $out );
+ }
+
@vals1 = Maasha::Common::get_fields( $fh1 );
$num1--;
}
elsif ( $cmp > 0 )
{
+ if ( $merge =~ /^(BorA|BnotA)$/ )
+ {
+ for ( $i = 0; $i < @keys2; $i++ ) {
+ $record->{ $keys2[ $i ] } = $vals2[ $i ];
+ }
+
+ put_record( $record, $out );
+ }
+
@vals2 = Maasha::Common::get_fields( $fh2 );
$num2--;
}
else
{
- undef $record;
-
- for ( $i = 0; $i < @keys1; $i++ ) {
- $record->{ $keys1[ $i ] } = $vals1[ $i ];
- }
+ if ( $merge =~ /^(AandB|AorB|BorA)$/ )
+ {
+ for ( $i = 0; $i < @keys1; $i++ ) {
+ $record->{ $keys1[ $i ] } = $vals1[ $i ];
+ }
- for ( $i = 1; $i < @keys2; $i++ ) {
- $record->{ $keys2[ $i ] } = $vals2[ $i ];
+ for ( $i = 1; $i < @keys2; $i++ ) {
+ $record->{ $keys2[ $i ] } = $vals2[ $i ];
+ }
+
+ put_record( $record, $out );
}
-
- put_record( $record, $out );
@vals1 = Maasha::Common::get_fields( $fh1 );
@vals2 = Maasha::Common::get_fields( $fh2 );
unlink $file1;
unlink $file2;
+
+ if ( $num1 > 0 and $merge =~ /^(AorB|AnotB)$/ )
+ {
+ undef $record;
+
+ for ( $i = 0; $i < @keys1; $i++ ) {
+ $record->{ $keys1[ $i ] } = $vals1[ $i ];
+ }
+
+ put_record( $record, $out );
+ }
+
+ if ( $num2 > 0 and $merge =~ /^(BorA|BnotA)$/ )
+ {
+ undef $record;
+
+ for ( $i = 0; $i < @keys2; $i++ ) {
+ $record->{ $keys2[ $i ] } = $vals2[ $i ];
+ }
+
+ put_record( $record, $out );
+ }
}