forked from MorrellLAB/sequence_handling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample_list_generator.sh
executable file
·54 lines (46 loc) · 1.29 KB
/
sample_list_generator.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
47
48
49
50
51
52
53
54
#!/bin/bash
set -e
set -u
set -o pipefail
# This is a simple script to create a list
# of samples in a directory and all of its
# subdirectories.
usage() {
echo -e "\
Usage: ./sample_list_generator.sh file_ext reads_dir out_dir out_name \n\
where: file_ext is the extenstion of samples being found \n\
example: \n\
.txt.gz \n\
.fq.gz \n\
.sam \n\
\n\
reads_dir is the directory in which all samples are found or \n\
the root directory for subdirectories containing samples \n\
\n\
out_dir is the desired out directory for the list. \n\
NOTE: this should NOT be the same as reads_dir \n\
\n\
out_name is the desired name for the sample list \n\
" >&2
exit 1
}
if [ "$#" -lt 4 ]; then
usage;
fi
# File extension of samples
# Example:
# .fastq.gz
# .txt.gz
# .fq.gz
FILE_EXT="$1"
# Full path to directory in
# which ALL samples are stored
# NOTE: subdirectories for indivdidual
# samples may be within this directory.
# They will still be searched through
READS_DIR="$2"
# Desired path and name of outfile
# Should not be same as $READS_DIR
OUT_DIR="$3"
OUT_NAME="$4"
find "$READS_DIR" -name "*$FILE_EXT" | sort > ${OUT_DIR}/${OUT_NAME}