BiotechnologyForums presents PAIRS: The Game of Nucleotides. Starting an era of Biology Games    
  • Welcome to Biotechnology Forums!
  • Contribution is the key to connections! Stay active and you'll benefit a lot!
  • Defeat the Difficulties!
Hello There, Guest! Login Register

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CommandSets: Shell Scripting for Bioinformatics
This is post no. 1 under the main topic.
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

Possibly Related Threads...
Thread Author Replies Views Last Post
  Career in Bioinformatics SunilNagpal 9 3,043 04-25-2017, 04:25 AM
Last Post: Saurabh R.
  Bioinformatics Tools - Databases, Alignment, Evolutionary and Protein Analysis joshuajoby 9 17,457 11-11-2016, 03:14 AM
Last Post: stevewoods
  Bioinformatics Applications: Genomics, Proteomics and Transcrptiomics NatashaKundi 6 30,333 12-05-2014, 08:38 PM
Last Post: zoya
  Workshop on Bioinformatics and Interdisciplinary Technologies (BAIT) Karthik Kalyan 0 3,138 05-26-2014, 06:13 PM
Last Post: Karthik Kalyan
  Masters in Bioinformatics after Computer Science Sreenath Ak 0 2,551 01-09-2014, 05:20 PM
Last Post: Sreenath Ak

Browsing: 1 Guest(s)