The Shell Solution
diff <(cat file1.fasta | grep ">" | sort) <(cat file2.fasta | grep ">" | sort)
IDs that are in file1 but not if file2
To the diff command add:
| grep "^<" | awk -F\> '{print $2}'
IDs that are in file2 but not if file1
To the diff command add:
| grep "^>" | awk -F\> '{print $3}'
Examples<
diff <(cat file1.fasta | grep ">" | sort) <(cat file2.fasta | grep ">" | sort) | grep "^>" | awk -F\> '{print $3}'
CPS1_PENJA, 623 bases, 9643C925 checksum.
Y5SS2_CAEEL, 623 bases, E99BFB checksum.
YUA6_CAEEL, 623 bases, A389AA05 checksum.
diff <(cat file1.fasta | grep ">" | sort) <(cat file2.fasta | grep ">" | sort) | grep "^<" | awk -F\> '{print $2}'
YSS2_CAEEL, 623 bases, E99BFB checksum.
Credits
The powerful command line tools are brought to you by GNU - the brilliant software written overwhelmingly in C an ported to all imaginable kernels: Solaris, OpenSolaris, OpenIndiana, FreeBSD, OpenBSD, NetBSD, Linux, Cygwin (Windows XP, Server, Vista, and 7).
Hi Marco! You're welcome to ask beginner questions here. If you show us what you've tried so far in code and/or thought, I'm sure someone will be willing and able to answer your question. For instance, you might want to align your sequences first.
Hi Marco! You're welcome to ask beginner questions here. If you show us what you've tried so far in code and/or thought, I'm sure someone will be willing and able to answer your question.
Can you clarify whether, for example, seqA in file1 is similar only to sequences in file1, or file2, or both?
Sai Liu asks: What's the meaning of similar sequence? You can give us some extract examples.
I have 2 file in which there are a lot of sequence, but most of them are the same. I want to exclude the identical sequence and extract only different sequence ant to know from which file (1 or 2) they came. for similar sequence I mean identical sequence with identical name, ID etc.