---
title: "25-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 05.33-lncRNA-discovery-overview output folder
```{bash}
awk '!seen[$0]++' ~/github/deep-dive/D-Apul/output/05.33-lncRNA-discovery/Apul_lncRNA.bed > ~/github/deep-dive/D-Apul/output/25-lncRNA-clean-up/Apulchra_lncRNA_de-duplicated.bed

```

```{bash}
wc -l ~/github/deep-dive/D-Apul/output/25-lncRNA-clean-up/Apulchra_lncRNA_de-duplicated.bed
```

16028 after removing duplicates

# Shift BED positions over by 1

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

```

```{bash}
head ../output/25-lncRNA-clean-up/Apulchra_lncRNA.bed
tail ../output/25-lncRNA-clean-up/Apulchra_lncRNA.bed
wc -l ../output/25-lncRNA-clean-up/Apulchra_lncRNA.bed
```

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


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



# Subset new FASTA

```{bash}
cd ../data
wget http://gannet.fish.washington.edu/seashell/snaps/GCF_013753865.1_Amil_v2.1_genomic.fna
```


Subset original genomic FASTA with new bed file to obstain FASTA of lncRNAs
```{bash}
/home/shared/bedtools2/bin/bedtools getfasta \
-fi ../data/GCF_013753865.1_Amil_v2.1_genomic.fna \
-bed ../output/25-lncRNA-clean-up/Apulchra_lncRNA.bed \
-fo ../output/25-lncRNA-clean-up/Apulchra_lncRNA.fasta

```





```{bash}
grep -c '>' ../output/25-lncRNA-clean-up/Apulchra_lncRNA.fasta
head ../output/25-lncRNA-clean-up/Apulchra_lncRNA.fasta
tail ../output/25-lncRNA-clean-up/Apulchra_lncRNA.fasta
```
```{bash}
cp ../output/25-lncRNA-clean-up/Apulchra_lncRNA.fasta ../output/25-lncRNA-clean-up/Apul_lncRNA.fasta
```

```{bash}
cp ../output/25-lncRNA-clean-up/Apulchra_lncRNA.bed ../output/25-lncRNA-clean-up/Apul_lncRNA.bed
```

