0

I have multiple directories with multiple fasta files in those directories. I am trying to concatenate all files starting with a specific name in each of the directory into a single file. hpa_C.seq PANS_1_2__hpaC.fasta PANS_4_2__hpaC.fasta PNA_02_12__hpaC.fasta PNA_07_7__hpaC.fasta PNA_18_9S__hpaC.fasta PNA_98_12__hpaC.fasta PNA_99_3__hpaC.fasta leu_D.seq PANS_1_2__leuD.fasta PANS_4_2__leuD.fasta PNA_02_12__leuD.fasta PNA_07_7__leuD.fasta PNA_18_9S__leuD.fasta PNA_98_12__leuD.fasta PNA_99_6__leuD.fasta nta_A.seq PANS_1_2__ntaA.fasta PANS_4_2__ntaA.fasta PNA_02_12__ntaA.fasta PNA_07_7__ntaA.fasta PNA_18_9S__ntaA.fasta PNA_98_12__ntaA.fasta PNA_99_6__ntaA.fasta

I tried the following script to concatenate all the fasta files starting with names PANS_1_2 into a output file

for sample in *.seq;do 
  echo -en $sample
  cat *.seq/PANS_1_2*.fasta
done > xyz

The script however is returning sequences multiple times in the output file.

1
0

cat *.seq/PANS_1_2*.fasta > xyz already concatenates all fasta files. The for loop multiplies that by the number of seq files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.