---
title: Data sequencing
---

```bash
pip3 install ncbi-acc-download --user
```

```{r}
install.packages("biomartr", dependencies = TRUE)
library(biomartr)
sequences <- read.csv(file = 'genes/Coronaviridae/sequences.csv')
head(sequences)
```

![Filter used for coronaviridae](images/filter-for-coronaviridae.png)

To download all sequences for SARS-CoV-2
```bash
wget "https://www.ncbi.nlm.nih.gov/genomes/VirusVariation/vvsearch2/?q=*:*&fq=%7B!tag=SeqType_s%7DSeqType_s:(%22Nucleotide%22)&fq=VirusLineageId_ss:(2697049)&fq=%7B!tag=Flags_ss%7DFlags_ss:%22complete%22&cmd=download&dlfmt=fasta&fl=id,Nucleotide_seq" -O genes/SARS-CoV-2/all.fasta
```

To download all sequences for Coronavidae
```bash
wget "https://www.ncbi.nlm.nih.gov/genomes/VirusVariation/vvsearch2/?q=*:*&fq=%7B!tag=SeqType_s%7DSeqType_s:(%22Nucleotide%22)&fq=VirusLineageId_ss:(11118)&fq=%7B!tag=Flags_ss%7DFlags_ss:%22complete%22%20OR%20%22refseq%22&fq=HostLineageId_ss:(9606)&cmd=download&sort=SourceDB_s%20desc,CreateDate_dt%20desc&dlfmt=fasta&fl=id,Nucleotide_seq" -O genes/Coronaviridae/all.fasta
```

Now we can split the files into smaller chunks for each gene:
```bash
pyfasta split --header "genes/SARS-CoV-2/%(seqid)s.fasta" genes/SARS-CoV-2/all.fa
pyfasta split --header "genes/Coronaviridae/%(seqid)s.fasta" genes/Coronaviridae/all.fasta
```
