---
title: "Genome Annotation"
format: html
editor: visual
execute:
  echo: true
  warning: false
  message: false
---

```{r setup, include=FALSE}
library(tidyverse)
library(DT)
library(readxl)
library(plotly)
library(readr)
library(dplyr)

```


## NCBI NR BLAST

```{r, echo=FALSE}

# Read the CSV file
nr_data <- read_csv("http://gannet.fish.washington.edu/seashell/snaps/nr.csv")

# Subset the relevant columns
nr_subset <- nr_data[, c("query_name", "nr.hit_name", "description", "E value")]

# Create interactive datatable
datatable(
  nr_subset,
  extensions = 'Buttons',
  options = list(
    dom = 'Bfrtip',
    buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
    pageLength = 4
  ),
  filter = "top",
  rownames = FALSE
)
```
## UniProt

```{r, echo=FALSE}
# Read the tab-delimited file from the URL
uniprot_data <- read_tsv("http://gannet.fish.washington.edu/seashell/snaps/uniprot.txt")

# Display as an interactive datatable
datatable(
  uniprot_data,
  extensions = 'Buttons',
  options = list(
    dom = 'Bfrtip',
    buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
    pageLength = 4
  ),
  filter = "top",
  rownames = FALSE
)
```


## Pathways 

```{r, echo=FALSE}

# Read your Pathway CSV
# Read the CSV
df <- read_csv("http://gannet.fish.washington.edu/seashell/snaps/pathway_table.csv")

# Create clickable link column
df <- df %>%
  mutate(Link = paste0(
    "<a href='jbrowse/function/pathway/", PathwayId, ".png' target='_blank'>", PathwayId, "</a>"
  ))

# Move Link column to position 3
df <- df %>%
  select(1:2, Link, everything())

# Display interactive table
datatable(
  df,
  escape = FALSE,
  extensions = 'Buttons',
  options = list(
    dom = 'Bfrtip',
    buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
    pageLength = 6
  )
)
```


## Gene GFF 

```{r, echo=FALSE}
# Read the GFF3 file (skip comment lines starting with "#")
gff <- read_tsv(
  "http://gannet.fish.washington.edu/seashell/snaps/gene.gff3",
  comment = "#",
  col_names = c("seqid", "source", "type", "start", "end", "score", "strand", "phase", "attributes")
)



datatable(
  gff,
  extensions = 'Buttons',
  options = list(
    dom = 'Bfrtip',
    buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
    pageLength = 6
  ),
  filter = "top"
)



```

