get_embl_mim_mapping.pl 1.31 KB
Newer Older
1 2 3 4
use strict;

#Some doc will come ...

5 6
#perl ../../../src/ensembl-live/misc-scripts/protein_match/get_embl_mim_mapping.pl -sp ../primary/hum_sp_sptrembl.pep -dbmap mapdb.map -output sp_embl_mim.map

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
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
24 25
print STDERR "Reading DBmap\n";

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

Emmanuel Mongin's avatar
Emmanuel Mongin committed
32 33
print STDERR "Reading SP\n";

34 35 36 37 38 39
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
40
    
41
    foreach my $link(@dblink) {
Emmanuel Mongin's avatar
Emmanuel Mongin committed
42 43 44 45
	if ($link->database eq "EMBL") {
	    if (!defined $map{$ac}) {
		die "Can't map $ac\n";
	    }
Emmanuel Mongin's avatar
Emmanuel Mongin committed
46
	    
Emmanuel Mongin's avatar
Emmanuel Mongin committed
47
	    print OUT "$map{$ac}\t$ac\tEMBL_AC\t".$link->primary_id,"\n";
48 49 50

	    my ($protac) = $link->optional_id =~ /^(\w+).\S+/;
	    print OUT "$map{$ac}\t$ac\tEMBL_PROT_AC\t$protac\n";
Emmanuel Mongin's avatar
Emmanuel Mongin committed
51 52
	}
	if  ($link->database eq "MIM") {
Emmanuel Mongin's avatar
Emmanuel Mongin committed
53 54 55
	    if (!defined $map{$ac}) {
		die "Can't map $ac\n";
	    }
Emmanuel Mongin's avatar
Emmanuel Mongin committed
56 57
	    
	    print OUT "$map{$ac}\t$ac\tOMIM\t".$link->primary_id,"\n";
58
	}
Emmanuel Mongin's avatar
Emmanuel Mongin committed
59 60
	
	
61
    }
62 63


64 65 66
}


67 68 69 70 71 72 73 74 75 76 77 78