my $extraction_command_unmapped = qq($samtools_bin view -bo $target_extraction_unmapped $BAM '*');
or
my $extraction_command_unmapped = qq($samtools_bin view -f4 -bo $target_extraction_unmapped $BAM);
but the second one could be a problem when only one of the paired-end reads mapped
The following code could get an error of bam header when there is no unmapped reads
my $extraction_command_unmapped = qq($samtools_bin view $BAM '' | awk '{if (\$3 == "") print \$0}' | $samtools_bin view -bo $target_extraction_unmapped -);
how about this:
my $extraction_command_unmapped = qq($samtools_bin view -bo $target_extraction_unmapped $BAM '*'); or my $extraction_command_unmapped = qq($samtools_bin view -f4 -bo $target_extraction_unmapped $BAM); but the second one could be a problem when only one of the paired-end reads mapped