-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_samplesheet_gcloud.sh
More file actions
53 lines (44 loc) · 1.43 KB
/
create_samplesheet_gcloud.sh
File metadata and controls
53 lines (44 loc) · 1.43 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
52
#!/bin/bash
MYFOLDER=$1
SAMPLE_TYPE='tumor'
R1_FASTQS=($(gcloud storage ls ${MYFOLDER}/** | grep -P ".*_1.f.*q.gz"))
R1_FASTQS+=($(gcloud storage ls ${MYFOLDER}/** | grep -P ".*_R1_.*.f.*q.gz"))
R1_FASTQS+=($(gcloud storage ls ${MYFOLDER}/** | grep -P ".*_R1.f.*q.gz"))
#R1_FASTQS=($(find ${MYFOLDER} -iname "*_1.f*q.gz"))
#R1_FASTQS+=($(find ${MYFOLDER} -iname "*_R1_*.f*q.gz"))
echo "sample,fastq_1,fastq_2,bam,bai,sample_type"
for FASTQ_1 in ${R1_FASTQS[@]}; do
BAM=""
BAI=""
SAMPLE=$( echo $(basename ${FASTQ_1}) | cut -f1 -d'_' | cut -f1 -d'.')
if [[ "${FASTQ_1}" == *"_R1_"* ]]; then
FASTQ_2=${FASTQ_1/_R1_/_R2_}
fi
if [[ "${FASTQ_1}" == *"_1.f"* ]]; then
FASTQ_2=${FASTQ_1/_1.f/_2.f}
fi
if [[ "${FASTQ_1}" == *"_R1.f"* ]]; then
FASTQ_2=${FASTQ_1/_R1.f/_R2.f}
fi
if gsutil -q stat ${FASTQ_2}; then
echo ${SAMPLE},${FASTQ_1},${FASTQ_2},${BAM},${BAI},${SAMPLE_TYPE}
else
echo "NO PAIRED FASTQ FILES FOUND FOR ${SAMPLE}"
fi
done
BAMS=($(gcloud storage ls ${MYFOLDER}/** | grep -P ".*.bam$"))
#BAMS=($(find ${MYFOLDER} -iname "*bam"))
for BAM in ${BAMS[@]}; do
FASTQ_1=""
FASTQ_2=""
SAMPLE=$( echo $(basename ${BAM}) | cut -f1 -d'_' | cut -f1 -d'.')
BAI=${BAM}.bai
if ! gsutil -q stat ${BAI} ; then
BAI=${BAM/.bam/.bai}
fi
if ! gsutil -q stat ${BAI}; then
echo "NO BAI FILE FOUND FOR ${SAMPLE}"
else
echo ${SAMPLE},${FASTQ_1},${FASTQ_2},${BAM},${BAI},${SAMPLE_TYPE}
fi
done