Unix

From 22113
Revision as of 14:36, 6 March 2024 by WikiSysop (talk | contribs) (Created page with "__NOTOC__ {| width=500 style="font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;" |Previous: None |Next: Python Recap and Objects |} You did do the Course preparation, right!! Otherwise all of this matters not. == Required course material for the lesson == Powerpoint: [https://teaching.healthtech.dtu.dk/material/22113/22113_01-Unix.ppt Introduction to Unix]<br> The videos are not entirely in sync with the powerpoint, as it has been updated.<br...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Previous: None Next: Python Recap and Objects

You did do the Course preparation, right!! Otherwise all of this matters not.

Required course material for the lesson

Powerpoint: Introduction to Unix
The videos are not entirely in sync with the powerpoint, as it has been updated.
Video: Unix intro and navigation Monday
Video: Coping, Moving, Renaming files. Changing permissions Monday
Video: Using shortcuts in Unix - making it easier Monday
Video: File inspection and editor in unix. 1½ min silence at the end Monday
Video: Manipulating files: wc, paste, cut & sort Monday
Video: Manipulating files: grep and pipelines Monday
Video: Touching upon various relevant subjects Monday
Resource: The resource on Unix for many courses at Health Tech
Resource: Biological knowledge needed in the course
Resource: UNIX Tutorial for Beginners from University of Surrey
Resource: UNIX/LINUX Tutorial from TutorialsPoint

Subjects covered

  • Basic file handling in UNIX.
  • Understanding and navigating the file system.
  • Many different Unix commands
  • Scripting in bash

Exercises to be handed in

Use a text editor to to create a file mycommands.txt where you write all commands and observations you do in the following exercises. Use copy/paste to copy the commands.
Note: Make sure that we can easily see which exercise you attempt to solve.
Note: You should work from your home directory, or a work directory that you specify explicitly in the top of your hand-in.
Note: Data files can be found in the collection of files.

Exercises to do after Monday

It is assumed that you have downloaded the 3 files; ex1.dat, ex1.acc and orphans.sp before you start the exercises

  1. First list the files in the directory.
  2. Copy ex1.acc to myfile.acc.
  3. Look at the content of both files to ensure they are identical.
  4. Copy ex1.dat to myfile.acc.
  5. Check that the content of myfile.acc changed.
  6. Delete myfile.acc.
  7. Make a directory test and move the three files to it.
  8. Make a directory data and move the three files to that instead.
  9. Remove test' directory.
  10. Change directory to data and confirm that you succeeded. Go back to the home/work directory afterwards.
  11. Make three new directories newtest - one inside the other, like a Russian doll.
  12. Move the data directory to the innermost newtest directory.
  13. Confirm that the three files are moved along with the data directory.
  14. Copy the three files to your home (your top directory).
  15. Remove all newtest directories and data in the with a single command.
  16. Count the lines in ex1.acc and ex1.dat.
  17. Concatenate ex1.acc and ex1.dat in the file ex1.tot, i.e. copy the content of two files into one new file. Verify that all gene IDs comes first followed by numerical data.
  18. Merge/Paste ex1.acc and ex1.dat together in ex1.tot, thus destroying the old file. Verify that corresponding gene IDs and numerical data are put on the same line as the data.
  19. Extract (cut) SwissProt ID and 3nd numerical data (column 1 and 5) from ex1.tot. Put results into a file ex1.res.
  20. Find the 3 SwissProt ID's in ex1.res which have the largest number(s) in column 2, i.e. the top 3 entries. Display only the ID's.
  21. Find the lines (using grep) in orphans.sp which contain a GenBank accession number. There are 85, verify this. Note: An accession number is one or two capital letters and looks like this 'AB000114.CDS.1', i.e. Some letters followed by some numbers. The .CDS. part is kind of optional.
  22. How many human genes with SwissProt IDs in orphans.sp exist ? How many of those are hypothetical ? (11)
  23. How many genes belong to the rat, and how many of those are precursors ? (9) Note: A Swissprot ID looks like 'PARG_HUMAN' or 'TF1A_MOUSE', with the gene being before the underscore and the organism after the underscore.
  24. From the file ex1.res find the lines with positive numbers and put then into ex1.pos. The lines with negative number go into ex1.neg.
  25. Calculate ((356+51)*123-12765)/56 on the command line.

Exercises to do after Thursday

  1. Go back to exercise 2 & 3. Check if the files are changed, using diff this time.
  2. In the myfile.acc (copy of ex1.acc) change all occurrences of SPC to BLNK, using sed. Check if the files are changed, using diff.
  3. What is the path to the bash command?
  4. Write a bash shell script that solves exercise 19-24, with the exercises clearly separated and explained in both the script and the output. "42" is unclear, but "Number of genes: 42" is clear. This should be straight forward (but long), especially since you wrote down what you did.
  5. Write a bash shell script that puts all the positive numbers in the file ex1.dat into a file ex1.pos2, and all the negative numbers into a file ex1.neg2. Column position does not matter. The script must clean up after itself, so if any temporary files are used, they must be deleted as the last action. Put the date and a description of the files in the first lines of the resulting output files.
  6. Write a bash shell script that calculates the total number of lines for all files in the directory mentioned on the command line as argument. No argument means current directory. Misleading hint: cut can split on other than tab.

Exercises for extra practice