You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
alert("Error: Missing platform value for 'change_content_by_platform()' script!");
30
-
}
31
-
}
32
-
33
-
window.onload= set_page_view_defaults;
34
-
</script>
35
16
36
17
## Writing files
37
18
38
19
We've been able to do a lot of work with files that already exist, but what if we want to write our own files? We're not going to type in a FASTA file, but we'll see as we go through other tutorials, there are a lot of reasons we'll want to write a file, or edit an existing file.
39
20
40
-
To add text to files, we're going to use a text editor called Nano. We're going to create a file to take notes about what we've been doing with the data files in `~/obss_2023/commandline/shell_data/untrimmed_fastq`.
21
+
To add text to files, we're going to use a text editor called Nano. We're going to create a file to take notes about what we've been doing with the data files in `~/shell_data/untrimmed_fastq`.
41
22
42
23
This is good practice when working in bioinformatics. We can create a file called `README.txt` that describes the data files in the directory or documents how the files in that directory were generated. As the name suggests, it's a file that we or others should read to understand the information in that directory.
43
24
44
-
Let's change our working directory to `~/obss_2023/commandline/shell_data/untrimmed_fastq` using `cd`,
25
+
Let's change our working directory to `~/shell_data/untrimmed_fastq` using `cd`,
45
26
then run `nano` to create a file called `README.txt`:
@@ -55,7 +36,7 @@ You should see something like this:
55
36
56
37
The text at the bottom of the screen shows the keyboard shortcuts for performing various tasks in `nano`. We will talk more about how to interpret this information soon.
57
38
58
-
::::::::::::::::::::::::::::::::::::::::: callout
39
+
59
40
60
41
## Which Editor?
61
42
@@ -80,7 +61,7 @@ your computer's start menu, the editor may want to save files in your desktop or
80
61
documents directory instead. You can change this by navigating to
Add today's date and then use <kbd>Ctrl</kbd>\-<kbd>X</kbd> followed by `y` and <kbd>Enter</kbd> to save.
134
108
135
109
## Writing scripts
136
110
@@ -140,92 +114,97 @@ One thing we will commonly want to do with sequencing results is pull out bad re
140
114
141
115
We're going to create a new file to put this command in. We'll call it `bad-reads-script.sh`. The `sh` isn't required, but using that extension tells us that it's a shell script.
142
116
143
-
```bash
144
-
$ nano bad-reads-script.sh
145
-
```
117
+
!!! terminal "code"
118
+
119
+
```bash
120
+
$ nano bad-reads-script.sh
121
+
```
146
122
147
123
Bad reads have a lot of N's, so we're going to look for `NNNNNNNNNN` with `grep`. We want the whole FASTQ record, so we're also going to get the one line above the sequence and the two lines below. We also want to look in all the files that end with `.fastq`, so we're going to use the `*` wildcard.
We had to type `bash` because we needed to tell the computer what program to use to run this script. Instead, we can turn this script into its own program. We need to tell the computer that this script is a program by making the script file executable. We can do this by changing the file permissions. We talked about permissions in [an earlier episode](03-working-with-files.md).
197
172
198
-
First, let's look at the current permissions.
173
+
!!! terminal-2 "First, let's look at the current permissions."
199
174
200
-
```bash
201
-
$ ls -l bad-reads-script.sh
202
-
```
175
+
```bash
176
+
$ ls -l bad-reads-script.sh
177
+
```
203
178
204
-
```output
205
-
-rw-rw-r-- 1 dcuser dcuser 0 Oct 25 21:46 bad-reads-script.sh
206
-
```
179
+
```output
180
+
-rw-rw-r-- 1 dcuser dcuser 0 Oct 25 21:46 bad-reads-script.sh
181
+
```
207
182
208
183
We see that it says `-rw-r--r--`. This shows that the file can be read by any user and written to by the file owner (you). We want to change these permissions so that the file can be executed as a program. We use the command `chmod` like we did earlier when we removed write permissions. Here we are adding (`+`) executable permissions (`+x`).
209
184
210
-
```bash
211
-
$ chmod +x bad-reads-script.sh
212
-
```
185
+
!!! terminal "code"
213
186
214
-
Now let's look at the permissions again.
187
+
```bash
188
+
$ chmod +x bad-reads-script.sh
189
+
```
215
190
216
-
```bash
217
-
$ ls -l bad-reads-script.sh
218
-
```
191
+
!!! terminal-2 "Now let's look at the permissions again."
219
192
220
-
```output
221
-
-rwxrwxr-x 1 dcuser dcuser 0 Oct 25 21:46 bad-reads-script.sh
222
-
```
193
+
```bash
194
+
$ ls -l bad-reads-script.sh
195
+
```
196
+
197
+
```output
198
+
-rwxrwxr-x 1 dcuser dcuser 0 Oct 25 21:46 bad-reads-script.sh
199
+
```
223
200
224
201
Now we see that it says `-rwxr-xr-x`. The `x`'s that are there now tell us we can run it as a program. So, let's try it! We'll need to put `./` at the beginning so the computer knows to look here in this directory for the program.
225
202
226
-
```bash
227
-
$ ./bad-reads-script.sh
228
-
```
203
+
!!! terminal "code"
204
+
205
+
```bash
206
+
$ ./bad-reads-script.sh
207
+
```
229
208
230
209
The script should run the same way as before, but now we've created our very own computer program!
231
210
@@ -314,133 +293,10 @@ command line belongs to. So, if you are logged into AWS on the command line and
314
293
the `curl` command above in the AWS terminal, the file will be downloaded to your AWS
315
294
machine, not your local one.
316
295
317
-
### Moving files between your laptop and NeSI with Jupyterhub
318
-
319
-
With Jupyterhub on NeSI, one of the easiest way to move small-medium sized files is to use the upload option on the file explorer panel
320
-
321
-

