-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy.sh
More file actions
executable file
·52 lines (41 loc) · 1.15 KB
/
Copy pathcopy.sh
File metadata and controls
executable file
·52 lines (41 loc) · 1.15 KB
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
#!/bin/bash
set -e
# Check at least one argument is given
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <target_dir> [input_dir1 input_dir2 ...]"
exit 1
fi
# First argument: destination parent directory
base_dest="$1"
shift
target_dir="$base_dest/swiftseq_pipeline"
# Ensure target_dir does not already exist
if [[ -e "$target_dir" ]]; then
echo "Error: Target directory '$target_dir' already exists."
exit 1
fi
# Create the target directory
mkdir -p "$target_dir"
# Copy contents of current directory into target_dir
cp -r ./* "$target_dir"
# If there are additional arguments, verify and process them
if [[ $# -gt 0 ]]; then
abs_dirs=()
for d in "$@"; do
if [[ ! -d "$d" ]]; then
echo "Error: Directory '$d' does not exist."
exit 1
fi
fq_count=$(find "$d" -maxdepth 1 -type f -name "*.fastq.gz" | wc -l)
if [[ "$fq_count" -eq 0 ]]; then
echo "Error: Directory '$d' does not contain any FASTQ files."
exit 1
fi
abs_dirs+=("$(cd "$d" && pwd)")
done
# Call make_json.sh with absolute directories
"$target_dir/make_json.sh" "${abs_dirs[@]}"
fi
# Change into the target directory
cd "$target_dir"
ulimit -n 8192