wrapper_ehdn_outlier.sh 2.81 KB
Newer Older
1 2 3 4
#! /bin/sh

### ASDP PIPELINE ###
## Version: 0.0.1
5
## Licence: AGPLv3
6
## Author: Anne-Sophie Denommé-Pichon
7 8
## Description: script to generate automatically a manifest and multisampleprofile in a tsv format, then do outlier analyses for a single patient

9
# Source the configuration file
10
. ./config.sh
11

12 13 14 15 16 17
# Log file path option
if [ -z "$LOGFILE" ]
then
    LOGFILE=ehdn_outlier.$(date +"%F_%H-%M-%S").log
fi

18 19 20 21 22 23 24
# Logging
exec 1>> "$LOGFILE" 2>&1
echo "$(date +"%F_%H-%M-%S"): START"

# Check if case is specified
if [ -z "$CASE" ]
then
25
    echo "Sample is not specified"
26 27 28 29
    echo "$(date +"%F_%H-%M-%S"): END"
    exit 1
fi

30 31 32 33 34 35 36 37
# Check if samples list file is specified
if [ -z "$SAMPLES" ]
then
    echo "Sample list file is not specified"
    echo "$(date +"%F_%H-%M-%S"): END"
    exit 1
fi

38
# Generate manifest for one patient with all samples (to write lines in the file)
39
while read sample
40 41
do
    # Check if str_profile.json exists
42
    if [ -f "$OUTPUTDIR/$sample/str/ehdn/$sample.str_profile.json" ]
43
    then
44
        if [ "x$sample" = "x$CASE" ]
45
        then
46
            echo -e "$sample\tcase\t$OUTPUTDIR/$sample/str/ehdn/$sample.str_profile.json"
47
        else
48
            echo -e "$sample\tcontrol\t$OUTPUTDIR/$sample/str/ehdn/$sample.str_profile.json"
49 50
        fi
    fi
51
done < "$SAMPLES" > "$OUTPUTDIR/$CASE/str/ehdn/$CASE.manifest.tsv"
52 53 54 55 56 57 58 59 60 61 62 63 64

ehdn_outlier_exitcode=$?

echo "ehdn_outlier exit code : $ehdn_outlier_exitcode"
if [ $ehdn_outlier_exitcode != 0 ]
then
    echo "$(date +"%F_%H-%M-%S"): END"
    exit 1
fi

# Generate multisampleprofile for one patient with all samples
"$EHDN" merge \
    --reference "$REFERENCE" \
65 66
    --manifest "$OUTPUTDIR/$CASE/str/ehdn/$CASE.manifest.tsv" \
    --output-prefix "$CASE/str/ehdn/$CASE"
67 68 69 70 71 72 73 74 75 76 77

ehdn_outlier_exitcode=$?

echo "ehdn_outlier exit code : $ehdn_outlier_exitcode"
if [ $ehdn_outlier_exitcode != 0 ]
then
    echo "$(date +"%F_%H-%M-%S"): END"
    exit 1
fi

# Run locus-based comparison analysis
78
"$PYTHON" "$EHDN_OUTLIER" locus \
79 80 81
    --manifest "$OUTPUTDIR/$CASE/str/ehdn/$CASE.manifest.tsv" \
    --multisample-profile "$OUTPUTDIR/$CASE/str/ehdn/$CASE.multisample_profile.json" \
    --output "$OUTPUTDIR/$CASE/str/ehdn/$CASE.outlier_locus.tsv"
82 83 84 85 86 87 88 89 90 91 92 93

ehdn_outlier_exitcode=$?

echo "ehdn_outlier exit code : $ehdn_outlier_exitcode"
if [ $ehdn_outlier_exitcode != 0 ]
then
    echo "$(date +"%F_%H-%M-%S"): END"
    exit 1
fi


# Run motif_based comparison analysis
94
"$PYTHON" "$EHDN_OUTLIER" motif \
95 96 97
    --manifest "$OUTPUTDIR/$CASE/str/ehdn/$CASE.manifest.tsv" \
    --multisample-profile "$OUTPUTDIR/$CASE/str/ehdn/$CASE.multisample_profile.json" \
    --output "$OUTPUTDIR/$CASE/str/ehdn/$CASE.outlier_motif.tsv"
98 99 100 101 102 103 104 105 106 107 108 109 110 111

ehdn_outlier_exitcode=$?

echo "ehdn_outlier exit code : $ehdn_outlier_exitcode"
if [ $ehdn_outlier_exitcode != 0 ]
then
    echo "$(date +"%F_%H-%M-%S"): END"
    exit 1
fi

echo "$(date +"%F_%H-%M-%S"): END"