Chemistry-Artificial-SQL
view release on metacpan or search on metacpan
lib/Chemistry/Artificial/SQL.pm view on Meta::CPAN
package Chemistry::Artificial::SQL;
$VERSION = '0.01';
# $Id: Chemistry::Artifical::SQL.pm, v 0.01 2005/05/31 12:14:17 brequesens Exp $
=head1 NAME
ArtificialSQL - Artificial chemistry with database support module
=head1 SYNOPSIS
use strict;
use Chemistry::SQL;
use Chemistry::Artificial::SQL;
# Execution: perl gcha.pl DBNAME CHANAME SIZE_VALUE LEVELS
# NUMBER_OF_COMPONENTS_TO_PROCESS
my $dbname = $ARGV[0];
my $chaname = $ARGV[1];
my $size = $ARGV[2];
my $levels = $ARGV[3];
my $compnumber = $ARGV[4];
if (scalar(@ARGV)!=5)
{ print "Incorrect parameter number \n";
print "perl gcha.pl DBNAME CHANAME SIZE_VALUE LEVELS
NUMBER_OF_COMPONENTS_TO_PROCESS \n";
exit;
}
my $db1 = Chemistry::SQL->new(db_host=>"127.0.0.1",db_user=>"root",db_port=>"3306",db_pwd=>"",
db_name=>"$dbname",db_driver=>"mysql");
$db1->connect_db;
my $cha = Chemistry::Artificial::SQL->new(db_name=>$db1);
$cha->new_ch ("$chaname","TEST DESCRIPTION");
#Inserting Reactions
#In this example file we're working with the reaction C=CC=C.C=C>>C1=CCCCC1
my $string_react = $db1->string_react(1);
my $qr=$cha->create_reaction($string_react,'smiles');
$cha->art_insert_react($qr,"$chaname");
my $string_react = $db1->string_react(2);
my $qr=$cha->create_reaction($string_react,'smiles');
$cha->art_insert_react($qr,"$chaname");
# Inserting Components
my $list = $db1->recover_comp("","");
my $component;
my $formula;
my $smilesform;
for (my $index=0; $index<$compnumber; $index++)
{ @$list[$index]->print(format => 'smiles', unique => 1);
$cha->art_insert_comp(@$list[$index],"$chaname");
}
print ("GENERATING $chaname IN $dbname DATABASE\n");
$cha->ch_artificial_table($levels,"$chaname",$size);
=head1 DESCRIPTION
This package provides the necessary functions to work with the generation of
artificial chemistry. The methods implemented in this package, are all
oriented to generate artificial chemistry. There is a lot of interaction
with the package Chemistry::SQL, but Chemistry::Artficial::SQL doesnt
implement any Chemistry::SQL function.
=cut
=head2 Chemistry::Artificial::SQL Attributes
There is only one attribute necessary to work with this module.
* db: This attribute describes the SQL object to use in the process.
=cut
use strict;
use Chemistry::Reaction;
use Chemistry::SQL;
=head1 METHODS
Methods of Chemistry::Artificial::SQL object.
=over 4
=item Chemistry::Artificial::SQL->new(SQL_OBJECT)
Creates a new I<Chemistry::Articial::SQL> object with the especified attributes.
Example:
my $db1 = Chemistry::SQL->new(db_host=>"127.0.0.1",db_user=>"root",
db_port=>"3306",db_pwd=>"",db_name=>"TESTDB",db_driver=>"mysql");
$db1->connect_db;
my $cha = Chemistry::Artificial::SQL->new(db_name => $db1);
$cha->new_ch ("CHATEST","TEST DESCRIPTION");
=cut
sub new {
my $class = shift;
my %args = @_;
my $self =
bless
{
db_name=>"",
}, ref $class || $class;
( run in 0.852 second using v1.01-cache-2.11-cpan-39bf76dae61 )