---
title: "02 Apul lncRNA align"
author: Steven Roberts
date: "`r format(Sys.time(), '%d %B, %Y')`" 
output: 
  github_document:
    toc: true
    toc_depth: 3
    number_sections: true
    html_preview: true
  html_document:
    theme: readable
    highlight: zenburn
    toc: true
    toc_float: true
    number_sections: true
    code_folding: show
    code_download: true

---



```{r setup, include=FALSE}
library(knitr)
library(tidyverse)
library(kableExtra)
library(DESeq2)
library(pheatmap)
library(RColorBrewer)
library(data.table)
library(DT)
library(formattable)
library(Biostrings)
library(spaa)
library(tm)
knitr::opts_chunk$set(
  echo = TRUE,         # Display code chunks
  eval = FALSE,         # Evaluate code chunks
  warning = FALSE,     # Hide warnings
  message = FALSE,     # Hide messages
  fig.width = 6,       # Set plot width in inches
  fig.height = 4,      # Set plot height in inches
  fig.align = "center" # Align plots to the center
)

```


# Blast to sRNA, genome, proteome....


## lncRNA fasta 

```{r, engine='bash', eval=TRUE}
head ../../DEF-cross-species/data/apul_bedtools_lncRNAs.fasta

fgrep ">" -c ../../DEF-cross-species/data/apul_bedtools_lncRNAs.fasta
```


# make some blastdb


## sRNA

```{r, engine='bash', eval=TRUE}
ls ../../DEF-cross-species/data/blast/apul_sRNA*
```

## Genome
http://gannet.fish.washington.edu/seashell/snaps/GCF_013753865.1_Amil_v2.1_genomic.fna

```{bash}
cd ../data/
curl -O https://gannet.fish.washington.edu/seashell/snaps/GCF_013753865.1_Amil_v2.1_genomic.fna
```


```{r, engine='bash', eval=TRUE}
head ../data/GCF_013753865.1_Amil_v2.1_genomic.fna

```

```{r, engine='bash'}
/home/shared/ncbi-blast-2.11.0+/bin/makeblastdb \
-in ../data/GCF_013753865.1_Amil_v2.1_genomic.fna \
-dbtype nucl \
-out ../data/blast/Amil_v2.1_genome
```

```{r, engine='bash', eval=TRUE}
ls ../data/blast/Amil_v2.1_genome*
```




## Proteins
http://gannet.fish.washington.edu/seashell/snaps/GCF_013753865.1_Amil_v2.1.protein.faa

```{bash}
cd ../data/

curl -O https://gannet.fish.washington.edu/seashell/snaps/GCF_013753865.1_Amil_v2.1.protein.faa
```



```{r, engine='bash', eval=TRUE}
head ../data/GCF_013753865.1_Amil_v2.1.protein.faa
```




```{r, engine='bash'}
/home/shared/ncbi-blast-2.11.0+/bin/makeblastdb \
-in ../data/GCF_013753865.1_Amil_v2.1.protein.faa \
-dbtype prot \
-out ../data/blast/Amil_v2.1_proteome
```



```{r, engine='bash', eval=TRUE}
ls ../data/blast/Amil_v2.1_proteome*
```



## lncRNA

```{r, engine='bash', eval=TRUE}
ls ../../DEF-cross-species/data/blast/apul*lncRNA*
```

## Genes
???



# Blast comparison


# Results - database: sRNA


```{r, engine='bash'}
/home/shared/ncbi-blast-2.11.0+/bin/blastn \
-task blastn \
-query ../../DEF-cross-species/data/apul_bedtools_lncRNAs.fasta \
-db ../../DEF-cross-species/data/blast/apul_sRNA \
-out ../output/06-Apul-lncRNA-align/lncRNA_sRNA_blastn.tab \
-evalue 1E-08 \
-num_threads 20 \
-outfmt 6


```


```{r, engine='bash', eval=TRUE}
echo "Number of hits?"
wc -l ../output/06-Apul-lncRNA-align/lncRNA_sRNA_blastn.tab

echo "File header"
head ../output/06-Apul-lncRNA-align/lncRNA_sRNA_blastn.tab
```



# Result - database: proteome



```{r, engine='bash'}
/home/shared/ncbi-blast-2.11.0+/bin/blastx \
-query ../../DEF-cross-species/data/apul_bedtools_lncRNAs.fasta \
-db ../data/blast/Amil_v2.1_proteome \
-out ../output/06-Apul-lncRNA-align/lncRNA_proteome_blastx.tab \
-evalue 1E-40 \
-num_threads 20 \
-max_target_seqs 5 \
-max_hsps 1 \
-outfmt 6


```



```{r, engine='bash', eval=TRUE}

echo "Number of hits?"
wc -l ../output/06-Apul-lncRNA-align/lncRNA_proteome_blastx.tab


echo "File header"
head ../output/06-Apul-lncRNA-align/lncRNA_proteome_blastx.tab


```

# Result - database: lncRNA


../../DEF-cross-species/data/blast/apul_bedtools_lncRNAs




```{r, engine='bash'}
/home/shared/ncbi-blast-2.11.0+/bin/blastn \
-task blastn \
-query ../../DEF-cross-species/data/apul_bedtools_lncRNAs.fasta \
-db ../../DEF-cross-species/data/blast/apul_bedtools_lncRNAs \
-out ../output/06-Apul-lncRNA-align/lncRNA_lncRNA_blastn.tab \
-evalue 1E-80 \
-max_hsps 1 \
-num_threads 20 \
-outfmt 6


```




```{r, engine='bash', eval=TRUE}

echo "Number of hits?"
wc -l ../output/06-Apul-lncRNA-align/lncRNA_lncRNA_blastn.tab

```


