Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Graphics
Graphic plot for artificial with database support

Graphics - Graphic plot for artificial with database support


NAME

Graphics - Graphic plot for artificial with database support


SYNOPSIS


    use strict;

    use Chemistry::SQL;

    use Chemistry::Artificial::Graphics;

    

    my $dbname = $ARGV[0];

    my $chaname = $ARGV[1];

    my $file = $ARGV[2];

    my $mode = $ARGV[3];

    

    if (scalar(@ARGV)!=4)

    {  print "Error in parameter number \n";

       print "perl chaplot.pl DB_NAME 

       CHA_NAME FILE_NAME MODE (svg | svg_static | text)\n";

       exit;

    }

    my $db1 = Chemistry::SQL->new(db_host=>"127.0.0.1",db_user=>"root",db_port=>"3306",sb_pwd=>"",db_name=>"$dbname",db_driver=>"mysql");

    $db1->connect_db;

    my $pcha = Chemistry::Artificial::Graphics->new(db => $db1, width=> "800",height=>"600",radius=> "10",distanceh=>"200",file=> $file,

    mode=> $mode);

    $pcha->ch_plot("$chaname");



=head1 DESCRIPTION

This package, along with Chemistry::SQL, includes all the necessary to generate graphics of the artificial chemistry in database.

Graphics Attributes


        * db: Working database.

        * width: Width screen value.

        * height: Height screen value.

        * def_fathercolor: Components that have >=1 childs.

        * def_childcolor: Components that don't have any child.

        * def_font: Font name.

        * def_font_size: Font size in the graphic.

        * def_font_color: Font color in the graphic.

        * radius: Radius for each component (radius of the circle).

        * inix: This will be the first position X position.

        * iniy: This will be the first position Y position.

        * distanceh: Horitzontal distance from one component to each other.

        * id: First id component.

        * file: File name where we are going to save the graphic.

        * mode: Working mode (svg|svg_static|text).


METHODS

Implements the methods.

Graphics->new(SQL_OBJECT, width, height, radius, distanceh, distancev, file, mode)
Creates a new object graphics to plot artificial chemistry.

* Example:


        my $pcha = Graphics->new(db => $db1,width=>"1400",height=>"1024",

        radius=>"10",distanceh=>"10",file=>"$file",

        mode=>"svg");

File functions

These functions are oriented to the generic I/O graphic file, and they are:

$graph->ini_file()
This function only creates the file where the graphic is going to be writed.

This function uses $self-{file>} parameter to set the name of the output file.

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

Component functions

These are auxiliar functions used to work with components:

$graph->smiles_string(component)
Returns SMILES format string of the component.

It is often used to get the SMILES string of the components in the function.


        $self->smiles_string($component);

Graphic plot

These functions are used in the plot process.

Common functions (not depending of the graphic type)

These functions are used to write SVG files, and they are:

$graph->write_style()
Here we define the style of the objects in the graph, for example: path (the lines), circle(the components), text (text properties)...

Here we defined the arrows directions too.

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

$graph->write_circle(x, y, id, color, smilestring, child, formula, reaction, reaction_type, atommap, elembefore)
This function writes a component in the graph.

        The properties:

        * id: This is an unique id for one component in the graph.

        * cx: X position.

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

$graph->write_text(text, x, y, id)
Function used to write a text line in the SVG.

        The properties:

        * x: X position to start the text.

        * y: Y positicion to start the text.

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

$graph->write_line(id,inix,iniy,xend,yend,direction)
Function used to write a line in the SVG file. This is a path component of the SVG.

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

$graph->write_title_eng()
Title in english language.



This function should be called from the inside of the module, not being 

recomended to call it from an external applicattion.

$graph->write_top()
SVG needs a header to be recongnized by browsers. This function puts the head in the SVG file.



This function should be called from the inside of the module, not being 

recomended to call it from an external applicattion.

Functions depending of graphic type (dynamic)

These functions depend on the graphic type. The dynamic graphic need some diferent functions to work correctly.

$graph->insert_function()
This function writes the functions and header necessary for the SVG interaction.

