Skip to content

Instantly share code, notes, and snippets.

@lindenb
Created April 19, 2014 09:37
Show Gist options
  • Save lindenb/11079312 to your computer and use it in GitHub Desktop.
Save lindenb/11079312 to your computer and use it in GitHub Desktop.
genbank to fasta
BEGIN {
inE=0;
inS=0;
def="";
}
/\/\// {
inS=0;
inE=0;
next;
}
/^VERSION/ {
inE=1;
gi=0;
n=split($0,A,/[ ]+/);
for(i=1;i<=n;++i)
{
if(substr(A[i],1,3)=="GI:") gi=substr(A[i],4);
}
printf("\n>gi:%s|%s\n",gi,def);
next;
}
/^DEFINITION/ {
def=substr($0,13);
next;
}
/^ORIGIN/ {
inS=1;
next;
}
{
if(!(inS==1 && inE==1))next;
gsub(/[ 0-9]/,"");
print;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment