Compare fasta file with text file in bash script
1
0
Entering edit mode
6.2 years ago

Hi everyone ! I have some problems with my bash script. I have a text file( filt80more.txt) that contain my best alignments and I want to compare the alignments in that text file(filt80more.txt) with directory that contain all alignments(Tcoffee_outputs/E.aa.fa.aln) and take out that best alignments from directory(Tcoffee_outputs/E.aa.fa.aln) to my new folder (Filtrerad). I will be very grateful for your help :)

  for FILE1 in Tcoffee_outputs/E*.aa.fa.aln;
   do
    for FILE2 in `cat filt80more.txt`;
      do
       if [ $( diff "${FILE1}" "${FILE2}" ) == 0 ];
        then
mv Tcoffee_outputs/$FILE1~/Users/vazgengevorgyan/Desktop/perl_krill/merged_min_4_species_filtered/Filtrerad/$FILE1
       break
       fi
    done
   done
alignment bash script fast file text file • 1.4k views
ADD COMMENT
0
Entering edit mode

and what exactly is the problem with the script? (I'm not saying it's correct otherwise!). do you get any errors/warnings? or is it just not doing what you expect?

L.

ADD REPLY
0
Entering edit mode

Hi :) I get this error: diff: EOG090Y02RG: No such file or directory getfiles.sh: line 105: [: ==: unary operator expected

ADD REPLY
1
Entering edit mode
6.2 years ago

Try this in the if statement :

if [ $( diff "${FILE1}" "${FILE2}" | wc -l ) == 0 ];

so add " | wc -l " to the if statement. this will check if there are differences reported (= line count will be > 0 )

ADD COMMENT
0
Entering edit mode

Thank you so much for the help :)

ADD REPLY
0
Entering edit mode

If an answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted. Upvote|Bookmark|Accept

ADD REPLY

Login before adding your answer.

Traffic: 1493 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6