ShowContentsAndRelatives(evt): This function tales the id of the current component and increments by one, the result is going to be the group that is associated at this component.

Each ball has a unique id, the child of one ball is in a group id+1.

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

$graph->open_group(group)
Opens a new group in the SVG file.

Here if the group is the number 1 (root elements) then it is visible, else it is writted but is not visible.

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

$graph->close_group()
Closes a group in the SVG file.

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

$graph->write_bottom()
Writes the dynamic bottom (last lines) in the SVG file.

Here it is defined the option value (properties mode versus expand mode).

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

$graph->recursive_ch()
Plots a dinamic SVG grahic. This is the most sofisticated graphic that this module can produce.

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

Functions that depends of the graphic type (static)

Static graphics needs some diferent functions in the SVG file

$graph->write_bottom_static()
Writes the bottom (last lines) in the SVG static file.

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

$graph->write_circle_static(x, y, id, color, smilestring, child, formula, reaction, reaction_type, atommap, elembefore)
This function writes a component in the graph.

        The properties:

        * id: This is an unique id for one component in the graph.

        * cx: X position.

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

$graph->recursive_ch_static(x, y, root)
Represents a SVG static file with the solution in the solution graphic table.

How does it works:

Get all the root elements and then, get the childs for each one.

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

Functions in text mode

Text mode graphics needs diferent functions to write the file.

$graph->write_top_text()
This function writes the title in the text version of the graphic

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

$graph->recursive_chtxt()
This function writes a txt file with the solution graph table. This is the simplest way to see a graphic structure of cha

This function should be called from the inside of the module, not being recomended to call it from an external applicattion.

Plotting functions

These functions are used to plot and prepare the table before graphic drawing

Preparing and drawing artificial chemistry

These functions are used to work with specific artificial chemistry

$graph->ch_plot()
Using Chemistry::SQL module store in the sgraph table the necessary data to draw the graphic of artificial chemistry (designed by name).

After this, plot using the apropiate function, it depends of the selected mode.

Example (Dynamic SVG):


        my $cha5 = Graphics::new($db1,"1400","1024","10","10","25",

        "cha.svg","svg");

        $cha5->ch_plot("$chaname");

Example (Static SVG):


        my $cha6 = Graphics::new($db1,"1400","1024","10","10","25",

        "cha.svg","svg_static");

        $cha6->ch_plot("$chaname");

Example (Text):


        my $cha7 = Graphics::new($db1,"1400","1024","10","10","25",

        "cha.txt","text");

        $cha7->ch_plot("$chaname");

$graph->ch_plot_levels(qname, startlevel,endlevel)
Using Chemistry::SQL module store in the sgraph table the necessary data to draw the graphic of artificial chemistry (designed by name) from startlevel to endlevel.

After this, plot using the apropiate function, it depends of the selected mode.

Example (Dynamic SVG):


        my $cha = Graphics::new($db1,"1400","1024","10","10","25",

        "chalevel.svg","svg");

        $cha->ch_plot_levels("$chaname",2,3);

Example (Static SVG):


        my $cha = Graphics::new($db1,"1400","1024","10","10","25",

        "chalevels.svg","svg_static");

        $cha->ch_plot_levels("$chaname",2,3);

Example (Text):


        my $cha = Graphics::new($db1,"1400","1024","10","10","25",

        "chalevel.txt","text");

        $cha->ch_plot_levels("$chaname",2,3);

Preparing and plotting independent results

These functions are used to work with especific results (components), and they are:

$graph->ch_plot_fsc(Reference_array_start_components)
Using Chemistry::SQL module store in the sgraph table the necessary data to draw the possibilities from the start components in the Reference_Array

After this, draw using the apropiate function, it depends of the selected mode.

