intro to bioinformatics, Assignments of Bioinformatics

Programming for Bioinformatics introduction quiz

Typology: Assignments

2016/2017

Uploaded on 06/30/2026

teacup_tornado
teacup_tornado ๐Ÿ‡บ๐Ÿ‡ธ

8 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ls โ€“ list files in your current directory
man - manual
emacs โ€“ a text editor
cp โ€“ copy a file or directory
rm โ€“ remove a file
mv โ€“ move a file or directory
cat >, >> and | - concatenate, redirect, append and pipe
head, tail and more โ€“ look at whatโ€™s in a file
mkdir โ€“ make directory
rmdir โ€“ remove directory
echo โ€“ print something
exit โ€“ leave a shell or remote connection
wc โ€“ count the number of words in a file
1.) Working with ls
a) List all of the files in /usr/bin
ls /usr/bin
list all the content in the directory usr, folder bin.
b) Use the man command with ls
man ls
Opens the manual for ls
c) List the size of all of the files in /usr/bin
ls โ€“s /usr/bin
-s print size for all files.
d) List the permissions of those files
ls โ€“l /usr/bin
-l print each file in long listing format. (r refer to read, w to write, and x to
execute)
e) Lit all of the files that start with โ€˜aโ€™, what are the . and .. files/directories?
ls /usr/bin/a*
list all file start with a. *wildcard
. means the present working directory, .. means one directory up.
f) List all files of the type .pl in /usr/bin
ls /usr/bin/*.pl
list files with the type.pl in /usr/bin
2.) Creating and editing a file with emacs
a) Use emacs to open a file by the name abc.txt for editing
emacs abc.txt
emacs file name to create a file
b) Write something in the file
c) Save and close the file with ctrl-x ctrl-s and ctrl-x ctrl-c
1
pf3
pf4
pf5

Partial preview of the text

Download intro to bioinformatics and more Assignments Bioinformatics in PDF only on Docsity!

ls โ€“ list files in your current directory man - manual emacs โ€“ a text editor cp โ€“ copy a file or directory rm โ€“ remove a file mv โ€“ move a file or directory cat >, >> and | - concatenate, redirect, append and pipe head, tail and more โ€“ look at whatโ€™s in a file mkdir โ€“ make directory rmdir โ€“ remove directory echo โ€“ print something exit โ€“ leave a shell or remote connection wc โ€“ count the number of words in a file

1.) Working with ls a) List all of the files in /usr/bin ls /usr/bin list all the content in the directory usr, folder bin. b) Use the man command with ls man ls Opens the manual for ls c) List the size of all of the files in /usr/bin ls โ€“s /usr/bin -s print size for all files. d) List the permissions of those files ls โ€“l /usr/bin -l print each file in long listing format. (r refer to read, w to write, and x to execute) e) Lit all of the files that start with โ€˜aโ€™, what are the. and .. files/directories? ls /usr/bin/a* list all file start with a. *wildcard

. means the present working directory, .. means one directory up. f) List all files of the type .pl in /usr/bin ls /usr/bin/*.pl list files with the type.pl in /usr/bin

2.) Creating and editing a file with emacs a) Use emacs to open a file by the name abc.txt for editing emacs abc.txt emacs file name to create a file b) Write something in the file c) Save and close the file with ctrl-x ctrl-s and ctrl-x ctrl-c

3.) Copying and removing a file a) Use cp to create a copy of the file you just created cp abc.txt copy.txt cp file name and make a copy as copy.txt b) Use rm to remove the copy rm abc.txt rm file name

4.) cat and redirecting output a) Use cat to display the contents of the file you created cat copy.txt display content in copy.txt b) Redirect the output to another file using > cat copy.txt >redirect.txt redirect the content to another file. c) cat the first file to the second file again, but use >> cat copy.txt >>redirect.txt add the first file to the bottom of the second. d) Use cat to display the contents of the second file cat redirect.txt display whatโ€™s in the file.

5.) Looking at whatโ€™s in a file a) Navigate to ~/class/ex1/, Use the head and tail commands on ex1.bed cd ~/class/ex1/ go to the directory. head ex1.bed display first 10 lines of a file tail ex1.bed display last 10 lines of a file b) Use the more command on your ex1.bed more ex1.bed display the file, can scroll down c) Try using different sizes with the head and tail commands head -5 ex1.bed list the top 5 lines of the file tail -12 ex1/bed list the bottom 12 lines of the file d) Use the less command on your ex1.bed less ex1.bed display data.

6.) Making and removing directories a) Create a directory with mkdir

b) Count the character in the file ex1.bed using wc wc -m ex1.bed 78290 ex1.bed -m count by character. c) Count the number of lines in the file ex1.bed using wc wc -l ex1.bed 3414 ex1.bed

9.) Redirecting different streams a) Run this command: perl -e 'foreach(1..100){print $."\n"; print STDERR ($ / 2)."\n"}' b) Redirect only the standard output to out.txt > out.txt > standard output c) Redirect only the standard error to err.txt 2> error.txt 2> standard error d) Redirect standard output to out.txt and standard error to err.txt > out.txt 2>err.txt e) e.) Redirect both standard output and standard error to seq.txt >seq.txt 2>& both standard output and error.

10.) Piping data โ€“ Key concept (if you learn one thing here, let it be this) a) Run this command: perl -e 'foreach(1..100){print $."\n".($ / 2)."\n"}' > seq.txt b) Browse the output with the head, tail and more commands. head seq.txt Top ten lines tail seq.txt Bottom ten lines more seq.txt See details. c) Display different amounts of data with the head and tail commands. head -3 seq.txt display top 3 lines tail -4 seq.txt display bottom 4 lines d) Using the head and tail commands, along with โ€˜|โ€™, get the 50th^ line of the fil head -50 | tail -1 seq.txt first 50 lines and last 1 from the previous 50 e) Print everything but the top 13 lines tail -n +14 seq.txt print from #14 and down f) Print everything but the last 13 lines head -n -13 seq.txt

g) Count the number of characters between lines 45-50 (inclusive) head -50 | tail -6 | WC -m seq.txt -m count by character. The last 6 lines of 50.

Additional exercises: 1.) Go through the emacs tutorial. Many of the same controls for editing text in emacs can be used to edit text at the command line, e.g. ctrl-a or ctrl-k. Emacs is a very powerful editor and knowing it will serve you well. The meta key defaults to escape in Mac OS X, change it under preferences. 2.) Change the colors in your prompt setting to something you like. export PS1=" \e[36m\u@\h:\e[35m\W$ \e[m" cyan and purple 3.) Get a webpage up by requesting access through OIT