[Bio] / Babel / bin / load_md5rna2db.pl Repository:
ViewVC logotype

Diff of /Babel/bin/load_md5rna2db.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4, Fri Jul 8 19:39:49 2011 UTC revision 1.5, Wed Jul 20 16:41:16 2011 UTC
# Line 8  Line 8 
8  use DBI;  use DBI;
9  use Getopt::Long;  use Getopt::Long;
10    
 use FIG_Config;  
   
11  my $verbose   = 0;  my $verbose   = 0;
12  my $datafile  = '';  my $datafile  = '';
13  my $taxfile   = '';  my $taxfile   = '';
14  my $index     = 0;  my $index     = 0;
15  my $test      = 0;  my $test      = 0;
16  my $tmpdir    = "/tmp";  my $tmpdir    = "/tmp";
17  my $dbname    = $FIG_Config::babel_db;  my $dbname    = "mgrast_ach_prod";
18  my $dbhost    = $FIG_Config::babel_dbhost;  my $dbhost    = "kursk-3.mcs.anl.gov";
19  my $dbuser    = $FIG_Config::babel_dbuser;  my $dbuser    = "mgrastprod";
20  my $usage     = qq(  my $usage     = qq(
21  DESCRIPTION: ($0)  DESCRIPTION: ($0)
22  load the ACH database tables with the inputted file data. Must be postgresql db.  load the ACH database tables with the inputted file data. Must be postgresql db.
# Line 96  Line 94 
94    my ($md5, $id, $func, $org, $source) = split(/\t/, $line);    my ($md5, $id, $func, $org, $source) = split(/\t/, $line);
95    unless ($md5 && $id && $source && exists($taxa->{$id})) { next; }    unless ($md5 && $id && $source && exists($taxa->{$id})) { next; }
96    
97    $funcID = ($func && exists($func_ids->{$func})) ? $func_ids->{$func} : '\\N';    $funcID = ($func && exists($func_ids->{$func})) ? $func_ids->{$func} : '';
98    $srcID  = $src_ids->{$source};    $srcID  = $src_ids->{$source};
99    $orgID  = '';    $orgID  = '';
100    $rankID = $taxa->{$id}[0];    $rankID = $taxa->{$id}[0];
# Line 113  Line 111 
111      }      }
112    }    }
113    
114    if ($md5 && $id && $funcID && $orgID && $srcID && $rankID) {    if ($md5 && $id && $orgID && $srcID && $rankID) {
115      print DTMP join("\t", ($md5, $id, $funcID, $orgID, $rankID, $srcID)) . "\n";      print DTMP join("\t", ($md5, $id, $funcID, $orgID, $rankID, $srcID)) . "\n";
116    }    }
117    
# Line 176  Line 174 
174  sub psql_copy {  sub psql_copy {
175    my ($cmd, $table, $cols, $file, $v) = @_;    my ($cmd, $table, $cols, $file, $v) = @_;
176    
177    my $psql = qq($cmd -c "COPY $table ($cols) FROM '$file';");    my $psql = qq($cmd -c "COPY $table ($cols) FROM STDIN WITH NULL AS '';" < $file);
178    unless (-s $file) {    unless (-s $file) {
179      print STDERR "No data in '$file' to COPY to '$table', skipping\n"; return;      print STDERR "No data in '$file' to COPY to '$table', skipping\n"; return;
180    }    }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3