Multiple sequence alignment filtering

How to discard characters containing too many gaps from a FASTA-formatted multiple sequence alignment?

Let $infile be a FASTA-formatted multiple sequence alignment file and $gaprate a real value (from 0 to 1). The following command lines will discard every aligned character containing a proportion of gaps that is higher than $gaprate and write the remaining characters into the FASTA-formatted file $outfile.

goalign

The program goalign allows gapped characters to be filtered out with the following command line:

[170328fl]

awk

[170328ac]