Allow splitFasta generated filenames to be fasta record ids
It would be nice if the splitFasta operator had an option to save the fasta files it generates named with the fasta record id. This would only work in instances where splitFasta splits to one file and the record id is acceptable as a filename, but this is still a fairly common request that we see.
It could be added a autoNames option. However fasta IDs tend to contain reserved linux/posix special characters eg. |, ', &, etc. How to sanitize it?
I'd just do something like: header.replaceAll("[^a-zA-Z0-9]","") or header.replaceAll("[^a-zA-Z0-9]","_") and maybe emit a warning if a header needs to be changed. My feeling is that if someone wants to use fasta headers as filenames, then it's up to them to make the headers workable as filenames. Given that there is a very reasonable fallback (i.e. the current behavior) I don't think this option needs to go to great lengths to accommodate every edge case.
I gave a try to this, but it's more complicated than it could seem and it cannot be always applied. For example: chunks can be pure textual ie. the fasta ID is not parsed or in the most common scenario fasta chunks contain more than a single fasta record (what ID should be used?).
I think it would be better to leave the user to manage this. #397 should simplify this.
Do you have a branch with the code you experimented with? I'd like to better understand what's difficult.
There isn't a specific branch. You can look at FastaSplitter and related classes.