-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapping.sh
More file actions
48 lines (41 loc) · 1.44 KB
/
mapping.sh
File metadata and controls
48 lines (41 loc) · 1.44 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
#!/bin/bash
#Verfication of argument number
if [ $# -lt 3 ]; then
echo "Usage: $0 <ACCESSIONS_LIST> <GENE_SEQUENCE> <DESTINATION_DIRECTORY>"
exit 1
fi
# Arguments
ACCESSIONS_LIST=$1 # Text file containing ID accesion for your data (data should have been published before december 2023)
GENE_SEQUENCE=$2 # fasta sequence of gene of interest
DESTINATION_DIRECTORY=$3 # Output Directory
# Checking
if [ ! -f "$ACCESSIONS_LIST" ]; then
echo "The file $ACCESSIONS_LIST is not found"
exit 1
fi
if [ ! -f "$GENE_SEQUENCE" ]; then
echo "The file $GENE_SEQUENCE is not found"
exit 1
fi
if [ ! -d "$DESTINATION_DIRECTORY" ]; then
echo "Please identify the output directory"
exit 1
fi
# Loop over the ID
while IFS= read -r ID; do
if [ -f "$DESTINATION_DIRECTORY/$ID.minimap2_output" ]; then
echo ""
echo "WARNING : The $ID is already processed. Skipping "
echo ""
else
if aws s3 ls "s3://logan-pub/c/$ID/" --no-sign-request > /dev/null 2>&1; then
echo ""
echo "Procssing sample : $ID"
echo ""
/opt/minimap2/bin/minimap2-2.17-r941 -t 8 -a "$GENE_SEQUENCE" <(aws s3 cp s3://logan-pub/c/"$ID"/"$ID".contigs.fa.zst --no-sign-request - | zstdcat) | samtools view -hF4 - > "$DESTINATION_DIRECTORY"/"$ID".minimap2_output
else
echo ""
echo "ERROR: sample $ID is not found in logan bucket"
fi
fi
done < "$ACCESSIONS_LIST"