Hi I have two files. One file contains all my interested uniprot id and second file contains uniprot ID with their corresponding family. My aim or I am trying to create new file.
So from file1, I want compare all Id with file2's Id. If equal then they should print id with their family name or not equal then they should print their id with 'None' word.
I uploaded, File1 which contains uniprot Id.
File2 which contains uniprot Id and family name.
File3 is my desired output file.
I tried to write script for it and that is
#!/usr/bin/perl -w
use strict;
my $outfile = 'file3.txt';
open (OUTFILE, ">$outfile") or die "Cannot open $outfile for writing \n";
open (PM,"./file1.txt");
my @uniprot = <PM>;
close (PM);
my @col;
while (my $line = <>)
{
@col = split(/\s+/,$line);
print $col[1],"\n";
for (my $i=0; $i<@uniprot; $i++)
{
chomp $uniprot[$i];
print OUTFILE $uniprot[$i],"\t";
if ($uniprot[$i] eq $col[0]) {
print OUTFILE $col[1],"\n";
}
elsif ($uniprot[$i] ne $col[0]) {
print OUTFILE "None \n";
}
}
}
#print OUTFILE @uniprot;
close (OUTFILE);
Although its not working at all.
If anyone kindly help me I will be grateful to you.
Thank you in advance.
cheers
pallab