Q:

Regex to match "a string of length less than X resides between two ">" symbols"

The have text in this form:

>xxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxx
>xxxxxxxxxxxxxx
xxxxxxxxxxx
>

I need regex to match all >xxx... if there is less than, say a 100, amount of x in between > symbols. How can I do this?
The actual problem is: "smalt.c:334 ERROR: sequence too short to be hashed"
when trying to index fasta file with reference sequences of multiple viruses. It worked before, when only longer sequences were present in the file.
I haven't found a solution for the smalt error (and even if I would, I would prefer to run it first with default settings), so 
I need to remove all the shorter reference sequences from the reference file.

A:

you can use grep to give you only the parts of the file where there are more than 100 characters in between > and write the results into a new file (which then should work with fasta):
grep -Pzo '>[^>]{100,}' fasta.txt > fasta_wo_short_genes.txt

explanation:

-P tells grep to accept pearl regular expressions (for some reason, I could not get it to work with the normal grep regular expressions)
z tells grep to see the whole file as one big line
o tells grep to output only the matching parts (otherwise, because of the z flag it would always output the whole file if it finds any match at all)

the regular expression:

> the character separating your virus gene sequences
[^>] matches any character except >
{100,} matches 100 or more repetitions of the previous expression (in this case [^>])

