#!/usr/bin/perl
#################################
#Author: Jack Min
#Program: uniqID
# 	the program is used to retrieve the uniqe seqIDs from a set of IDs
#
#############################

if ($#ARGV != 1)
{
	print "Usage: uniqID.pl inFile outFile \n";
	exit;
}

$inFile = $ARGV[0];
$outFile = $ARGV[1];

open (INPUT, $inFile) || die ("Cannot open file $inFile !!\n");
@content = <INPUT>;
close (INPUT);

@idArray = ();
$id = '';
print "In progress ...\n";
$flag = 0;
foreach $line1 (@content)
{
	$flag = 0;
	chomp($line1);
	foreach $line2 (@idArray)
	{
		chomp($line2);

		if ($line1 eq $line2)
		{
			$flag = 1;
			print "duplicate: ".$line1."\n";
			last;
		}
	}
	if ($flag ==0)
	{
		push(@idArray, $line1."\n");
		push (@newArray, $line1."\n");
	}
}


open (OUTPUT, ">$outFile") || die ("Cannot open for writing file $outFile !\n");
print OUTPUT (@newArray);
close OUTPUT;

print "The work is done!\n";

exit;


