Convert fasta to 1l

From IBERS Bioinformatics and HPC Wiki
Jump to: navigation, search


Copy and paste the following snippet of code:

 #This script is to convert files from multiple lines fasta into 1-line fasta for easy grepping.
 #call it by typing "sh file.fasta"
 namefile=`echo $1 | sed 's/\.fa$//g;s/\.fas$//g;s/\.fasta$//'`;
 #echo $namefile;
 sed '/>/s/$/</' $1 | tr -d "\n" | tr ">" "\n" | sed '/</s/^/>/' | sed '1d' | tr "<" "\n" > ${namefile}.1l.fasta;

To make it self-executable, you can copy it into your ~/bin directory and then do:

 chmod a+x ~/bin/;