---
title: "22-lncRNA-clean-up"
author: "Zach Bengtsson"
date: "2025-07-21"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# Remove Duplicates

Remove duplicates in BED file from output folder
```{bash}
awk '!seen[$0]++' ../output/Peve_lncRNA.bed > ../output/22-lncRNA-clean-up/Pevermanni_lncRNA_de-duplicated.bed

```

```{bash}
wc -l ../output/22-lncRNA-clean-up/Pevermanni_lncRNA_de-duplicated.bed
```

7131 after removing duplicates

# Shift BED positions over by 1



```{bash}
awk '{
  $2 = $2 + 1;
  $3 = $3;
  print
}' OFS='\t' ../output/22-lncRNA-clean-up/Pevermanni_lncRNA_de-duplicated.bed > ../output/22-lncRNA-clean-up/Pevermanni_lncRNA.bed

```

```{bash}
head ../output/22-lncRNA-clean-up/Pevermanni_lncRNA.bed
tail ../output/22-lncRNA-clean-up/Pevermanni_lncRNA.bed
```

ctrl+F in bed produced 0 occurences of -1 positions

```{bash}
echo "Negative start coordinates:" 
awk '$2 < 0' ../output/22-lncRNA-clean-up/Pevermanni_lncRNA.bed
```

# Subset new FASTA

Download genomic fasta
```{bash}
# Navigate to your desired download directory
cd ../data/

# Use wget to download only .sorted.bam files
wget "https://gannet.fish.washington.edu/seashell/snaps/Porites_evermanni_v1.fa"


```


Subset original genomic FASTA with new bed file to obstain FASTA of lncRNAs
```{bash}
/home/shared/bedtools2/bin/bedtools getfasta \
-fi ../data/Porites_evermanni_v1.fa \
-bed ../output/22-lncRNA-clean-up/Pevermanni_lncRNA.bed \
-fo ../output/22-lncRNA-clean-up/Pevermanni_lncRNA.fasta

```



```{bash}
grep -c '^>' ../output/22-lncRNA-clean-up/Pevermanni_lncRNA.fasta
head ../output/22-lncRNA-clean-up/Pevermanni_lncRNA.fasta
tail ../output/22-lncRNA-clean-up/Pevermanni_lncRNA.fasta
```


```{bash}
cp ../output/22-lncRNA-clean-up/Pevermanni_lncRNA.fasta ../output/22-lncRNA-clean-up/Peve_lncRNA.fasta
```

```{bash}
cp ../output/22-lncRNA-clean-up/Pevermanni_lncRNA.bed ../output/22-lncRNA-clean-up/Peve_lncRNA.bed
```