Example (Dynamic SVG):


        my $cha = Graphics::new($db1,"1400","1024","10","10","25",

        "gsg_fsc.svg","svg");

        my @root;

        push @root,Chemistry::Mol->

        parse("OC1C(C(C(CO)OC1OC1(CO)C(C(C(CO)O1)O)O)O)O", format => 'smiles');

        push @root,Chemistry::Mol->

        parse("OC1C(C(C(CO)OC1OC)O)O", format => 'smiles');

        push @root,Chemistry::Mol->

        parse("OC1=CC=CC=C1C1=CC=CC=C1", format => 'smiles');

        push @root,Chemistry::

        Mol->parse("[O-]C1=CC=CC=C1C1=CC=CC=C1.[Na+]", format => 'smiles');

        $cha->ch_plot_fsc(\@root);

Example (Static SVG):


        my $cha = Graphics::new($db1,"1400","1024","10","10","25",

        "gsg_fscs.svg","svg_static");

        my @root;

        push @root,Chemistry::Mol->

        parse("OC1C(C(C(CO)OC1OC1(CO)C(C(C(CO)O1)O)O)O)O", format => 'smiles');

        push @root,Chemistry::Mol->

        parse("OC1C(C(C(CO)OC1OC)O)O", format => 'smiles');

        push @root,Chemistry::Mol->

        parse("OC1=CC=CC=C1C1=CC=CC=C1", format => 'smiles');

        push @root,Chemistry::Mol->

        parse("[O-]C1=CC=CC=C1C1=CC=CC=C1.[Na+]", format => 'smiles');

        $cha->ch_plot_fsc(\@root);

Example (Text):


        my $cha = Graphics::new($db1,"1400","1024","10","10","25",

        "gsg_fsc.txt","text");

        my @root;

        push @root,Chemistry::Mol->

        parse("OC1C(C(C(CO)OC1OC1(CO)C(C(C(CO)O1)O)O)O)O", format => 'smiles');

        push @root,Chemistry::Mol->

        parse("OC1C(C(C(CO)OC1OC)O)O", format => 'smiles');

        push @root,Chemistry::Mol->

        parse("OC1=CC=CC=C1C1=CC=CC=C1", format => 'smiles');

        push @root,Chemistry::Mol->

        parse("[O-]C1=CC=CC=C1C1=CC=CC=C1.[Na+]", format => 'smiles');

        $cha->ch_plot_fsc(\@root);

$graph->ch_plot_fec(qname, Reference_array_end_components)
Using Chemistry::SQL module store in the sgraph table the necessary data to draw from the end components in the Reference_Array

After this, draw using the apropiate function, it depends of the selected mode.

Example (Dynamic SVG):


        my $cha = Graphics::new($db1,"1400","1024","10","10","25",

        "gsg_fec.svg","svg");

        my @root;

        push @root,Chemistry::Mol->parse("OC12C3C=CC4C5C6C=CC1(C35)C462", 

        format => 'smiles');

        push @root,Chemistry::Mol->parse("OC1C2C=CC3C=1C13C2C2C3C2C31", 

        format => 'smiles');

        $cha->ch_plot_fec(\@root);

Example (Static SVG):


        my $cha = Graphics::new($db1,"1400","1024","10","10","25",

        "gsg_fecs.svg","svg_static");

        my @root;

        push @root,Chemistry::Mol->parse("OC12C3C=CC4C5C6C=CC1(C35)C462",

        format => 'smiles');

        push @root,Chemistry::Mol->parse("OC1C2C=CC3C=1C13C2C2C3C2C31",

        format => 'smiles');

        $cha->ch_plot_fec(\@root);

Example (Text):


        my $cha = Graphics::new($db1,"1400","1024","10","10","25",

        "gsg_fec.txt","text");

        my @root;

        push @root,Chemistry::Mol->parse("OC12C3C=CC4C5C6C=CC1(C35)C462",

        format => 'smiles');

        push @root,Chemistry::Mol->parse("OC1C2C=CC3C=1C13C2C2C3C2C31",

        format => 'smiles');

        $cha->ch_plot_fec(\@root);


VERSION

0.01


SEE ALSO

the Chemistry::Artificial::SQL manpage,the Chemistry::SQL manpage

The PerlMol website http://www.perlmol.org/


AUTHOR

Bernat Requesens <brequesens@gmail.com>.


COPYRIGHT

This program is free software; it can be redistributed and/or modified under the same terms as Perl itself.

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy