# Mapping pipeline

First log into the serve

```
ssh monica@10.18.0.21
```

Then go to the correct directory with the data:

```
cd /opt/storage5/monica/NGS_data
```

{% hint style="info" %}
If you have a new reference you have to index it using:

```
bwa index <reference_file>
```

{% endhint %}

&#x20;Perform mapping using the following code

```
bwa mem -t 10 -R "@RG\tID:AGT12\tSM:ATG12\tPL:Illumina" Anopheles_gambiae.AgamP4.dna.toplevel.fa AGT12_1.fastq.gz AGT12_2.fastq.gz | samtools view -@ 10 -b - | samtools sort -@ 10 -o AGT12.bam -
```

Then index the bam file with

```bash
samtools index AGT12.bam
```

Create a table of variants

```
 bcftools mpileup -f Anopheles_gambiae.AgamP4.dna.toplevel.fa AGT12.bam | bcftools call -mv | bcftools query -f '%CHROM\t%POS\t%REF\t%ALT[\t%TGT]\n'
```
