I have a folder fasta_files containing 500 files
Each file contains fasta sequence which is in this format
cat $file.fnn
>Fas1#66
EEYLKKFLMTSLVGFMYRMYKEYEVPDTDRNWTPKPSSAEFPGLKELKIKIDQLQLLLDTACSDESNTELTLLTLLEFIRAG
>Fas2#80
LQEWMPSYSKPTHTTKTLLSELITLVDTLKQETNDVPSESVVNTILSIADSCKTQTQKSKEAKTTIDSFLREH
.
.
.
>Fas3#87
VDTCASTCADTNVNTCASMCADTNVDTCASTCANTCASTEYTDLADPERIPLHIMQKTLNVPNELQADI
In addition, a got a blast file output which is in this format
Cat blastfile
Fas1#66 gi|1769046680|dbj|**BBO53957.1**| 100.000 0.0 1264 2654827 N/A N/A
Fas1#66 gi|1769046681|dbj|**BBO53958.1**| 100.000 0.0 1117 2654827 N/A N/A
Fas2#80 gi|1769046682|dbj|**BBO53959.1**| 100.000 0.0 1119 2654827 N/A N/A
Fas3#87 gi|1769046683|dbj|**AWO53960.1**| 100.000 6.01e-118 339 2654827 N/A N/A
My aim is to make a connection between each of fasta.fnn with the blastfile in order to obtain the value after the third pipe (mentioned with bold) in the blastfile like the output below
Cat $file.list
BBO53957.1
BBO53958.1
BBO53959.1
AWO53960.1
I wrote this script which works
mkdir fasta_files/lists
mkdir fasta_files/fnn
echo "1" >counter
for file in $(ls fasta_files/*.fnn) ;do
cat $file|grep ">" |sed 's/>//'g|grep -wf- /home/kgee/DATA/blastfile |awk '{print $2}'|cut -d\| -f4 |sort -u >$file.list
mv $file.list fasta_files/lists
mv $file fasta_files/fnn
echo "**" $(tail -1 counter) "** LIST GENE FAMILIES FILES GENERATED"
awk '{print $1+1}' counter >>counter
done
mv *list* lists
rm counter
The screen output is this:
** 1 ** LIST GENE FAMILIES FILES GENERATED
** 2 ** LIST GENE FAMILIES FILES GENERATED
** 3 ** LIST GENE FAMILIES FILES GENERATED
** 4 ** LIST GENE FAMILIES FILES GENERATED
** 5 ** LIST GENE FAMILIES FILES GENERATED
** 6 ** LIST GENE FAMILIES FILES GENERATED
** 7 ** LIST GENE FAMILIES FILES GENERATED
** 8 ** LIST GENE FAMILIES FILES GENERATED
** 9 ** LIST GENE FAMILIES FILES GENERATED
** 10 ** LIST GENE FAMILIES FILES GENERATED
** 11 ** LIST GENE FAMILIES FILES GENERATED
** 12 ** LIST GENE FAMILIES FILES GENERATED
Cursor blinks for ever
All the 12 generated files $file.list in the folder file.list are exactly like I want.
My issue is that after the 13th time the loop brakes for a reason.
I removed the 13th file from the folder but again the loop "breaks" at the 13th time.
I removed all the files except 20 files and again "breaks" at the 13th time
Does anyone have any idea how to overcome this problem?