get_embl_mim_mapping.pl 940 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
use strict;

#Some doc will come ...

use Getopt::Long;
use Bio::SeqIO;

my ($sp,$dbmap,$out);

my %map;


&GetOptions(
	    'sp:s'=>\$sp,
	    'output:s'=>\$out,
	    'dbmap:s'=>\$dbmap
            );

open (DBMAP,"$dbmap") || die "Can't open file $dbmap\n"; 
open (OUT,">$out") || die "Can't open file\n";

Emmanuel Mongin's avatar
Emmanuel Mongin committed
22 23
print STDERR "Reading DBmap\n";

24 25 26 27 28 29
while (<DBMAP>) {
    chomp;
     my ($mapac,$mapdb) = split(/\t/,$_);
     $map{$mapac} = $mapdb;
}

Emmanuel Mongin's avatar
Emmanuel Mongin committed
30 31
print STDERR "Reading SP\n";

32 33 34 35 36 37
my $in1  = Bio::SeqIO->new(-file => $sp, '-format' =>'swiss');

while ( my $seq1 = $in1->next_seq() ) {
    my $ac = $seq1->accession;
    my @dblink = $seq1->annotation->each_DBLink;
    
Emmanuel Mongin's avatar
Emmanuel Mongin committed
38
    
39
    foreach my $link(@dblink) {
40
	if (($link->database eq "EMBL") || ($link->database eq "MIM")) {
Emmanuel Mongin's avatar
Emmanuel Mongin committed
41 42 43 44 45
	    
	    if (!defined $map{$ac}) {
		die "Can't map $ac\n";
	    }

46 47 48 49 50 51
	    print OUT "$map{$ac}\t$ac\t".$link->database."\t".$link->primary_id,"\n";
	}
    }
}


52 53 54 55 56 57 58 59 60 61 62 63