Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

2013-07-19

How to convert fasta file to uppercase/lowercase, without altering the annotation line

This awk-oneliner converts all lines which do not contain a '>' in the beginning to upper case:

$ awk '{ if ($0 !~ />/) {print toupper($0)} else {print $0} }' name.fasta

2013-02-18

Use Imagemagick to swap blue and red colors

For a presentation I wanted an image to appear in magenta, rather than in cyan. This is how the image originally looks like:




blue.jgp

With the following command I separated the R, G, B color channels and swapped the Red and the Green channel, to produce a picture in which all blue colors appear in red:

$ convert blue.jpg -separate -swap 0,1 -combine red.jpg

 And that is how the result looks like:




red.jpg


I got this information from: http://www.imagemagick.org/Usage/color_basics/#combine

2012-09-18

Bash Shell: Check if a file exists

To check, whether a file exists use this expression:

First, create the file thisFileExists.txt:
touch thisFileExists.txt

Now, check if it exists:
if [ -f thisFileExists.txt ]
then
  echo It is there
fi

This is what it looks like in terminal: