aboutsummaryrefslogtreecommitdiff
path: root/scripts/main.sh
blob: 612f6260c902c10b2046b042018132ad59855386 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
echo "$(pwd)"
currentVersion="0.9"
protein="false"
ligand="false"
docking="false"
visualisations="false"
interactions="false"
proteinPath=""
ligandPath=""
pdfPath=""
smile=""
name=""
config=""

usage()
{
  cat <<EOF
Curie-CLI
Description: OwO.
Usage: curie [flags] or curie [-a] [arg] [-s] [arg]
  -d  Perform Docking using AutoDock Vina
  -p  Visualisations using PyMOL
  -i  Protein-Ligand Interactions using PLIP
  -s  SMILES Code for Ligand
  -n  Name for ligand if using the -s option
  -r  Specify Receptor file path (PDBQT Format Only!)
  -l  Specify Ligand file path (PDBQT Format Only!)
  -c  Specify AutoDock Vina Configuration File (TXT Format Only!)
  -h  Show the help
  -v  Get the tool version
Examples:
   ./main.sh -v
   ./main.sh -v
EOF
}


while getopts "r:l:s:n:c:vhdip" opt; do
  case "$opt" in
    \?) echo "Invalid option: -$OPTARG" >&2
        exit 1
        ;;
    h)  usage
        exit 0
        ;;
    v)  echo "Version $currentVersion"
        exit 0
        ;;
    u)
        getConfiguredClient || exit 1
        checkInternet || exit 1
        update
        exit 0
        ;;
    d) 
        docking="true"
        ;;
    i)
        interactions="true"
        ;;
    p)
        visualisations="true"
        ;;
    s)
       smile="$OPTARG"
        ;;
    n) 
       name="$OPTARG"
       ;;
    r)
       proteinPath="$OPTARG"
        ;;
    l)
       ligandPath="$OPTARG"
        ;;
    c) 
        config="$OPTARG"
        ;;
    a)
        artist="true"
        if [[ "$(echo "$@" | grep -Eo "\-s")" == "-s" ]];then song="true";fi # wont go through both options if arg spaced and not quoted this solves that issue (dont need this but once had bug on system where it was necessary)
        if [[ "$(echo "$@" | grep -Eo "\-f")" == "-f" ]];then filePath=$(echo "$@" | grep -Eo "\-f [ a-z A-Z / 0-9 . \ ]*[ -]?" | sed s/-f//g | sed s/-//g | sed s/^" "//g);fi
      ;;
    #s)
    #    song="true"
    #    if [[ "$(echo "$@" | grep -Eo "\-a")" == "-a" ]];then artist="true";fi # wont go through both options if arg spaced and not quoted this solves that issue (dont need this but once had bug on system where it was necessary)
    #    if [[ "$(echo "$@" | grep -Eo "\-f")" == "-f" ]];then filePath=$(echo "$@" | grep -Eo "\-f [ a-z A-Z / 0-9 . \ ]*[ -]?" | sed s/-f//g | sed s/-//g | sed s/^" "//g);fi
    #  ;;
    :)  echo "Option -$OPTARG requires an argument." >&2
        exit 1
        ;;
  esac
done

if [[ $# == "0" ]]; then
  usage ## if calling the tool with no flags and args chances are you want to return usage
  exit 0
elif [[ $# == "1" ]]; then
  if [[ $1 == "update" ]]; then
    getConfiguredClient || exit 1
    checkInternet || exit 1
    update || exit 1
    exit 0
  elif [[ $1 == "help" ]]; then
    usage
    exit 0
  fi
fi

if [[ $docking == "true" ]]; then
    if [[ $proteinPath != "" ]]; then
        if [[ $smile != "" ]] || [[ $ligandPath != "" ]]; then
            if [[ $config == "" ]]; then
                echo "Configuration File Not Specified!"
                exit 1
            else
                dockingCheck="true"
            fi
        else 
            echo "WTF Only Protein!"
            exit 1
        fi
    fi
fi

if [[ $smile != "" ]]; then
    if [[ $name == "" ]]; then
        name="ligand"
        obabel -:"$smile" --gen3d -opdbqt -O$name.pdbqt
        ligandPath="$name.pdbqt"
    fi
fi

if [[ $dockingCheck == "true" ]]; then
    echo ""
    vina --receptor $proteinPath --ligand $ligandPath --config $config
fi

if [[ $visualisations == "true" ]]; then
    file=$(echo "$ligandPath" | cut -f 1 -d '.')
    python3 /src/scripts/quick-ligand-protein.py -p $proteinPath -l "$(echo $file)_out.pdbqt"
fi

if [[ $interactions == "true" ]]; then
    python3 /src/scripts/get-best.py -p $proteinPath -l "$(echo $file)_out.pdbqt"
    python3 /src/plip/plipcmd.py -f best.pdb -qpxy
    python3 /src/scripts/makeReport.py --input . > report.md
    pandoc -V geometry:margin=1in report.md --pdf-engine=xelatex -o $name.pdf
fi

echo "$proteinPath and $ligandPath and $docking and $interactions and $visualisations"