Tuesday, May 4, 2010

Auto remove repeats from a file


Say if you have a file with multiple peptides in a file and you want
to keep only one instance of each peptide.

This script would be of great use.

You could save it as removeduplicates.pl and run it as you run a
normal perl script.

open(FILE,"FILENAME");
@peptides=;
%seen=();
@unique=grep{! $seen{$_} ++} @peptides;
print @unique;

If you want to print the output to a file , do the following

perl removeduplicates.pl > Outputfilename

No comments:

Post a Comment