Thanks, this is good. I want to use this in combination with a find command, could you tell me why this isn't working?
for files in `find . -type f -name '*.consensus.fasta' -not -path "*/temp/*"`
do
faSplit byname $files outRoot
done
So far I have this
awk '/^>/{s=++d".fasta"} {print > s}' file.fasta
This splits the file just as I want it, but it produces new files called 1.fasta, 2.fasta, 3.fasta and so on. Is there a method of splitting it that has the new file name as the ID of the sequence inside?
Or failing that, is there a quick way of renaming fasta's based on their ID?
faSplit ( http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/faSplit ) utility by Jim Kent from UCSC.
faSplit byname your_file.fa outRoot/
Thanks, this is good. I want to use this in combination with a find command, could you tell me why this isn't working?
for files in `find . -type f -name '*.consensus.fasta' -not -path "*/temp/*"`
do
faSplit byname $files outRoot
done
What is not working? Did you make a real directory to replace outRoot?
Hi, yes I did make a more suitable directory! Just didn't include it because the name is sensitive. I meant just looking at the loop, It's so simple but It just doesn't work.
You need to include the trailing / after the directory name for this to work right. Try this.
for files in `find . -type f -name '*.consensus.fasta' -not -path "*/temp/*"`
do
faSplit byname $files outRoot/
done
create the filename with sprintf
echo -e ">hello\nAAA\n>world\nATGCA" |\
awk '/^>/ {fout=sprintf("%s.fasta",substr($0,2));}{print >> fout;}'
Log in to answer this question.