How can I get unmatched reads for defective genomes analysis using bwa and samtools? I am trying to follow the Beauclair et al. paper (free version here https://rnajournal.cshlp.org/content/24/10/1285.long) for identifying defective genomes using their DI-tector program.
According to figure 2 
Before using the program itself, it is highly recommended to filter my raw read using bwa and then samtools
Unfortunately I have no idea where to start - I have browsed official bwa and samtools sites, I have installed them using the following commands:
sudo apt-get update -y
sudo apt-get install -y bwa

I have indexed my reference genome with the following command (as I read it is required before the analysis)
bwa index sequence.fasta

Then, I have installed samtools
cd ..
wget https://github.com/samtools/samtools/releases/download/1.9/samtools-1.9.tar.bz2
tar -vxjf samtools-1.9.tar.bz2
cd samtools-1.9
make
sudo apt install samtools

I wonder what will be the further steps to get these &quot;UNMATCHED READS at the end of step i&quot;, since Di-tector program takes virus_reference genome (I have it) and these unmatched reads.
First of all I want to align my .fastq files vs GCF_000001405.39_GRCh38.p13_genomic.fna - what will be the output file? If I got it right - I need this output file to filter with samtools, am I correct?
If I am not mistaken, the output after samtools will be the .sam file that I will have to put into a DI-tector - correct?
If you want to keep track of the unmapped reads, I recommend you to use Bowtie2 instead of bwa.
Start by building an index:
bowtie2-build genome.fa genome.fa

Then map your reads, using arguments to save unmapped reads in a specific file like this:
bowtie2 -x genome.fa -1 reads_1.fq -2 reads_2.fq -S bowtie2_mapping.sam --un-conc-gz unmappedreads_%.fq.gz

It will write the alignment as well as unmappedreads_1.fq.gz and unmappedreads_2.fq.gz that you may use in DI-tector.