322
-
323
-
And to download a file, you can right click on it in the explorer panel and select "Download"
324
-
325
-

326
-
327
-
::::::::::::::::::::::::::::::::::::::::: callout
328
-
329
-
**Original instructions for downloading data from AWS**
330
-
331
-
### Moving files between your laptop and your instance - AWS
332
-
333
-
What if the data you need is on your local computer, but you need to get it _into_ the
334
-
cloud? There are also several ways to do this, but it's _always_ easier
335
-
to start the transfer locally. **This means if you're typing into a terminal, the terminal
336
-
should not be logged into your instance, it should be showing your local computer. If you're
337
-
using a transfer program, it needs to be installed on your local machine, not your instance.**
338
-
339
-
## Transferring Data Between your Local Machine and the Cloud
340
-
341
-
If you're using Windows with PuTTY instead of Git Bash, please select the alternative option here:
### Uploading Data to your Virtual Machine with scp
351
-
352
-
`scp` stands for 'secure copy protocol', and is a widely used UNIX tool for moving files
353
-
between computers. The simplest way to use `scp` is to run it in your local terminal,
354
-
and use it to copy a single file:
355
-
356
-
```bash
357
-
scp <file I want to move><where I want to move it>
358
-
```
359
-
360
-
Note that you are always running `scp` locally, but that _doesn't_ mean that
361
-
you can only move files from your local computer. In order to move a file from your local computer to an AWS instance, the command would look like this:
362
-
363
-
```bash
364
-
$ scp <local file><AWS instance>
365
-
```
366
-
367
-
To move it back to your local computer, you re-order the `to` and `from` fields:
368
-
369
-
```bash
370
-
$ scp <AWS instance><local file>
371
-
```
372
-
373
-
#### Uploading Data to your Virtual Machine with scp
374
-
375
-
Open the terminal and use the `scp` command to upload a file (e.g. local_file.txt) to the dcuser home directory:
#### Downloading Data from your Virtual Machine with scp
382
-
383
-
Let's download a text file from our remote machine. You should have a file that contains bad reads called ~/shell_data/scripted_bad_reads.txt.
384
-
385
-
**Tip:** If you are looking for another (or any really) text file in your home directory to use instead, try:
386
-
387
-
```bash
388
-
$ find ~ -name *.txt
389
-
```
390
-
391
-
Download the bad reads file in ~/shell_data/scripted_bad_reads.txt to your home ~/Download directory using the following command **(make sure you substitute [[email protected]](mailto:[email protected]) with your remote login credentials)**:
### Uploading Data to your Virtual Machine with PSCP
404
-
405
-
If you're using a Windows PC without Git Bash, we recommend you use the _PSCP_ program.
406
-
This program is from the same suite of tools as the PuTTY program we have been using to connect.
407
-
408
-
1. If you haven't done so, download pscp from [http://the.earth.li/~sgtatham/putty/latest/x86/pscp.exe](https://the.earth.li/~sgtatham/putty/latest/x86/pscp.exe)
409
-
2. Make sure the _PSCP_ program is somewhere you know on your computer. In this case,
410
-
your Downloads folder is appropriate.
411
-
3. Open the windows [PowerShell](https://en.wikipedia.org/wiki/Windows_PowerShell);
412
-
go to your start menu/search enter the term **'cmd'**; you will be able to start the shell
413
-
(the shell should start from C:\\Users\\your-pc-username>).
414
-
4. Change to the Downloads directory:
415
-
416
-
```bash
417
-
>cd Downloads
418
-
```
419
-
420
-
5. Locate a file on your computer that you wish to upload (be sure you know the path). Then upload it to your remote machine **(you will need to know your AMI instance address (which starts with ec2), and login credentials)**. You will be prompted to enter a password, and then your upload will begin. **(make sure you substitute 'your-pc-username' for your actual pc username and 'ec2-54-88-126-85.compute-1.amazonaws.com' with your AMI instance address)**
### Downloading Data from your Virtual Machine with PSCP
427
-
428
-
1. Follow the instructions in the Upload section to download (if needed) and access the _PSCP_ program (steps 1-3)
429
-
2. Download the text file to your current working directory (represented by a .) using the following command **(make sure you substitute 'your-pc-username' for your actual pc username and 'ec2-54-88-126-85.compute-1.amazonaws.com' with your AMI instance address)**
0 commit comments