forked from zeyaxue/ARG_metagenome
-
Notifications
You must be signed in to change notification settings - Fork 1
/
count_fq.sh
executable file
·46 lines (38 loc) · 1.12 KB
/
count_fq.sh
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# usage: count_fq.sh gz/fq indir outfile
touch $2/count_fq_log.txt
if [ "$1" = "fq" ]
then
for file in $2/*.fastq
do
STEM=$(basename "$file" .fastq)
echo ${STEM} >> $2/count_fq_log.txt
echo $(cat $file|wc -l)/4|bc >> $2/count_fq_log.txt
done
elif [ "$1" = "gz" ]
then
for file in $2/*.fastq.gz
do
STEM=$(basename "$file" _R1_001.fastq.gz )
echo ${STEM} >> $2/count_fq_log.txt
echo $(zcat $file|wc -l)/4| >> $2/count_fq_log.txt
done
else
echo "Please input between fq and gz"
fi
# organize file
cd $2
## # Make sampleID column
## ## I tried over several hours to wrangle the data in variables but that did not work
## awk 'NR%2==1' $2/count_fq_log.txt > $2/col1a.txt
## # use $() to denote everthing between () are excutable commands
## $(echo sampleID > $2/col1b.txt) # column header
## $(sed 's/_.*//' $2/col1a.txt >> $2/col1b.txt) # need the . period symbol for wildcard to work
##
## # Make read column
## $(echo lib_size > $2/col2.txt)
## awk 'NR%2==0' $2/count_fq_log.txt >> $2/col2.txt
##
## # Combine 2 columns to final stats file
## $(paste $2/col1b.txt $2/col2.txt -d "\t" > $3)
##