-
Notifications
You must be signed in to change notification settings - Fork 1
/
tormes metadata creation script
32 lines (30 loc) · 1.32 KB
/
tormes metadata creation script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
#This script needs to be run in the same folder that you have any .fasta or .fastq.gz files to be added to the 'tormes' 'samples_metadata.txt'
#It will also only work if running tormes from the same folder that you ran this script from (it doesn't account for files in different folders)
r0check=(*.fasta)
r1check=(*1.fastq.gz)
r2check=(*2.fastq.gz)
echo -e "Samples\t""Read1\t""Read2\t""Description" > samples_metadata.txt
if test -n "$(shopt -s nullglob; echo *.fasta)"; then
for i in ${r0check[*]}; do
echo -e "${i%.fasta}""\t""GENOME""\t""${i}""\t""Reads from ${i%.fasta}" >> samples_metadata.txt
done
echo
echo "fasta files added to samples_metadata.txt"
else
echo
echo "no fasta files detected. Ignore if intentional."
fi
if [[ -f "$r1check" && -f "$r2check" ]] ; then
for i in $(ls *1.fastq.gz); do
echo -e "$(echo $i | sed "s/.*\///" | sed "s/1.fastq.gz//")""\t""$i""\t""$(echo $i | sed "s/1.fastq.gz/2.fastq.gz/")""\t""Reads from $(echo $i | sed "s/.*\///" | sed "s/1.fastq.gz//")" >> samples_metadata.txt;
done
echo
echo "fastq.gz files added to samples_metadata.txt"
else
echo
echo "Missing or incomplete fastq.gz file set with naming syntax of xxxx1.fastq.gz and xxxx2.fastq.gz."
echo "Ignore this message if this is intentional."
fi
echo
echo "samples_metadata.txt file created, type: cat samples_metadata.txt to check entries"