BEGIN {
	isSeq = 0 ;
	nbFeature = 0 ;
	nbCds = 0 ;
	Lseq = 0 ;
        label=">" filename;
	print label  > filename ;
}


{
	
	if ($0 ~ /^FT   [a-zA-Z]/ || $0 ~ /^     [a-zA-Z]/) 
	{
		nbFeature ++ ;
	}
	if ($0 ~ /^FT   CDS/ || $0 ~ /^     CDS/ ) 
	{
		nbCds ++ ;
	}
	if ( isSeq == 1 &&  $0 !~ /\/\// )
	{
		seq = $0 ;
		gsub("[0-9 \t]","",seq);	
		print  toupper(seq) > filename ;
		Lseq = Lseq + length(seq)  ;
	}

	if ( $0 ~ /^ORIGIN/ ) { isSeq = 1 ; }
	if ( $0 ~ /^SQ/ ) { isSeq = 1 ; }

}

END {
	#print "longueur sequence : " Lseq ;	
	if ( nbFeature <= 1 || nbCds <= 1 )
	{
		print 0 ;
	}
	else 
	{
		print Lseq ;
	}
}
