So far we've made a pretty cool script that takes the reverse complement of a DNA sequence.
Let's build on our previous work to make a full-fledged script.
Now, let's make it executable. That means that we don't have to type “bash” anymore. This will be important when we use our script as a command.
For this part,
So far, the only way to run our script is by
$ bash revComp
and we must be in the same directory as revComp.
What we're really doing is executing bash, and giving our file as the argument to the bash program.
We're going to make a change to the permissions so we can execute our script directly.
It's not executable yet. We can easily make it executable with chmod.
$ ls -l revComp -rw-r--r-- 1 fileowner filegroupname 62 Jul 16 12:32 revComp $ chmod 755 hello_world $ ls -l hello_world -rwxr-xr-x 1 fileowner filegroupname 62 Jul 16 12:32 revComp
Notice the x in the 4th, 7th, and 10th positions. This means that the file has execute permissions for the file owner, the file group, and everyone, respectively.
Two common permission settings for scripts are:
To learn more about file permissions and these numbers, see file permissions.
$ chmod 755 revComp $ ./revComp ACTGTACGGTACAC sequence: ACTGTACGGTACAC complement: TGACATGCCATGTG reverse: CACATGGCATGTCA reverse complement: GTGTACCGTACAGT sequence length: 14
We removed the “bash” but replaced it with dot slash “./” which might seem like the same amount of work.
Currently, our script only works in the directory ~/Bash_Scripts.
For example:
$ cd $ bash revComp TAG bash: revComp: No such file or directory
When you log on, you start in your home directory. So you'll get the same result as above.
So how do you make the script work from anywhere?
We are going to:
1. Go to your home directory.
$ cd $ pwd # should be your home directory
2. Make the new directory for finished scripts. By convention, it is called bin
$ mkdir bin $ ls # should see the new directory bin, plus Bash_Scripts and anything you created before
3. Copy the finished script to the new directory. Use TAB-completion to help you not type so much.
$ cp Bash_Scripts/revComp bin/ $ ls bin
Is revComp there?
4.