5 $SIG{__WARN__} = sub { die @_ };
7 my $mysql = DBI->connect("DBI:mysql:database=seq_demo;user=seq_demo;password=demo_pass");
9 $mysql->do(q{LOCK TABLES prot WRITE,
16 my @aatrans = ($EL,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$EL,$NA,$NA,$EL,$NA,$NA,
17 $NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,
18 $NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA, 24,$NA,$NA,$NA,$NA,$NA,
19 $NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,$NA,
20 $NA, 1, 21, 5, 4, 7, 14, 8, 9, 10,$NA, 12, 11, 13, 3,$NA,
21 15, 6, 2, 16, 17,$NA, 20, 18, 23, 19, 22,$NA,$NA,$NA,$NA,$NA,
22 $NA, 1, 21, 5, 4, 7, 14, 8, 9, 10,$NA, 12, 11, 13, 3,$NA,
23 15, 6, 2, 16, 17,$NA, 20, 18, 23, 19, 22,$NA,$NA,$NA,$NA,$NA
26 my $ins_prot = $mysql->prepare(q{
27 INSERT INTO prot (seq,bin,len) VALUES (?, ?, ?)
30 my $ins_annot = $mysql->prepare(q{
31 INSERT INTO annot (gi, prot_id, db, descr) VALUES (?, ?, ?, ?)
34 my $ins_sp = $mysql->prepare(q{
35 INSERT INTO sp (gi, acc, name) VALUES (?, ?, ?)
38 use vars qw( $seq $bin $tot_seq $tot_annot $tot_sp );
39 use vars qw( $gi $prot_id $db $desc $sp_acc $sp_name );
40 use vars qw( $header $seq @entries );
41 use vars qw( $gi $db $db_acc $db_name $desc);
43 $tot_seq = $tot_annot = $tot_sp = 0;
45 for my $db_file ( @ARGV ) {
46 open(DATA, "<$db_file") or die $!;
49 chomp; # remove trailing "\n>" record header
50 ($header, $seq) = $_ =~ m/^>? # record separator (first entry)
51 ( [^\n]* ) \n # header line
53 /osx; # optimize, multiline, commented
56 $bin = pack('C*', map { $aatrans[unpack('C', $_)] } split(//, $seq));
57 $ins_prot->execute($seq,$bin,length($seq));
58 $prot_id = $ins_prot->{mysql_insertid};
62 # print STDERR "Inserted $prot_id: ". length($seq)."\n";
64 @entries = split(/\001/, $header);
67 ($gi,$db,$db_acc,$db_name,$desc)=
68 $_ =~ /^gi\|(\d+)\|([a-z]+)\|(\S*)\|(\S*) (.*)$/o;
69 # print "$prot_id: $gi\t$db\t$db_acc\t$desc\n";
70 $ins_annot->execute($gi,$prot_id,$db,$desc);
75 $ins_sp->execute($gi,$db_acc,$db_name);
83 print "Inserted $tot_seq sequences; $tot_annot annotations; $tot_sp swissprot\n";