Contact: to feature here

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CommandSets: Shell Scripting for Bioinformatics
Hello all,

Shell scripting has been an indispensable part of Bioinformatics. Thought to initiate a thread for discussing problems/codes/useful one-liners/anything that can ease the life of the Bioinformaticians!

Here are some of the useful one-liners one can use for various purposes ( assuming actions on tab separated text file):

Transpose of a File :
awk '{ for (i=1; i<=NF; i++) { a[NR,i] = $i }}NF>p { p = NF }END { for(j=1; j<=p; j++) {str=a[1,j];for(i=2; i<=NR; i++){str=str" "a[i,j];}print str}}'

Number of Columns and Rows in a matrix
awk '{print NF}' (For Columns)
awk '{print NR}' (For Rows)

Print Even and Odd Numbered Columns and Rows in a matrix
awk '{NR%2==0}' For Even Rows
awk '{NR%2==1}' For odd Rows
awk '{NF%2==0}' For Even Columns
awk '{NF%2==1}' For Odd Columns

Fastq to Fasta conversion
Use FASTX Toolkit from Hannon Lab: Click Here for the link.

The Magic of !!
Double exclamation is a very useful command in Shell (those who have used it, would agree). Whenever you type !! in your terminal, it will print and execute the Last Shell Command you used on your Linux Terminal. Now this puts forward an array of possibiliies using !!.

Just for an example:
Use !! to add your last used command into any file or even a shell script you want to update.
If I use:
and then
!! (it will print following)

So, you can do echo !! >> filename (this will append the last used command to your file.

Delete First Line of a File
All you have to do is:
sed '1d' Filename

Delete all lines having a particular string
sed '/STRING/d' Filename

So, these were some of the tips for today. I'll keep it posted. And, let's share tips and problems here.
Sunil Nagpal
MS(Research) Scholar, IIT Delhi (Alumnus)
Advisor for the Biotech Students portal (
Computational Researcher in BioSciences at a leading MNC

Suggested Reads:
Top Biotech Companies | Top places to work
Indian Biotech Companies and Job Openings
Aiming a PhD in Top Grad School? | These are the Important Points to Consider
Careers in Biotechnology | A list of various Options
Biotechnology Competitive Exams in India
Like Post Reply

Possibly Related Threads...
Last Post
Replies: 21
Views: 9,503
10-20-2017, 06:06 AM
Last PostSunil Dhasmana
Replies: 0
Views: 530
08-08-2017, 04:22 PM
Last Postbinu
Replies: 1
Views: 1,595
05-25-2017, 07:48 PM
Last PostRoshan Raj
Replies: 1
Views: 1,252
05-16-2017, 03:46 AM
Last PostLavkeshsharma

Users browsing this thread:
1 Guest(s)

CommandSets: Shell Scripting for Bioinformatics00