/usr/share/gmod/chado/bin/gencode2sql.pl is in chado-utils 1.23-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #!/usr/bin/env perl
#This is old code and hasn't been tested!
use strict;
use warnings;
my @nucs = qw(T C A G);
my $x = 0;
my @codons = ();
for my $i (@nucs) {
for my $j (@nucs) {
for my $k (@nucs) {
my $codon = "$i$j$k";
$codons[$x] = $codon;
$x++;
}
}
}
print "-- autogenerated by gencode2sql.pl from NCBI gencode.dmp\n";
print "SET search_path=public,genetic_code;\n";
my @rows=();
while(<>) {
chomp;
push(@rows, [split(/\s*\|\s*/,$_)]);
}
foreach (@rows) {
my ($id,$x,$n,$code,$starts) = @$_;
printf("INSERT INTO gencode (gencode_id,organismstr) VALUES (%d,%s);\n", $id, pquote($n));
}
foreach (@rows) {
my ($id,$x,$n,$code,$starts) = @$_;
next unless $id;
my @codes = split('',$code);
for (my $i=0;$i<64;$i++) {
printf("INSERT INTO gencode_codon_aa (gencode_id,codon,aa) VALUES (%d,%s,%s);\n",
$id,
pquote($codons[$i]),
pquote($codes[$i]));
}
}
foreach (@rows) {
my ($id,$x,$n,$code,$start) = @$_;
next unless $id;
my @starts = split('',$start);
for (my $i=0;$i<64;$i++) {
printf("INSERT INTO gencode_startcodon (gencode_id,codon) VALUES (%d,%s);\n",
$id,
pquote($codons[$i]))
if $starts[$i] eq 'M';
}
}
sub pquote {
my $s = shift;
$s='' unless defined $s;
if ($s =~ /^\-?[0-9]+$/) {
return $s;
}
return "''" unless $s;
$s =~ s/\'/\'\'/g;
"'$s'";
}
|