-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_TATfind.pl
executable file
·78 lines (66 loc) · 1.88 KB
/
load_TATfind.pl
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/perl
# New loader as of 1/2016
use Getopt::Std;
use DBI;
use strict;
use lib $ENV{SCRIPTS};
use ENV;
my %arg;
&getopts('D:u:p:i:', \%arg);
my $user = $arg{'u'};
my $password = $arg{'p'};
my $db = $arg{'D'};
my $host = $ENV{DBSERVER} ? $ENV{DBSERVER} : 'localhost';
my $dbh = DBI->connect("dbi:mysql:host=$host;database=$db", $user, $password);
if (! $dbh) { die "Couldn't connect with $host / $db / $user / $password\n";}
my $infile = $arg{'i'};
if (! $infile) { die "No input file provided with -i\n";}
if (! -r $infile) { die "$infile is not readable: $!\n";}
open my $in, $infile or die "Can't open $infile: $!\n";
my $ev_d = "DELETE FROM feature_evidence"
. " WHERE feature_id = ?"
. " AND ev_type='SP'"
. " AND program='TATfind'";
my $dsth = $dbh->prepare($ev_d);
my $ev_i = "INSERT INTO feature_evidence"
. " (feature_id, feat_min, feat_max, program, ev_type, ev_accession)"
. " VALUES(?, '', '', 'TATfind1.4a', 'SP', 'TAT')";
my $sth = $dbh->prepare($ev_i);
while (my $line = <$in>) {
next if ($line =~ /^\#/);
chomp $line;
my $short = 0;
if ($line =~ /ExpAA/) {
$short = 1;
}
my @f = split/\t/, $line;
# if (@f != 6) { die "Input file is not in TMHMM2.0 summary format\n"; }
my $acc = $f[0];
my $fid;
if ($acc =~ /^\d+$/) {
$fid = $acc;
} else {
$fid = get_feature_id_by_accession($dbh, $acc);
if (!$fid) {
print "WARNING: Couldn't get a feature_id from accession '$acc'. Skipping.\n";
next;
}
}
$dsth->execute($fid);
if ($short) {
my (undef, $len) = split/\=/, $f[1];
my (undef, $string) = split/\=/, $f[5];
while ($string =~ /(\d+)\-(\d+)/g) {
$sth->execute($fid, $1, $2);
}
} else {
# this is for long form output.
if (!defined($f[9])) {
#my @acc = split(/\|/, $acc);
# my $ev_acc = $f[0];
# my $min = $f[3];
# my $max = $f[4];
$sth->execute($fid);
}
}
}