Bio-Palantir

 view release on metacpan or  search on metacpan

bin/export_bgc_sql_tables.pl  view on Meta::CPAN

#!/usr/bin/env perl
# PODNAME: export_bgc_sql_tables.pl
# ABSTRACT: Exports SQL tables of BGC data (Palantir and antiSMASH annotations)
# CONTRIBUTOR: Denis BAURAIN <denis.baurain@uliege.be>

use Modern::Perl '2011';
use autodie;
use Smart::Comments;

use Carp;
use Const::Fast;
use Data::UUID;
use DBI;
use GD::Simple;
use Getopt::Euclid qw(:vars);
use File::Basename qw(fileparse);
use File::ShareDir qw(dist_dir);
use File::Temp;
use Path::Class qw(dir file);
use POSIX;

use Bio::Palantir::Parser;
use Bio::MUST::Core;

use aliased 'Bio::FastParsers::Hmmer::DomTable';
use aliased 'Bio::MUST::Core::Taxonomy';
use aliased 'Bio::Palantir::Parser';
use aliased 'Bio::Palantir::Refiner::ClusterPlus';


const my $DATA_PATH => dist_dir('Bio-Palantir') . '/';

unless (@ARGV_infiles || $ARGV_file_table) {
    croak 'Error: use of --xml-reports or --file-table is needed';
}

if (@ARGV_types) {
    Parser->is_cluster_type_ok(@ARGV_types);
}

# SQLite database creation

# delete the previous database
if ($ARGV_new_db) {
    my $cmd = 'rm -rf ' . $ARGV_db_name . ' ' . $ARGV_db_name . '_tables/';
    system $cmd;
}

# connect to SQLite database
my $dsn = "DBI:SQLite:$ARGV_db_name";
my %attr = (PrintError=>0, RaiseError=>1);
 
my $dbh = DBI->connect($dsn,'', '', \%attr);

my @stmts = <<'EOT' =~ m/(CREATE .*? \) \;)/xmsg;
CREATE TABLE IF NOT EXISTS Clusters (
id              TEXT       NOT NULL    PRIMARY KEY,
rank            INTEGER    NOT NULL,
type            TEXT       NOT NULL,
size            INTEGER    NOT NULL,
coordinates     TEXT       NOT NULL,
begin           INTEGER    NOT NULL,
end             INTEGER    NOT NULL,
dna_coordinates INTEGER    NOT NULL,
dna_begin       INTEGER    NOT NULL,
dna_end         INTEGER    NOT NULL,



( run in 0.894 second using v1.01-cache-2.11-cpan-b16cb0d3907 )