File: fasta-split

package info (click to toggle)
staden 2.0.0%2Bb11-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 21,556 kB
  • sloc: ansic: 240,603; tcl: 65,360; cpp: 12,854; makefile: 11,201; sh: 2,952; fortran: 2,033; perl: 63; awk: 46
file content (17 lines) | stat: -rwxr-xr-x 342 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#! /bin/sh
AWK=gawk
for x in $*
  do
    echo splitting ${x}
$AWK '
BEGIN { f = ""; }
/^>/ { if ( f != "" ) close(f); f = substr($1,2);
"if [ -r " f " ] ; then echo yes ; else echo no ; fi" | getline result;
if (result == "yes") { print "File " f " already exists"; f = "";} else
print f;
next;} 
{if (f != "") print $0 >> f ;}
' $x
  done