summaryrefslogtreecommitdiff
path: root/topics/aws/how-to.gmi
blob: e4598056a8f46e5f77bd09fbf74ed866e9fdd070 (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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# Amazon Web Services

## Create a virtual machine

In the browser:

* Log in to Amazon Web Services as "Root user" (https://signin.aws.amazon.com/)
* Click "Launch a virtual machine"
* Select instance's O.S. and type
* Create a key pair to securely connect to the instance
* Download the created key pair (file `chosen_name.pem`)
* Allow HTTPS/HTTP traffic from the internet
* Click "Launch instance"

In the local machine:

```shell
chmod 400 chosen_name.pem` # ensure your key is not publicly viewable
ssh -i "chosen_name.pem" ubuntu@ec2-54-211-237-62.compute-1.amazonaws.com` # connect to the instance (the address changes every time the machine is restarted)
```

Note: select the instance and then click 'Instance state' and 'Stop Instance' to stop it.

## Create multiple users

In the virtual machine:

```shell
ssh -i "chosen_name.pem" ubuntu@ec2-54-211-237-62.compute-1.amazonaws.com # connect to the virtual machine
sudo adduser user1 # create a new user
sudo adduser user2 # create a new user
sudo sed 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config -i # allow new users to use SSH with password authentication
sudo systemctl restart sshd # restart the SSH service to apply the changes
```

## Clone a virtual machine

* Select the instance
* Click "Actions", "Image and templates", and "Create image"
* Set "Image name" and click "Create image"
* Click Images->"Create AMI in the menu on the left side
* Select the AMI and click the "Launch instances from AMI" button

## Set up a pangenomic virtual machine

```shell
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y \
                    git \
                    bash \
                    cmake \
                    make \
                    g++-11 \
                    python3-dev \
                    pybind11-dev \
                    libbz2-dev \
                    bc \
                    libatomic-ops-dev \
                    autoconf \
                    libgsl-dev \
                    zlib1g-dev \
                    libzstd-dev \
                    libjemalloc-dev \
                    libhts-dev \
                    build-essential \
                    pkg-config \
                    time \
                    curl \
                    pigz \
                    tabix \
                    bcftools \
                    samtools \
                    wget \
                    pip \
                    libcairo2-dev \
                    unzip \
                    parallel \
    && sudo apt-get clean \
    && sudo apt-get purge  \
    && sudo rm -rf /var/lib/apt/lists/*
sudo apt-get autoremove

git clone --recursive https://github.com/waveygang/wfmash \
    && cd wfmash \
    && git pull \
    && git checkout 8ba3c53f327731ca515abd1ef32179f15acb9732 \
    && git submodule update --init --recursive \
    && cmake -H. -DCMAKE_BUILD_TYPE=Release -Bbuild && cmake --build build -- -j $(nproc) \
    && sudo cp build/bin/wfmash /usr/local/bin/wfmash \
    && cd ../ \
    && rm -rf wfmash

git clone --recursive https://github.com/ekg/seqwish \
    && cd seqwish \
    && git pull \
    && git checkout d9e7ab59e73258f57875f2a060437735a460475e \
    && git submodule update --init --recursive \
    && cmake -H. -DCMAKE_BUILD_TYPE=Release -Bbuild && cmake --build build -- -j $(nproc) \
    && sudo cp bin/seqwish /usr/local/bin/seqwish \
    && cd ../ \
    && rm -rf seqwish

git clone --recursive https://github.com/pangenome/smoothxg \
    && cd smoothxg \
    && git pull \
    && git checkout 956eb75644522bb2b96b4cca44b7bafa9cf02f4a \
    && git submodule update --init --recursive \
    && cmake -H. -DCMAKE_BUILD_TYPE=Release -Bbuild && cmake --build build -- -j $(nproc) \
    && sudo cp bin/smoothxg /usr/local/bin/smoothxg \
    && sudo cp deps/odgi/bin/odgi /usr/local/bin/odgi \
    && cd ../ \
    && rm -rf odgi

curl https://sh.rustup.rs -sSf | sh -s -- -y
PATH="$HOME/.cargo/bin:${PATH}"

git clone https://github.com/marschall-lab/GFAffix.git \
    && cd GFAffix \
    && git pull \
    && git checkout 3784c7ee03ee82df576474d2e119fdd88616914b \
    && cargo install --force --path . \
    && sudo mv $HOME/.cargo/bin/gfaffix /usr/local/bin/gfaffix \
    && cd ../ \
    && rm -rf GFAffix


wget https://github.com/vgteam/vg/releases/download/v1.40.0/vg \
    && chmod +x vg \
    && sudo mv vg /usr/local/bin/vg

git clone https://github.com/pangenome/vcfbub \
    && cd vcfbub \
    && git pull \
    && git checkout 26a1f0cb216a423f8547c4ad0e0ce38cb9d324b9 \
    && cargo install --force --path . \
    && sudo mv $HOME/.cargo/bin/vcfbub /usr/local/bin/vcfbub \
    && cd ../ \
    && rm -rf vcfbub

git clone --recursive https://github.com/vcflib/vcflib.git \
    && cd vcflib \
    && git checkout 4f2bce873bc520449ec549f36aaaad65bace51ca \
    && mkdir -p build \
    && cd build \
    && cmake -DZIG=OFF -DCMAKE_BUILD_TYPE=Release .. && cmake --build . -- -j $(nproc) \
    && sudo mv vcfwave /usr/local/bin/vcfwave \
    && sudo mv vcfuniq /usr/local/bin/vcfuniq \
    && cd ../../ \
    && rm -rf vcflib

git clone https://github.com/ekg/fastix.git \
    && cd fastix \
    && git pull \
    && git checkout 331c1159ea16625ee79d1a82522e800c99206834 \
    && cargo install --force --path . \
    && sudo mv $HOME/.cargo/bin/fastix /usr/local/bin/fastix \
    && cd ../ \
    && rm -rf fastix

git clone https://github.com/ekg/pafplot.git \
    && cd pafplot \
    && git pull \
    && git checkout 7dda24c0aeba8556b600d53d748ae3103ec85501 \
    && cargo install --force --path . \
    && sudo mv $HOME/.cargo/bin/pafplot /usr/local/bin/ \
    && cd ../ \
    && rm -rf pafplot

pip install igraph==0.10.4
pip install pycairo==1.23.0
pip install multiqc==1.14
sudo mv /home/ubuntu/.local/bin/* /usr/local/bin/

git clone https://github.com/pangenome/pggb.git
cd pggb
git checkout de5303e24d3e5594a5a2c9bdeb49aba420b24b0c
sudo cp pggb /usr/local/bin/pggb
sudo chmod 777 /usr/local/bin/pggb
sudo cp partition-before-pggb /usr/local/bin/partition-before-pggb
sudo chmod 777 /usr/local/bin/partition-before-pggb
sudo cp scripts/* /usr/local/bin/ # copy required scripts

# Hacky-way to easily get versioning info
sudo cp -r .git /usr/local/bin/
git config --global --add safe.directory /usr/local/bin
cd ..
rm -rf pggb

# Docker (for Nextflow)
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
sudo apt install docker.io
sudo snap install docker
sudo groupadd docker # create the docker group
sudo usermod -aG docker ${USER} # add yourself to the docker group
#  log out and log back in so that your group membership is re-evaluated
docker run hello-world # test it
# reboot the instance

# Java 17 (for Nextflow)
sudo apt install openjdk-17-jre-headless

# Nextflow
wget -qO- https://get.nextflow.io | bash
sudo cp nextflow /usr/local/bin/nextflow
sudo chmod 777 /usr/local/bin/nextflow
nextflow run nf-core/pangenome -r a_brave_new_world -profile test,docker --outdir a_brave_new_world.output # test it
nextflow run nf-core/pangenome -r a_brave_new_world --input pggb/data/HLA/DRB1-3123.fa.gz --n_haplotypes 14 --outdir uffa -profile docker -c hla.config # to ask for less resources
```