Take care that cat chr*.fa chr*_gl0000**_random.fa ... > output.fasta will put duplicates in the final output as files chrUn*_gl0000.blabla.fa are matched by multiple globs.
Concatenate the chromosome files from hsa19 into a single FASTA file
Hi, I need to concatenate the chromosome files into a single FASTA file but I have a lot of files with strange names.
- The typical
chr*.fa - Random
chr*_gl0000**_random.fa - ChrUn
chrUn_gl0000**.fa
Note that * means any number
What is the correct order to concatenate these files with cat? In working in making the reference for mapping smallRNA.
Thanks in advance
• 9,336 views
•
link
2 answers
cat * > genome.fa will lose the numerical ordering (for lexicographical ordering instead) so you get: 1, 11-19, 2, 20-22, 3-9, M, other, X, Y. Some tools want the proper ordering (1-22, X, Y, M, other), which is doable in a line of bash :
echo "$(ls chr*.fa | sort -V | grep -vP 'chr[^X|Y|\d]'; ls chr*.fa | sort -V | grep -vP 'chr[\d|X|Y]')" | xargs cat > genome.fa
• 0 views
•
link
cat chr*.fa chr*_gl0000**_random.fa chrUn_gl0000**.fa > output.fasta
* means "anything", so it should work.
But keep it even more simple: cat *.fa > output.fasta
• 0 views
•
link
• 0 views
•
link
Log in to answer this question.
Those are sequences can not be assigned to a certain chromosome. see here.
I do not think the order of the fasta file matters (correct me if I am wrong)
what I did:
and if this is small rna you will get a lot of multiple mapped reads if you add all chromosomes, that if you plan to remove is better to use only the known chromosomes and maybe the chrUn. But the latter, normally are ribosomal genes, that have some copies in the genome as well. So, you need to think about the strategy you want to follow to map and annotate to decide this beforehand.