Result:
found more than 658 distributions - search limited to the first 2001 files matching your query ( run in 0.502 )


Catalyst-View-XLSX

 view release on metacpan or  search on metacpan

lib/Catalyst/View/XLSX.pm  view on Meta::CPAN

        filename => 'ExcelFile.xlsx'
    };

    #row,col -> represents the position on the Excel sheet 
    #data    -> represents the content of the field
    #value   -> (OPTIONAL) it will hold the actual value when data has formula
    #format  -> (OPTIONAL) format of the cell, supports the following properties  
 
            #font => 'Times New Roman',
            #size => '15',
            #color => 'Black',

 view all matches for this distribution


CatalystX-Crudite

 view release on metacpan or  search on metacpan

lib/CatalystX/Crudite/Util/Random.pm  view on Meta::CPAN

formidable
forming
Formosa
Formosan
forms
formula
formulae
formulas
formulate
formulated
formulates
formulating
formulation
formulations
formulator
formulators
fornication
Forrest
forsake
forsaken
forsakes

lib/CatalystX/Crudite/Util/Random.pm  view on Meta::CPAN

reformed
reformer
reformers
reforming
reforms
reformulate
reformulated
reformulates
reformulating
reformulation
refract
refracted
refraction
refractory
refragment

 view all matches for this distribution


Catmandu-XSD

 view release on metacpan or  search on metacpan

t/demo/mods/test.xml  view on Meta::CPAN

</name>
<language>
    <languageTerm authority="iso639-2b" type="code">eng</languageTerm>
</language>
<abstract>Wastewater treatment plants (WWTP) are needed to treat municipal wastewater to reduce the impact of pollutants on the environment and the ambient nature. The discharge of treated wastewater and the disposal of sludge from treatment plants t...
The increased importance of wastewater treatment has led to development of mathematical models for optimization and design of wastewater treatment plants. WWTP modelling entails the modelling of the biological reactions (biokinetics) and underlying f...
In this thesis, it is hypothesised and confirmed that the bioreactors are not at all completely mixed and, hence, current models wrongfully calibrate the kinetic parameters by correcting for the errors induced by the over-simplified modelling of mixi...
The thesis comprises of four parts. The first part provides the detailed account of CFD (computational fluid dynamics) modelling of WWTPs. Second part is about integration of CFD hydrodynamic models with the biokinetic models to evaluate the impact o...
In the first part, detailed CFD hydrodynamic modelling of a bioreactor of Eindhoven WWTP is performed. The impact of reactor configuration and process conditions on gas dispersion is observed. Potential regions of poor mixing are identified. The diff...
In the second part, the CFD hydrodynamic model of Eindhoven WWTP is extended by integrating it with bio-kinetic models, firstly with ASM1 and secondly with ASMG1. The impact of local mixing conditions on the dissolved oxygen (DO) and ammonium concent...
In the third part, the compartmental modelling (CM) was setup based on the DO concentrations using CFD-biokinetic model. A novel idea of cumulative species distribution (CSDs) to quantify the variations is introduced here as well. The CSDs serve as a...

 view all matches for this distribution


Cellular-Automata-Wolfram

 view release on metacpan or  search on metacpan

Wolfram.pm  view on Meta::CPAN

[111,110,101,100,011,010,001,000]
  |   |   |   |   |   |   |   |
  0   1   1   0   1   1   1   0

This number 01101110 can be treated as a decimal number expressed as
110, as the result of the following standard binary to decimal formula.
0x128+1x64+1x32+0x16+1x8+1x4+1x2+0x1 = 110.

This number 110 can be used to define the entire rules function that is 
needed
to determine the next generation.

Wolfram.pm  view on Meta::CPAN

they run from 0 to 255 decimal, each number describes a different rules 
function and every possible rules function for an array limited to 0 and 1 

and whose input is three values drawn from that array.  The three values 
are
chosen in the formula descibed above.

The choice of i-1, the left adjacent cell, and, i+1, the right adjacent 
cell, as the number of left and right ajacent cells to consider for the 
next 
generation can be defined as radius R.  The number of values each cell can 

 view all matches for this distribution


Chart-EPS_graph

 view release on metacpan or  search on metacpan

lib/Chart/EPS_graph/PS.pm  view on Meta::CPAN

		} for
		stroke
	grestore
} bind def

/formula {
	-194.77 250.75 2 index mul add
	.13976 2 index 2 exp mul sub
	2.2082e-2 3 xpnt sub
	1.5757e-4 4 xpnt add
	3.2312e-7 5 xpnt sub
} def

/do_curve {
	/x-fin 200 def /y.line { formula } def
	plot_pairs stroke
} def

/graph {
	font_name findfont font_size scalefont setfont

 view all matches for this distribution


Chart-GGPlot

 view release on metacpan or  search on metacpan

lib/Chart/GGPlot/Scale/Functions.pm  view on Meta::CPAN

               :$sec_axis = undef,
               %rest,
      )
    {
        if ( defined $sec_axis ) {
            if ( is_formula($sec_axis) ) {
                $sec_axis = sec_axis($sec_axis);
            }
            if ( $sec_axis->$_isa('Chart::GGPlot::AxisSecondary') ) {
                die(
"Secondary axes must be specified using a Chart::GGPlot::AxisSecondary object"

 view all matches for this distribution


Chart-Plotly

 view release on metacpan or  search on metacpan

share/plotly.js/plotly.min.js  view on Meta::CPAN

 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 */
"use strict";var e=t("base64-js"),n=t("ieee754");r.Buffer=a,r.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},r.INSPECT_MAX_BYTES=50;function i(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=ne...
/*! Native Promise Only
    v0.8.1 (c) Kyle Simpson
    MIT License: http://getify.mit-license.org
*/
!function(t,r,n){r[t]=r[t]||n(),void 0!==e&&e.exports&&(e.exports=r[t])}("Promise",void 0!==t?t:this,(function(){"use strict";var t,e,n,i=Object.prototype.toString,a=void 0!==r?function(t){return r(t)}:setTimeout;try{Object.defineProperty({},"x",{}),...

 view all matches for this distribution


Chemistry-Artificial-Graphics

 view release on metacpan or  search on metacpan

lib/Chemistry/Artificial/Graphics.pm  view on Meta::CPAN

</defs>'."\n";
print svgfile $function2;
close (svgfile);
}

=item $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:

lib/Chemistry/Artificial/Graphics.pm  view on Meta::CPAN

=cut

sub write_circle
{	
my $self = shift;
my ($x,$y,$id,$color,$smilestring,$child,$formula,$reaction,$reaction_type,
$atommap,$elembefore)=@_;
open (svgfile,">>$self->{file}") or die("Couldn't open File\n");
print svgfile '<circle id="c'. $id .'" onclick="showContentAndRelatives(evt)" 
cx="'. $x. '" cy="' .$y. '" r="20" stroke="'.$color.'" 
smilestring="'. $smilestring .'" child="'. $child.'" formula="'. $formula.'" 
reaction="'. $reaction.'" reactiontype="'. 
$reaction_type.'" atommap="'. $atommap.'" elembefore="'. $elembefore.'"  
style="fill:url(#mygradient1)" stroke-with="1"/>' ."\n";
close (svgfile);
}

lib/Chemistry/Artificial/Graphics.pm  view on Meta::CPAN

   childtext.setAttribute("id","ch"+level);
   childtext.setAttribute("style","text-anchor:right;font-size:12;font-family:Arial;fill:blue");
   childstring = circle.getAttribute("child");	
   childtext.appendChild(document.createTextNode("Child Number: "+childstring));
   group.appendChild(childtext);
   //Create a text formula
   y = y+10;
   var ftext=document.createElementNS(svgNS,"text");
   ftext.setAttribute("x",x);ftext.setAttribute("y",y);
   ftext.setAttribute("id","f"+level);
   ftext.setAttribute("style","text-anchor:right;font-size:12;font-family:Arial;fill:blue");
   formulastring = circle.getAttribute("formula");	
   ftext.appendChild(document.createTextNode("Formula: "+formulastring));
   group.appendChild(ftext);
   //Create a text reaction
   y = y+10;
   var rtext=document.createElementNS(svgNS,"text");
   rtext.setAttribute("x",x);rtext.setAttribute("y",y);

lib/Chemistry/Artificial/Graphics.pm  view on Meta::CPAN

open (svgfile,">>$self->{file}") or die("Couldn't open File\n");
print svgfile "</svg>\n";
close (svgfile);
}

=item $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:

lib/Chemistry/Artificial/Graphics.pm  view on Meta::CPAN

=cut

sub write_circle_static
{	
my $self = shift;
my ($x,$y,$id,$color,$smilestring,$child,$formula,$reaction,$reaction_type,
$atommap,$elembefore)=@_;
open (svgfile,">>$self->{file}") or die("Couldn't open File\n");
print svgfile '<circle id="c'. $id .'" cx="'. $x. '" cy="' .$y. '" r="20" 
stroke="'.$color.'" smilestring="'. $smilestring .'" child="'. $child.'"
 formula="'. $formula.'" reaction="'. $reaction.'" reactiontype="'. 
$reaction_type.'" atommap="'. $atommap.'" elembefore="'. $elembefore.'"  
style="fill:url(#mygradient1)" stroke-with="1"/>' ."\n";
close (svgfile);
}

 view all matches for this distribution


Chemistry-Artificial-SQL

 view release on metacpan or  search on metacpan

lib/Chemistry/Artificial/SQL.pm  view on Meta::CPAN

    # 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");

 view all matches for this distribution


Chemistry-Bond-Find

 view release on metacpan or  search on metacpan

Find.pm  view on Meta::CPAN

}

# used by both find_bonds variants to figure out the maximum cutoff
sub guess_margin {
    my ($mol, $opts) = @_;
    my $formula = $mol->formula_hash;
    my $max = 0;
    for my $elem (keys %$formula) {
        $max = $Covalent_Radius{$elem} if $Covalent_Radius{$elem} > $max;
    }
    $max *= 2 * $opts->{tolerance};
    #printf "MARGIN guessed at (%.2f)\n", $max;
    $max;

Find.pm  view on Meta::CPAN


A bond order assignment algorithm based on Baber, J. C.; Hodgkin, E. E.
J. Chem. Inf. Comp. Sci. 1992, 32, 401-406 (with some interpretation).

This algorithm uses the 3D coordinates along with various cutoffs and
confidence formulas to guess the bond orders. It then tries to resolve
conflicts by looping through the atoms (but is not recursive or backtracking).
It does not require explicit hydrogens (although it's better when they are
available) because it was designed for use with real crystallographic data
which often doesn't have hydrogen atoms.

Find.pm  view on Meta::CPAN

############
# Bond order assignment algorithm based on Baber, J. C.; Hodgkin, E. E.
# J. Chem. Inf. Comp. Sci. 1992, 32, 401-406

# this algorithm uses the 3D coordinates along with various cutoffs and
# confidence formulas to assign the bond orders. It does not require all
# explicit hydrogens (although it's better when they are available) because
# it's design for use with real crystallographic data which often doesn't 
# have hydrogen.

my %Valences = (

 view all matches for this distribution


Chemistry-File-QChemOut

 view release on metacpan or  search on metacpan

t/qchemout.t  view on Meta::CPAN


my $mol = Chemistry::Mol->read("ethane.out", format => 'qchemout');

isa_ok($mol => 'Chemistry::Mol');
is ($mol->atoms * 1, 8, 'got 8 atoms');
is ($mol->formula, 'C2H6', 'formula is C2H6');
ok (abs($mol->atoms(1)->coords->x - -0.771166) < 0.00001, 'x1');
ok (abs($mol->atoms(8)->coords->z -  0.867544) < 0.00001, 'z8');

my @mols = Chemistry::Mol->read("ethane.out", format => 'qchemout', all => 1);

 view all matches for this distribution


Chemistry-File-SLN

 view release on metacpan or  search on metacpan

lib/Chemistry/File/SLN.pm  view on Meta::CPAN


sub read_coords {
    my ($self, $mol, $coords_str) = @_;
    $coords_str =~ s/[()]//g;
    my (@coords) = split /,/, $coords_str;
    my $fh = $mol->formula_hash;
    my $n = sum(values %$fh);
    my $sprout = (@coords == 3*$n);
    for my $atom ($mol->atoms) {
        $atom->coords(splice @coords, 0, 3);
        if ($sprout) {

 view all matches for this distribution


Chemistry-File-SMILES

 view release on metacpan or  search on metacpan

write.pl  view on Meta::CPAN


#my $mol = Chemistry::Mol->parse($ARGV[0] || 'CCC', format => 'smiles',
    #kekulize => $kekulize);
my $mol = Chemistry::Mol->read($ARGV[0] || die "pls give a .mol\n");

printf "%s (%s)\n", $mol->name, $mol->formula;
$_->printf("%s H%h V%v\n") for $mol->atoms;

my $smiles = $mol->print(format => 'smiles', 
    unique => $unique, aromatic => $aromatic);

 view all matches for this distribution


Chemistry-FormulaPattern

 view release on metacpan or  search on metacpan

lib/Chemistry/File/FormulaPattern.pm  view on Meta::CPAN

    # somehow get a bunch of molecules...
    use Chemistry::File::SDF;
    my @mols = Chemistry::Mol->read("file.sdf");

    # we want molecules with six carbons and 8 or more hydrogens
    my $patt = Chemistry::Pattern->new("C6H8-", format => "formula_pattern");

    for my $mol (@mols) {
        if ($patt->match($mol)) {
            print $mol->name, " has a nice formula!\n";
        }
    }

    # a concise way of selecting molecules with grep
    my @matches = grep { $patt->match($mol) } @mols;

lib/Chemistry/File/FormulaPattern.pm  view on Meta::CPAN

Chemistry::Mol I/O interface. This allows Formula patterns to be used
interchangeably with other pattern languages such as SMARTS in the context of
programs such as L<mok>. All of the real work is done by
L<Chemistry::FormulaPattern>.

This module register the 'formula_pattern' format with L<Chemistry::Mol>.

=cut

use strict;
use warnings;
use base "Chemistry::File";
use Chemistry::FormulaPattern;

Chemistry::Mol->register_format(formula_pattern => __PACKAGE__);

sub parse_string {
    my ($self, $s, %opts) = @_;
    my $patt = Chemistry::FormulaPattern->new($s);
    #$patt->options(%opts);

 view all matches for this distribution


Chemistry-Harmonia

 view release on metacpan or  search on metacpan

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

			parse_chem_mix
			prepare_mix
			oxidation_state
			redox_test
			class_cir_brutto
			good_formula
			brutto_formula
			stoichiometry
			ttc_reaction
			) ],
		    'redox' => [ qw(
			parse_chem_mix

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

			) ],
		    'equation' => [ qw(
			parse_chem_mix
			prepare_mix
			class_cir_brutto
			good_formula
			brutto_formula
			stoichiometry
			ttc_reaction
			) ],
);

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

our $VERSION = '0.118';

use base qw(Exporter);


# Returns array of "good" chemical formulas
sub good_formula{
    my $substance = shift || return;
    my $opts = shift;

    for( $substance ){
	my $m = '(?:1|!|\|)';	# mask

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

		return [ @cf, @a ];
	    }
	    return \@cf;
	}

	# Normalization of oxide-coated formulas (written through '*')
	if(/\*/){
	    my %k;
	    my $l = 1;
	    for my $i (split /\*/){
		if($i =~ /^(\d+)[a-zA-Z]/){	# Integer coefficient

lib/Chemistry/Harmonia.pm  view on Meta::CPAN


	for my $f (split /($m)/, $s){

	    &_in_gf($f, \@i_maU, \@i_maUl, $cf);

	    if( $#{$cf} ){ # For >1 formula
		# To leave the longest fragments
		for( my $i = $#$cf; $i > 0; $i-- ){
		    splice @$cf, $i, 1 if length( $cf->[$i] ) < length( $cf->[0] );
		}
	    }

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

# Calculation common identifier for reaction:
#	Alphabetic CLASS
# and
#	Chemical Interger Reaction (CIR) identifier
# also
#	brutto (gross) formulas of substances
sub class_cir_brutto{
    my( $ce, $coef ) = @_;
    $ce || return;

    my( %elm, %bf, @cir );

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

	for my $s ( @$c ){

	    # stoichiometry coefficient
	    my $k = exists $coef->{$s} ? $coef->{$s} : 1; 

	    my %e = Chemistry::File::Formula->parse_formula( $s );

	    # for brutto
	    $bf{ $s } = join '', map( "$_$e{$_}", sort{ $a cmp $b } keys %e );

	    # for cir

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

	    # For class
	    @elm{ keys %e } = ''; # reaction atoms
	}
    }

    # CLASS, CIR of reaction and hash: formula => brutto of substances
    return [ join( '', sort { $a cmp $b } keys %elm ),
	     ( cksum( join '+', sort { $a cmp $b } @cir ) )[0],
	     \%bf ];
}

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

	# if assume all coefficients positive '+'
	if( $opts->{'norma'} != 1 ){
	    $opts->{'coefficients'}{$_} *= -1 for @{ $ce->[1] };
	}

	my @cir; # for brutto-formula
	while( my($s, $c) = each %{ $opts->{'coefficients'} } ){
	    $c || next;
	    my $ip = $sign * $c > 0 ? 0 : 1;

	    my $ff = abs($c)." $s";

	    my %e = Chemistry::File::Formula->parse_formula( $ff );
	    $cir[$ip]{$ff} = join '', map( "$_$e{$_}", sort{ $a cmp $b} keys %e );
	}
	# Result
	$_ = join(' == ', map{ join ' + ',sort {$_->{$a} cmp $_->{$b}} keys %{$_} } @cir);

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

    my %atoms;		# Atom hash

    for my $i ( @$chem_eq ){
	for my $s ( @$i ){
	    # Atoms of substance
	    my %f = eval{ Chemistry::File::Formula->parse_formula( $s ) } or
croak("'$s' is not substance!");

	    for( keys %f ){
		$tmp_subs{$s}{$_} = $f{$_};
		$atoms{$_}++; # Atom balance

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

    }

    return( \%atoms_substance, scalar(keys %atoms) );
}

# Transform classic into brutto (gross) formula
sub brutto_formula{
    my $s = shift;

    my %e = eval{ Chemistry::File::Formula->parse_formula( $s ) } or
croak("'$s' is not substance!");

    return( join( '', map{ "$_$e{$_}" } sort { $a cmp $b } keys %e ) );
}

lib/Chemistry/Harmonia.pm  view on Meta::CPAN


sub _in_os{
    my $chem_sub = shift;

    # prepare atomic composition of substance
    my %nf = eval{ Chemistry::File::Formula->parse_formula( $chem_sub ) };
    return unless keys %nf;

    # Count of "pure" atoms each element of substance
    $_ = $chem_sub;
    s/\d+//g;	# remove digits
    my %num = Chemistry::File::Formula->parse_formula( $_ );

    # Ions: { element }{ length }{ ion-pattern }[ [ array OSE ] ]
    my $ions = &_read_ions( $chem_sub );

    # Read Pauling electronegativity and OSE:

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

		$_ = $chem_sub;

		# Search ion-group. Remove all atoms of element, except current
		s{ ($m) }{ $1 if $count++ == $j }gex;

		my %f = Chemistry::File::Formula->parse_formula( $_ );
		push @{ $prop->{ $e }{'num'} }, $f{ $e };
	    }
	}
    }

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

	    }

	    my $iter = variations_with_repetition( [ (0..$max_n_ek) ], scalar( keys %ek ) );
ELEMENT_MACRO_1:
	    while (my $p = $iter->next) {
		my $m = $frm; # macro-formula (mask)
		my $i = 0;
		for my $em (sort keys %ek){
		    my $e = $ek{ $em }[0][ $p->[$i++] ];	# element
		    next ELEMENT_MACRO_1 unless defined $e; # pattern have ended

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

=head1 SYNOPSIS

  use Chemistry::Harmonia qw( :all );
  use Data::Dumper;

  for my $formula ('Fe3O4', '[Cr(CO(NH2)2)6]4[Cr(CN)6]3'){
    my $ose = oxidation_state( $formula );
    print Dumper $ose;
  }

Will print something like:

lib/Chemistry/Harmonia.pm  view on Meta::CPAN


Will output:

  K + O2 == 1 K2O + 0 Na2O2 + 2 K2O2 + 3 KO2

'Synthesis' of the good :) chemical formula(s):

  my $abracadabra = 'ggg[crr(cog(nhz2)2)6]4[qcr(cn)5j]3qqq';
  print Dumper good_formula( $abracadabra );

Will output:

  $VAR1 = [
           '[Cr(CO(NH2)2)6]4[Cr(CN)5I]3',
           '[Cr(Co(NH2)2)6]4[Cr(CN)5I]3'
          ];

Calculation CLASS-CIR and brutto (gross) formulas of substances
for reaction. See example:

  my $mix = '2 KMnO4 + 5 H2O2 + 3 H2SO4 --> 1 K2SO4 + 2 MnSO4 + 8 H2O + 5 O2';
  my %cf;
  my $ce = parse_chem_mix( $mix, \%cf );

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

            'H2O2' => 'H2O2',
            'H2O' => 'H2O1'
          }
        ];

Transforms classic chemical formula of substance into the brutto formula:

 print brutto_formula( '[Cr(CO(NH2)2)6]4[Cr(CN)6]3' );

Will output:

  C42Cr7H96N66O24

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

=head1 SUBROUTINES

Chemistry::Harmonia provides these subroutines:

    stoichiometry( $mix_of_substances [, \%facultative_parameters ] )
    oxidation_state( $formula_of_substance )
    parse_chem_mix( $mix_of_substances [, \%coefficients ] )
    good_formula( $abracadabra [, { 'zero2oxi' => 1 } ] )
    brutto_formula( $formula_of_substance )
    prepare_mix( \@reactants_and_products [, \%facultative_parameters ] )
    class_cir_brutto( \@reactants_and_products [, \%coefficients ] )
    ttc_reaction( \@reactants_and_products )


lib/Chemistry/Harmonia.pm  view on Meta::CPAN

Yes, to me it was hard to make it.

Beware use very big C<$mix_of_substances>!


=head2 oxidation_state( $formula_of_substance )

This subroutine returns a hierarchical hash-reference of hash integer 
oxidation state (key 'OS') and hash with the number of atoms for 
each element (key 'num') for the inorganic C<$formula_of_substance>.

Always use the upper case for the first character in the element name
and the lower case for the second character from Periodic Table. Examples: Na,
Ag, Co, Ba, C, O, N, F, etc. Compare: Co - cobalt and CO - carbon monoxide.

For very difficult mysterious formula (usually organic) returns C<undef>.
It will be good if to set, for example, 'Pb3C2O7' and 'Pt2Cl6' as
'{PbCO3}2{PbO}' and '{PtCl2}{PtCl4}'.

If you doesn't know formulas of chemical elements and/or Periodic Table
use subroutine C<good_formula()>.
I insist to do it always anyway :)

Now C<oxidation_state()> is checked for over 6760 unique inorganic substances.


=head2 parse_chem_mix( $mix_of_substances [, \%coefficients ] )

A chemical equation consists of the chemical formulas of the reactants
and products. This subroutine parses C<$mix_of_substances> (usually chemical equation)
to list of the reactants (initial substances) and products
(substances formed in the chemical reaction).
It is the most simple and low-cost way to carry out reaction without
reactants :).

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

together or without one or some '>'. For example: 
=, ==, =>, ==>, ==>>, -, --, ->, -->, ->>> etc.
Spaces round a separator are not essential.
If the separator is not set, last substance of a mix will be a product only.

Each individual substance's chemical formula is separated from others by a plus
sign ('+'), comma (','), semicolon (';') and/or space.
Valid examples:

  print Dumper parse_chem_mix( 'KNO3 + S ; K2SO4 , NO SO2' );

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

  '2Al 1 2 3 4 Ca 5 6 = Al2O3 CaO 9'  to-> [ ['Al', 'Ca56'], ['Al2O3', 'CaO'] ], {'Al' => 2, 'Ca56' => 1234}
  'Al O + 2 = Al2O3'  to-> [ ['Al', 'O'], ['Al2O3'] ], {'Al2O3' => 2}
  'Cr( OH )  3 + NaOH = Na3[ Cr( OH )  6  ]'  to-> [ ['Cr(OH)3', 'NaOH'], ['Na3[Cr(OH)6]'] ]


=head2 good_formula( $abracadabra [, { 'zero2oxi' => 1 } ] )

This subroutine parses C<$abracadabra> to array reference of "good" chemical
formula(s). The "good" formula it does NOT mean chemically correct.
The subroutine C<oxidation_state()> will help with a choice chemically
correct formula.

Algorithm basis is the robust sense and chemical experience.

  'Co'   to->  'Co'
  'Cc'   to->  'CC'
  'co'   to->  'CO', 'Co'
  'CO2'  to->  'CO2'
  'Co2'  to->  'Co2', 'CO2'
  'mo2'  to->  'Mo2'

The good formula(s) there are chemical elements, brackets ()[]{} and
digits only. C<good_formula()> love oxygen.
Fraction will be scaled in the integer.

Fragments A*B, xC*yD are transformed to {A}{B}, {C}x{D}y
(here A, B, C, D - groups of chemical elements, digits and brackets ()[]{};
x, y - digits only). Next examples:

lib/Chemistry/Harmonia.pm  view on Meta::CPAN


  'h20'    to->  'H20'

The forced conversion of zero to oxygen is set by parameter C<'zero2oxi'>:

  my $chem_formulas = good_formula( 'h20', { 'zero2oxi' => 1 } );

Output C<@$chem_formulas>:

  'H20', 'H2O'

If mode of paranoiac is necessary, then transform C<$abracadabra>
to low case as:

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

    lc $abracadabra

Beware use very long C<$abracadabra>!


=head2 brutto_formula( $formula_of_substance )

This subroutine transforms classic chemical C<$formula_of_substance> into the brutto (bruta, gross) formula:

 print brutto_formula( '[Cr(CO(NH2)2)6]4[Cr(CN)6]3' );

Output:

  'C42Cr7H96N66O24'

In brutto formula every the chemical element identified through its chemical symbol.
The atom number of every present chemical element in the classic C<$formula_of_substance> indicated 
by the sequebatur number.


=head2 prepare_mix( \@reactants_and_products [, \%facultative_parameters ] )

lib/Chemistry/Harmonia.pm  view on Meta::CPAN


=head2 class_cir_brutto( \@reactants_and_products [, \%coefficients ] )

This subroutine calculates Unique Common Identifier of Reaction 
C<\@reactants_and_products> with stoichiometry C<\%coefficients>
and brutto (gross) formulas of substances, i.e ref to array:
0th - alphabetic CLASS, 1th - Chemical Integer Reaction Identifier (CIR),
2th - hash brutto substances.

  my $reaction = '1 H2O + 1 CO2 --> 1 H2CO3';
  my %cf;

lib/Chemistry/Harmonia.pm  view on Meta::CPAN

C<parse_chem_mix> and C<prepare_mix>:

  use Chemistry::Harmonia qw( :redox );

the tag C<equation> exports the subroutines C<stoichiometry>,
C<good_formula>, C<brutto_formula>,
C<parse_chem_mix>, C<prepare_mix>, C<class_cir_brutto> and
C<ttc_reaction>:

  use Chemistry::Harmonia qw( :equation );

 view all matches for this distribution


Chemistry-Mok

 view release on metacpan or  search on metacpan

lib/Chemistry/Mok.pm  view on Meta::CPAN

=item C<pattern_format>

The name of the format which will be used for parsing slash-delimited patterns
that don't define an explicit format. Mok versions until 0.16 only used the
'smiles' format, but newer versions can use other formats such as 'smarts',
'midas', 'formula_pattern', and 'sln', if available. The default is 'smarts'.

=back

=cut

 view all matches for this distribution


Chemistry-Mol

 view release on metacpan or  search on metacpan

lib/Chemistry/File/Formula.pm  view on Meta::CPAN

use Carp;
use Text::Balanced qw(extract_bracketed);

=head1 NAME

Chemistry::File::Formula - Molecular formula reader/formatter

=head1 SYNOPSIS

    use Chemistry::File::Formula;

    my $mol = Chemistry::Mol->parse("H2O");
    print $mol->print(format => formula);
    print $mol->formula;    # this is a shorthand for the above 
    print $mol->print(format => formula, 
        formula_format => "%s%d{<sub>%d</sub>});

=cut

Chemistry::Mol->register_format('formula');

=head1 DESCRIPTION

This module converts a molecule object to a string with the formula and back.
It registers the 'formula' format with Chemistry::Mol.  Besides its obvious
use, it is included in the Chemistry::Mol distribution because it is a very
simple example of a Chemistry::File derived I/O module.

=head2 Writing formulas

The format can be specified as a printf-like string with the following control
sequences, which are specified with the formula_format parameter to $mol->print
or $mol->write.

=over

=item %s  symbol

lib/Chemistry/File/Formula.pm  view on Meta::CPAN

=item %% a percent sign

=back

If no format is specified, the default is "%s%d". Some examples follow. Let's
assume that the formula is C2H6O, as it would be formatted by default.

=over

=item C<< %s%D >>

Like the default, but include explicit indices for all atoms. 
The formula would be formatted as "C2H6O1"

=item C<< %s%d{E<lt>subE<gt>%dE<lt>/subE<gt>} >>

HTML format. The output would be
"CE<lt>subE<gt>2E<lt>/subE<gt>HE<lt>subE<gt>6E<lt>/subE<gt>O".

lib/Chemistry/File/Formula.pm  view on Meta::CPAN


=back

=head3 Symbol Sort Order

The elements in the formula are sorted by default in the "Hill order", which
means that:

1) if the formula contains carbon, C goes first, followed by H,
and the rest of the symbols in alphabetical order. For example, "CH2BrF".

2) if there is no carbon, all the symbols (including H) are listed
alphabetically.  For example, "BrH".

It is possible to supply a custom sorting subroutine with the 'formula_sort'
option. It expects a subroutine reference that takes a hash reference
describing the formula (similar to what is returned by parse_formula, discussed
below), and that returns a list of symbols in the desired order.

For example, this will sort the symbols in reverse asciibetical order:

    my $formula = $mol->print(
        format          => 'formula',
        formula_sort    => sub {
            my $formula_hash = shift;
            return reverse sort keys %$formula_hash;
        }
    );

=head2 Parsing Formulas

Formulas can also be parsed back into Chemistry::Mol objects.
The formula may have parentheses and square or triangular brackets, and 
it may have the following abbreviations:

    Me => '(CH3)',
    Et => '(CH3CH2)',
    Bu => '(C4H9)',
    Bn => '(C6H5CH2)',
    Cp => '(C5H5)',
    Ph => '(C6H5)',
    Bz => '(C6H5CO)',

The formula may also be preceded by a number, which multiplies the whole
formula. Some examples of valid formulas:

=over

    Formula              Equivalent to
    --------------------------------------------------------------

lib/Chemistry/File/Formula.pm  view on Meta::CPAN

    2C(C(C(C)5)4)3       C152
    C 1 0 H 2 2          C10H22 (whitespace is completely ignored)

=back

When a formula is parsed, a molecule object is created which consists of
the set of the atoms in the formula (no bonds or coordinates, of course).
The atoms are created in alphabetical order, so the molecule object for C2H5Br
would have the atoms in the following sequence: Br, C, C, H, H, H, H, H. 

If you don't want to create a molecule object, but would rather have a simple
hash with the number of atoms for each element, use the C<parse_formula>
method:

    my %formula = Chemistry::File::Formula->parse_formula("C2H6O");
    use Data::Dumper;
    print Dumper \%formula;

which prints something like

    $VAR1 = {
              'H' => 6,
              'O' => 1,
              'C' => 2
            };

The C<parse_formula> method is called internally by the C<parse_string> method.

=head3 Non-integer numbers in formulas

The C<parse_formula> method can also accept formulas that contain
floating-point numbers, such as H1.5N0.5. The numbers must be positive, and
numbers smaller than one should include a leading zero (e.g., 0.9, not .9).

When formulas with non-integer numbers of atoms are turned into molecule 
objects as described in the previous section, the number of atoms is always
B<rounded up>. For example, H1.5N0.5 will produce a molecule object with two
hydrogen atoms and one nitrogen atom.

There is currently no way of I<producing> formulas with non-integer numbers;
perhaps a future version will include an "occupancy" property for atoms that
will result in non-integer formulas.

=cut

sub parse_string {
    my ($self, $string, %opts) = @_;
    my $mol_class = $opts{mol_class} || "Chemistry::Mol";
    my $atom_class = $opts{atom_class} || "Chemistry::Atom";
    my $bond_class = $opts{bond_class} || "Chemistry::Bond";

    my $mol = $mol_class->new;
    my %formula = $self->parse_formula($string);
    for my $sym (sort keys %formula) {
        for (my $i = 0; $i < $formula{$sym}; ++$i) {
            $mol->add_atom($atom_class->new(symbol => $sym));
        }
    }
    return $mol;
}

sub write_string {
    my ($self, $mol, %opts) = @_;
    my @formula_parts;

    my $format = $opts{formula_format} || "%s%d";   # default format
    my $fh = $mol->formula_hash;
    $format =~ s/%%/\\%/g;                          # escape %% with a \
    my $joiner = "";
    $joiner = $1 if $format =~ s/(?<!\\)%j\{(.*?)}//;       # joiner %j{}

    my @symbols;
    if ($opts{formula_sort}) {
        @symbols = $opts{formula_sort}($fh);
    } else {
        @symbols = $self->sort_symbols($fh);
    }

    for my $sym (@symbols) {

lib/Chemistry/File/Formula.pm  view on Meta::CPAN

        $s =~ s/(?<!\\)%s/$sym/g;                           # %s
        $s =~ s/(?<!\\)%D/$n/g;                             # %D
        $s =~ s/(?<!\\)%d\{(.*?)\}/$n > 1 ? $1 : ''/eg;     # %d{}
        $s =~ s/(?<!\\)%d/$n > 1 ? $n : ''/eg;              # %d
        $s =~ s/\\(.)/$1/g;                                 # other \ escapes
        push @formula_parts, $s;
    }
    return join($joiner, @formula_parts);
}

sub sort_symbols {
    my ($self, $formula_hash) = @_;
    my @symbols = keys %$formula_hash;
    if ($formula_hash->{C}) {
        # C and H first, followed by alphabetical order
        s/^([CH])$/\0$1/ for @symbols;
        @symbols = sort @symbols;
        s/^\0([CH])$/$1/ for @symbols;
        return @symbols;

lib/Chemistry/File/Formula.pm  view on Meta::CPAN


sub file_is {
    return 0; # no files are identified automatically as having this format
}

### Code derived from formula.pl by Brent Gregersen follows

my %macros = (
    Me => '(CH3)',
    Et => '(CH3CH2)',
    Bu => '(C4H9)',

lib/Chemistry/File/Formula.pm  view on Meta::CPAN

    # Ac is an element
    # Pr is an element
);


sub parse_formula {
    my ($self, $formula) = @_;
    my (%elements);

    #check balancing
    return %elements if (!ParensBalanced($formula));

    # replace other grouping with normal parens
    $formula =~ tr/<>{}[]/()()()/;

    # get rid of any spaces
    $formula =~ s/\s+//g;

    # perform macro expansion
    foreach (keys(%macros)) {
        $formula =~ s/$_/$macros{$_}/g;
    }

    # determine initial compound coeficent
    my $coef = ($formula =~ s/^(\d+\.?\d*)//) ? $1 : 1.0;

    # recursively process rest of formula
    return internal_formula_parser($formula, $coef, %elements);
}

sub internal_formula_parser {
    my ($formula, $coef, %form) = @_;
    my $tmp_coef;

    my ($extract, $remainder, $prefix) =
      extract_bracketed($formula, '()', '[^(]*');

    if (defined($extract) and $extract ne '') {
        $extract =~ s/^\((.*)\)$/$1/;
        if ($remainder =~ s/^(\d+\.?\d*)(.*)$/$2/) {
            $tmp_coef = $1 * $coef;
        } else {
            $tmp_coef = $coef;
        }

        # get formula of prefix ( it has no parens)
        %form = add_formula_strings($prefix, $coef, %form) if ($prefix ne '');

        # check remainder for more parens
        %form = internal_formula_parser($remainder, $coef, %form)
          if ($remainder ne '');

        # check extract for more parens
        %form =
          internal_formula_parser($extract, $tmp_coef, %form);    
          ## we already know this is ne ''
    } else { # get formula of complete string
        %form = add_formula_strings($remainder, $coef, %form)
          if ($remainder ne '');
    }
    return %form;
}

sub add_formula_strings {
    my ($formula, $coef, %elements) = @_;

#  print "Getting Formula of $formula\n";
    $formula =~ /^(?:([A-Z][a-z]*)(\d+\.?\d*)?)+$/o # XXX new
        or croak "Invalid Portion of Formula $formula";
    while ($formula =~ m/([A-Z][a-z]*)(\d+\.?\d*)?/go) { # XXX new
        my ($elm, $count) = ($1, $2);
        $count = 1 unless defined $count;
        if (defined $elements{$elm}) {
            $elements{$elm} += $count * $coef;
        } else {

lib/Chemistry/File/Formula.pm  view on Meta::CPAN


=head1 SEE ALSO

L<Chemistry::Mol>, L<Chemistry::File>

For discussion about Hill order, just search the web for C<formula "hill
order">. The original reference is I<J. Am. Chem. Soc.> B<1900>, I<22>,
478-494.  L<http://dx.doi.org/10.1021/ja02046a005>.

=head1 AUTHOR

Ivan Tubert-Brohman <itub@cpan.org>.

Formula parsing code contributed by Brent Gregersen.

Patch for non-integer formulas by Daniel Scott.

=head1 COPYRIGHT

Copyright (c) 2005 Ivan Tubert-Brohman. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the same terms as

 view all matches for this distribution


Chemistry-MolecularMass

 view release on metacpan or  search on metacpan

MolecularMass/MolecularMass.pm  view on Meta::CPAN

=pod

=head1 NAME

Chemistry::MolecularMass - Perl extension for calculating
molecular mass of a chemical compound given its chemical formula.

=head1 VERSION

0.1

MolecularMass/MolecularMass.pm  view on Meta::CPAN


   Arbitrary element names can be added, they are expected, however, to
   start with an upper case letter followed by zero or more lower case
   letters. Macros can be any string of characters. Macros are substituted
   only once, so a macro should not evaluate to another macro. Legal
   characters in a formula are: A-Za-z0-9<>{}[]()
   Spaces are not allowed. Parentheses can be nested arbitrarily deep.

   Each MolecularMass object has its own hashes of macros and element 
   masses, so modifications made to one MolecularMass object do NOT
   affect another. The whole thing was programmed with reentrancy

MolecularMass/MolecularMass.pm  view on Meta::CPAN

#####################################################################

sub calc_mass
{
   my $self = shift;
   my $formula = shift;
   
   if($formula =~ /[^a-zA-Z\d()<>{}\[\]]/)
   {
      warn "Forbidden chars\n";
      return undef; ### Forbidden characters
   }

   unless(verify_parens($formula))
   {
      warn "Parentheses don't match\n";
      return undef; ### Parentheses do not match
   }

   $formula =~ tr/<>{}[]/()()()/;
   my $exp_formula = $self->expand_macros($formula);
   my %symbol_table = parse_formula($exp_formula);
   my $weight = $self->sum_el_masses(\%symbol_table);

   return $weight;
}

#####################################################################

sub expand_macros
{
   my $self = shift;
   my $formula = shift;

   my $macro;
   foreach $macro (keys %{$self->{macros}})
   {
      my $value = $self->{macros}->{$macro};
      eval '$formula =~ s/$macro/($value)/g';
   }
   return $formula;
}

#####################################################################

sub sum_el_masses

 view all matches for this distribution


Chemistry-Reaction

 view release on metacpan or  search on metacpan

lib/Chemistry/Reaction.pm  view on Meta::CPAN

sub new {
  my ($class, $substrate, $product, $mapping, %args) = @_;

  die sprintf(
    "$class substrate and product must coincide on atoms (%s ne %s)\n", 
        $substrate->formula, $product->formula) 
    if $substrate->formula ne $product->formula;

  my $order1 = 0;
  foreach my $bond ($substrate->bonds) {
    $order1 += $bond->order;
  }

 view all matches for this distribution


Chemistry-SQL

 view release on metacpan or  search on metacpan

lib/Chemistry/SQL.pm  view on Meta::CPAN

I<* Example of the components table estructure:>

	+-------------+--------------+------+-----+---------+----------------+
	| Field       | Type         | Null | Key | Default | Extra          |
	+-------------+--------------+------+-----+---------+----------------+
	| formula     | varchar(250) |      | MUL |         |                |
	| id          | int(11)      |      | PRI | NULL    | auto_increment |
	| smilesform  | blob         |      |     |         |                |
	| description | blob         |      |     |         |                |
	+-------------+--------------+------+-----+---------+----------------+

lib/Chemistry/SQL.pm  view on Meta::CPAN

	$self->{sth} = $self->{dbh}->prepare($self->{sql});
	$self->{sth}->execute ;

	# Creating components Table
	$self->{sql}="CREATE TABLE `components` (
	`formula` varchar(250) NOT NULL default '',
	`id` int(11) NOT NULL auto_increment,
	`smilesform` blob NOT NULL,
	`description` blob NOT NULL,
	PRIMARY KEY  (`id`),
	KEY `formula` (`formula`)
	)  ";
	$self->{sth} = $self->{dbh}->prepare($self->{sql});
	$self->{sth}->execute ;

	# Creating Reactions Table	
	$self->{sql}="CREATE TABLE `reactions` (
 	`formula` varchar(255) NOT NULL default '',
	`smilesbefore` blob NOT NULL,
	`smilesafter` blob NOT NULL,
	`atommap_forward` blob NOT NULL,
	`atommap_reverse` blob NOT NULL,
	`id` int(11) NOT NULL auto_increment,
	`direction` tinyint(1) NOT NULL default '0',
	`description` blob NOT NULL,
	PRIMARY KEY  (`id`),
	KEY `formula` (`formula`)
	) ";
	$self->{sth} = $self->{dbh}->prepare($self->{sql}) ;
	$self->{sth}->execute ;

	# Creating Results Table	
	$self->{sql}="CREATE TABLE `results` (
	`id` int(11) NOT NULL auto_increment,
	`q_name` varchar(255) NOT NULL default '',
	`formula` varchar(255) NOT NULL default '',
	`smilesbefore` blob NOT NULL,
	`smilesafter` blob NOT NULL,
	`atommap` blob NOT NULL,
	`idreact` int(11) NOT NULL default '0',
	`direction` tinyint(1) NOT NULL default '0',
	`is_root` tinyint(1) NOT NULL default '0',
	`level` int(11) NOT NULL default '0',
	PRIMARY KEY  (`id`),
	KEY `busquedakey` (`formula`,`idreact`),
	KEY `qnamekey` (`q_name`),
	KEY `levelkey` (`level`)
	)  ";
	$self->{sth} = $self->{dbh}->prepare($self->{sql}) ;
	$self->{sth}->execute;	

	# Creating Solution Graph	
	$self->{sql}="CREATE TABLE `sgraph` (
	`id` int(11) NOT NULL auto_increment,
	`q_name` varchar(255) NOT NULL default '',
	`formula` varchar(255) NOT NULL default '',
	`smilesbefore` blob NOT NULL,
	`smilesafter` blob NOT NULL,
	`atommap` blob NOT NULL,
	`idreact` int(11) NOT NULL default '0',
	`direction` tinyint(1) NOT NULL default '0',
	`is_root` tinyint(1) NOT NULL default '0',
	`reaction_smiles` blob NOT NULL default '',
	`painted` tinyint(1) NOT NULL default '0',
	PRIMARY KEY  (`id`),
	KEY `busqueda` (`formula`,`idreact`),
	KEY `q_name` (`q_name`)
	)  ";
	$self->{sth} = $self->{dbh}->prepare($self->{sql}) ;
	$self->{sth}->execute;	
	

lib/Chemistry/SQL.pm  view on Meta::CPAN


sub component_exist 	
{	my $self = shift;
	my ($component) = @_;
	my $result = 0;
	my $formula = $component->sprintf("%f");
	my $smilesform = $self->smiles_string($component);
	$self->{sql} = "SELECT smilesform,id FROM components where formula =
			'$formula'";
	$self->{sth} = $self->{dbh}->prepare($self->{sql});
	$self->{sth}->execute;
	while ((my @row = $self->{sth}->fetchrow_array)&&($result==0))
	{	if ($row[0] eq $smilesform) {$result=$row[1];}
	}

lib/Chemistry/SQL.pm  view on Meta::CPAN

=cut

sub insert_component 	
{	my $self=shift;
	my ($component,$description) = @_;
	my $formula = $component->sprintf("%f");
	my $smilesform = $self->smiles_string($component);
	if (($self->component_exist($component))==0)
	{	
		$self->{sql} = "INSERT INTO components
		(formula,smilesform,description)
		VALUES('$formula','$smilesform','$description')";
		$self->{sth}= $self->{dbh}->prepare($self->{sql});
		$self->{sth}->execute;
	}
	$self->{sth}->finish;
}

lib/Chemistry/SQL.pm  view on Meta::CPAN

sub inscomp_from_file
{	my $self=shift;
	my($file)=@_;
	my @mols = Chemistry::Mol->read($file, format => 'smiles');
	my $smilesform="";
	my $formula = "";
	my $repeat=0;
	my $ending_value = scalar(@mols) ;
	for(my $counter=0 ; $counter < $ending_value ; $counter++)
	{	$self->insert_component($mols[$counter],"");
	}		
	return 1;
}

=item $db->recover_comp(formula, smilesform)

This function returns the components.

Options of recover_comp function:

	-------------------------------
	|formula      |   smilesform  | Result
	-------------------------------
	|  blank      |   ------      | All components returned 
	-------------------------------
	|  value set  |   blank       | All components with formula parameter
	-------------------------------
	| value set   |   value set   | smilesform component is returned 
	-------------------------------

* I<Examples:>

lib/Chemistry/SQL.pm  view on Meta::CPAN


=cut

sub recover_comp
{	my $self=shift;
	my ($formula,$smilesform)=@_;
	my @list=();
	if ($formula eq "")
	{$self->{sql} = "SELECT smilesform FROM components";}
	else
	{$self->{sql} = "SELECT smilesform FROM components where formula=
			'$formula'";}
	$self->{sth} = $self->{dbh}->prepare($self->{sql});
	$self->{sth}->execute;
	if ($smilesform eq "")
	{while (my $row = $self->{sth}->fetchrow)
	 {	push @list, Chemistry::Mol->parse($row, format => 'smiles');

lib/Chemistry/SQL.pm  view on Meta::CPAN


=cut

=over 4

=item $db->reaction_exist(smilesbefore, smilesafter, formula)

It tests if the reaction described is in the database selecting the formula
reaction, and test if smilesbefore and smilesafter are the same that the
parameters describe.

=cut


sub reaction_exist 	
{	my $self=shift;
	my ($smilesbefore,$smilesafter,$formula) = @_;
	my $result = 0;
	$self->{sql} = "SELECT smilesbefore,smilesafter,id FROM reactions 
	where formula = '$formula' ";
	$self->{sth} = $self->{dbh}->prepare($self->{sql});
	$self->{sth}->execute;
	while (my @row = $self->{sth}->fetchrow_array)
	{	if (($row[0] eq $smilesbefore) && ($row[1] eq $smilesafter)) 
		{$result=$row[2];}

lib/Chemistry/SQL.pm  view on Meta::CPAN

{	my $self=shift;
	my ($reaction) = @_;
	my $id;
	my $substrate = $reaction->substrate;
	my $product = $reaction->product;
	my $formula = $substrate->sprintf("%f");
	my $smilesbefore = $substrate->sprintf("%s");
	my $smilesafter = $product->sprintf("%s");
	$self->{sql} = "SELECT id,smilesbefore,smilesafter FROM reactions 
			where formula = '$formula'";
	$self->{sth} = $self->{dbh}->prepare($self->{sql});
	$self->{sth}->execute;
	while (my @row = $self->{sth}->fetchrow_array)
	{	if (($row[1] eq $smilesbefore) && ($row[2] eq $smilesafter))
		 {$id = $row[0];}

lib/Chemistry/SQL.pm  view on Meta::CPAN


sub reaction_insert 	
{	my $self=shift;
	my ($reaction,$description,$direction) = @_;
	my $substrate = $reaction->substrate;
	my $formula = $substrate->sprintf("%f");
	my $product = $reaction->product;
	my $smilesbefore = $substrate->sprintf("%s");
	my $smilesafter = $product->sprintf("%s");
	my $atommapf;
	my $atommapr;
	my @map = $substrate->atom_map;
	$atommapf=split(//,@map);
	my @map = $product->atom_map;
	$atommapr=split(//,@map);
	if (($self->reaction_exist($smilesbefore,$smilesafter,$formula))==0)
	{	 $self->{sql} = "INSERT INTO reactions
		(formula,smilesbefore,smilesafter,atommap_forward,
		atommap_reverse,description,direction)
		VALUES('$formula','$smilesbefore','$smilesafter','$atommapf'
		,'$atommapr','$description','$direction')";
		$self->{sth} = $self->{dbh}->prepare($self->{sql});
		$self->{sth}->execute;	
	}
}

lib/Chemistry/SQL.pm  view on Meta::CPAN

	$self->{sth} = $self->{dbh}->prepare($self->{sql});
	$self->{sth}->execute;
	$self->{sth}->finish;
}

=item $db->result_before_exists(formula, smilesform, qname)

Test for one component in I<cha> if the result already has been calculated.

=cut

sub result_before_exists
{	my $self=shift;
	my ($formula,$smilesform,$qname)=@_;
	my $result = 0;
	$self->{sql} = "SELECT smilesbefore FROM results where formula = 
			'$formula' AND q_name='$qname'";
	$self->{sth} = $self->{dbh}->prepare($self->{sql});
	$self->{sth}->execute;
	while (my $rows=$self->{sth}->fetchrow)
	{	if ($rows eq $smilesform)
		{$result=1;}	

lib/Chemistry/SQL.pm  view on Meta::CPAN

	my ($startcomp)=@_;
	my $smilesform;
	my $component;
	my @child;my $rcomponent;
	foreach $component(@$startcomp)
	{	my $formula=$component->sprintf("%f");
		$smilesform=$self->smiles_string($component);
		my $sql = "SELECT smilesbefore,smilesafter,idreact,direction,
			atommap FROM results where formula = '$formula'";
		my $sth = $self->{dbh}->prepare($sql);
		$sth->execute;
		# Create the root Graph Nodes
		my $counter=0;
		while (my @row = $sth->fetchrow_array)
		{	# creem el component
			 if ($row[0] eq $smilesform)
			 {	
			 	push @child,$row[1];
				$self->sgraph_insert($formula,$row[0],$row[1],
					$row[2],$row[3],$row[4],"","1");
			 }
		}
		# Get all the others
		# Firts Get the Child Components, 
		# when detect a new child it is added in the list
		foreach $rcomponent(@child)
		{	my $component = Chemistry::Mol->parse($rcomponent, 
					format => 'smiles');
			my $formula=$component->sprintf("%f");
			my $smilestring=$self->smiles_string($component);
			my $sql  = "select smilesbefore,smilesafter,idreact,
				   direction,atommap from results where 
				   formula = '$formula' ";
			my $sth = $self->{dbh}->prepare($sql);
			$sth->execute;
			while (my @row = $sth->fetchrow_array)
			{	if ($row[0] eq $smilestring)
				{	if (!($self->sgraph_exist($formula,
						$row[0],$row[1],$row[2])))	
					{	push @child,$row[1];
						$self->sgraph_insert($formula,
						$row[0],$row[1],$row[2],
						$row[3],$row[4],"","0");
					}
				}
			}

lib/Chemistry/SQL.pm  view on Meta::CPAN

	my $smilesform;
	my $component;
	my @fathers;my $rcomponent;
	my $invdir;#inverted direction
	foreach $component(@$endcomp)
	{	my $formula=$component->sprintf("%f");
		$smilesform=$self->smiles_string($component);
		my $sql = "SELECT smilesbefore,smilesafter,idreact,direction,
			atommap FROM results where formula = '$formula'";
		my $sth = $self->{dbh}->prepare($sql);
		$sth->execute;
		# Create the root Graph Nodes
		my $counter=0;
		while (my @row = $sth->fetchrow_array)

lib/Chemistry/SQL.pm  view on Meta::CPAN

				else
				{ if ($row[3]==0)
				  {$invdir=1;}
				}
			 	push @fathers,$row[0];
				$self->sgraph_insert($formula,$row[1],$row[0],
				$row[2],$invdir,$row[4],"","1");
			 }
		}
		
		# Get all the others
		foreach $rcomponent(@fathers)
		{	my $component = Chemistry::Mol->parse($rcomponent, 
					format => 'smiles');
			my $formula=$component->sprintf("%f");
			my $smilestring=$self->smiles_string($component);
			my $sql  = "select smilesbefore,smilesafter,idreact,
					direction,atommap from results where 
					formula = '$formula' ";
			my $sth = $self->{dbh}->prepare($sql);
			$sth->execute;
			while (my @row = $sth->fetchrow_array)
			{	if ($row[1] eq $smilestring)
				{	 if ($row[3]==1) 
			 		 {$invdir=0;}
					 else
					 { if ($row[3]==0)
				  	   {$invdir=1;}
					 }
					if (!($self->sgraph_exist($formula,
						$row[1],$row[0],$row[2])))
					{	push @fathers,$row[0];
						$self->sgraph_insert($formula,
						$row[1],$row[0],$row[2],
						$invdir,$row[4],"","0");
					}
				}
			}

lib/Chemistry/SQL.pm  view on Meta::CPAN



sub gsg_levels
{	my $self=shift;
	my ($qname,$initlevel,$endlevel)=@_;
	my $sql = "SELECT level,formula,smilesbefore,smilesafter,idreact,
		direction,atommap FROM results where q_name='$qname' 
		AND level >= '$initlevel' AND level<='$endlevel'";
	my $sth = $self->{dbh}->prepare($sql);
	$sth->execute;
	while (my @row = $sth->fetchrow_array)

lib/Chemistry/SQL.pm  view on Meta::CPAN



sub gsg_complete
{	my $self=shift;
	my ($qname)=@_;
	my $sql = "SELECT formula,smilesbefore,smilesafter,idreact,
	direction,atommap,is_root FROM results where q_name='$qname'";
	my $sth = $self->{dbh}->prepare($sql);
	$sth->execute;
	while (my @row = $sth->fetchrow_array)
	{	$self->sgraph_insert($row[0],$row[1],$row[2],$row[3],$row[4],
					$row[5],$qname,$row[6]);	}
	$self->{sth}->finish;
}

=item $db->sgraph_exist(formula, smilesbefore, smilesafter, idreact)

Checks if a result is in the solution graph table

=cut


sub sgraph_exist
{	my $self=shift;
	my ($formula,$smilesbefore,$smilesafter,$idreact) = @_;
	my $result=0;
	$self->{sql} = "SELECT smilesbefore, smilesafter FROM sgraph where 
			formula = '$formula'  AND idreact = '$idreact' ";
	$self->{sth} = $self->{dbh}->prepare($self->{sql});
	$self->{sth}->execute;
	#Finding for a equal smilesbefore and smilesafter strings
	while (my @row = $self->{sth}->fetchrow_array)
	{	if (($row[0] eq $smilesbefore) && ($row[1] eq $smilesafter)) 

lib/Chemistry/SQL.pm  view on Meta::CPAN

	# 0 if not exist
	$self->{sth}->finish;
	return $result;
}

=item $db->sgraph_insert(formula,smilesbefore,smilesafter,idreact,direction,
atommap,q_name,is_root)

Solution graph insertion.

=cut


sub sgraph_insert
{	my $self=shift;
	my ($formula,$smilesbefore,$smilesafter,$idreact,$direction,$atommap,
	$qname,$is_root) = @_;
	if (!($self->sgraph_exist($formula,$smilesbefore,$smilesafter,$idreact)))
	{	# Get the Reaction Properties and Insert into the 
		# Result Graph Table
		my $sql = "Select smilesbefore,smilesafter from reactions  
				where id = $idreact";
		my $sth =  $self->{dbh}->prepare($sql);

lib/Chemistry/SQL.pm  view on Meta::CPAN

		if (my @row=$sth->fetchrow_array)
		{	$smilesreaction = $row[0].">>".$row[1];
		}
		$sth->finish;
		$self->{sql} = "INSERT INTO sgraph
		(formula,smilesbefore,smilesafter,idreact,direction,atommap,
		q_name,is_root,reaction_smiles)
		VALUES('$formula','$smilesbefore','$smilesafter','$idreact',
		'$direction','$atommap','$qname','$is_root','$smilesreaction')";
		$self->{sth} = $self->{dbh}->prepare($self->{sql});
		$self->{sth}->execute;
		$self->{sth}->finish;
		return 1;

lib/Chemistry/SQL.pm  view on Meta::CPAN


=cut

=over 4

=item $db->resultinsert(formula, smilesbefore, smilesafter, idreact, direction,
atommap, qname, is_root, level)

Inserts a result in the database.

=cut

sub result_insert
{	my $self=shift;
	my ($formula,$smilesbefore,$smilesafter,$idreact,$direction,$atommap,
	$qname,$is_root,$level) = @_;
	if ($smilesbefore eq $smilesafter) {return 0;}
	
	if (!($self->results_exist($formula,$smilesbefore,$smilesafter,
	$idreact,$qname)))
	{	$self->{sql} = "INSERT INTO results
		(formula,smilesbefore,smilesafter,idreact,direction,atommap,
		q_name,is_root,level)
		VALUES('$formula','$smilesbefore','$smilesafter','$idreact',
		'$direction','$atommap','$qname','$is_root','$level')";
		$self->{sth} = $self->{dbh}->prepare($self->{sql});
		$self->{sth}->execute;
		$self->{sth}->finish;
		return 1;
	}
	else 
	{return 0;}
}

=item $db->resultexist(formula, smilesbefore, smilesafter, idreact, qname)

Checks if the result already exists in the database.

=cut

sub results_exist
{	my $self=shift;
	my ($formula,$smilesbefore,$smilesafter,$idreact,$qname) = @_;
	my $resultado=0;
	$self->{sql} = "SELECT smilesbefore, smilesafter FROM results where
			formula = '$formula'  AND idreact = '$idreact' 
			AND q_name='$qname'";
	$self->{sth} = $self->{dbh}->prepare($self->{sql});
	$self->{sth}->execute;
	while (my @row = $self->{sth}->fetchrow_array)
	{	if ((@row[0] eq $smilesbefore) && (@row[1] eq $smilesafter)) 

lib/Chemistry/SQL.pm  view on Meta::CPAN

{	my $self = shift;
	# @_ is the quimics name
	my ($id,$component) = @_;
	my @info;
	my $smilesform = $self->smiles_string($component);
	my $formula = $component->sprintf("%f");
	$self->{sql} = "select smilesbefore,direction,atommap,reaction_smiles 
			from sgraph where id='$id'";
	$self->{sth} = $self->{dbh}->prepare($self->{sql});
	$self->{sth}->execute;
	if (my @row = $self->{sth}->fetchrow_array)
	{		push @info, $smilesform;
			push @info, $formula;
			push @info, $row[0];
			push @info, $row[1];
			push @info, $row[2];
			push @info, $row[3];	
	}

lib/Chemistry/SQL.pm  view on Meta::CPAN

=cut

sub rec_child 
{	my $self = shift;
	my ($component)=@_;
	my $formula = $component->sprintf("%f");
	my $smilesform = $self->smiles_string($component);
	$self->{sql} = "select id,smilesbefore,smilesafter from sgraph 
			where formula = '$formula' and painted=0";
	$self->{sth} = $self->{dbh}->prepare($self->{sql});
	$self->{sth}->execute;
	my @result;my @ids;
	while (my @row = $self->{sth}->fetchrow_array)
	{	# creem el component

 view all matches for this distribution


Chess-Elo

 view release on metacpan or  search on metacpan

lib/Chess/Elo.pm  view on Meta::CPAN

is given an initial provisional rating of 1600 points. 
In all cases, one gains and loses
points as a function of the playing strength of both parties and the result
of their encounter.

The formula used is:

    A2 = A1 + 32 (  G - ( 1 / ( 1 + 10 ** ( ( B1 -A1) / 400 ) ) ) )

=over 

 view all matches for this distribution


Chess-Plisco

 view release on metacpan or  search on metacpan

lib/Chess/Plisco/Engine/Position.pm  view on Meta::CPAN

	# If one side is a minor piece ahead, it is considered a draw, when there
	# are no rooks or queens on the board.  Important exception is KBB vs KN.
	# But in that case the material delta is B + B - N which is greater
	# than B.  On the other hand KBB vs KB is a draw and the material balance
	# in that case is exactly one bishop.
	# These simple formulas do not take into account that there may be more
	# than two knights or bishops for one side on the board but in the
	# exceptional case that this happens, the result would be close enough
	# anyway.
	if (!$pawns) {
		my $delta = (do {	my $mask = $material >> CP_INT_SIZE * CP_CHAR_BIT - 1;	($material + $mask) ^ $mask;});

 view all matches for this distribution


Class-Adapter

 view release on metacpan or  search on metacpan

lib/Class/Adapter/Clear.pm  view on Meta::CPAN

#pod
#pod You may never need this much power. But when you need it, you B<really>
#pod need it.
#pod
#pod As an aside, Class::Adapter::Clear is implemented with the following
#pod L<Class::Adapter::Builder> formula.
#pod
#pod   use Class::Adapter::Builder
#pod       ISA      => '_OBJECT_',
#pod       AUTOLOAD => 1;
#pod

lib/Class/Adapter/Clear.pm  view on Meta::CPAN


You may never need this much power. But when you need it, you B<really>
need it.

As an aside, Class::Adapter::Clear is implemented with the following
L<Class::Adapter::Builder> formula.

  use Class::Adapter::Builder
      ISA      => '_OBJECT_',
      AUTOLOAD => 1;

 view all matches for this distribution


Class-DBI-DDL

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

or drop the table automatically.

Installation
------------

This uses the typical Module::Build formula:

  perl Build.PL
  ./Build
  ./Build test
  ./Build install

 view all matches for this distribution


Class-Maker

 view release on metacpan or  search on metacpan

lib/Class/Maker/Examples/Soccer.pm  view on Meta::CPAN

		$spiel->printout();

		#print $spiel->to_html( type => 'FILE', source => 'spiel.tmpl' );
	}

	my $formular = new Formular::Antrag::Anmeldung();

		# wir simulieren ein ausgefülltes formular

	$formular->antragsteller( new Mensch( name => 'Horst', email => 'horsttappert@web.de' ) );

		# Wir brauchen einen Waechter (Object::Bouncer) der:
		#	- die Formulare auf ihre Rightigkeit überprüft.
		#
		# )=> 'Sicherheit::Waechter::Anmeldung'

lib/Class/Maker/Examples/Soccer.pm  view on Meta::CPAN


	my $schatzmeister = new Schatzmeister( name => 'Dagobert' );

		# dummy Zahlung

	$schatzmeister->annehmen( $formular->antragsteller, 100, 'Eintritt' );

	if( $schatzmeister->hatbezahlt( $formular->antragsteller ) )
	{
			# Voila ...Antrag akzeptiert ! der "antragsteller" wird zum mitgleid

		my $mitglied = $spielleiter->akzeptiert( $formular->antragsteller );

		printfln "\nHallo Herr %s, ihr Mitgliedname lautet %s und Passwort lautet %s. Herzliche Grüsse %s",

			$mitglied->name, $mitglied->userid, $mitglied->passwd, $spielleiter->name;

 view all matches for this distribution


ClearCase-Region

 view release on metacpan or  search on metacpan

docs/Creating_Reuseable_Perl_Scripts.htm  view on Meta::CPAN


<p class=MsoNormal><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600"
 o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f"
 stroked="f">
 <v:stroke joinstyle="miter"/>
 <v:formulas>
  <v:f eqn="if lineDrawn pixelLineWidth 0"/>
  <v:f eqn="sum @0 1 0"/>
  <v:f eqn="sum 0 0 @1"/>
  <v:f eqn="prod @2 1 2"/>
  <v:f eqn="prod @3 21600 pixelWidth"/>

docs/Creating_Reuseable_Perl_Scripts.htm  view on Meta::CPAN

  <v:f eqn="prod @6 1 2"/>
  <v:f eqn="prod @7 21600 pixelWidth"/>
  <v:f eqn="sum @8 21600 0"/>
  <v:f eqn="prod @7 21600 pixelHeight"/>
  <v:f eqn="sum @10 21600 0"/>
 </v:formulas>
 <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
 <o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_s1028" type="#_x0000_t75" style='position:absolute;
 margin-left:0;margin-top:5.2pt;width:279pt;height:4in;z-index:1;
 mso-wrap-style:none;v-text-anchor:middle' fillcolor="#09c" strokecolor="#3cc"

 view all matches for this distribution


Clownfish-CFC

 view release on metacpan or  search on metacpan

lemon/lempar.c  view on Meta::CPAN

** If the index value yy_shift_ofst[S]+X is out of range or if the value
** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
** and that yy_default[S] should be used instead.  
**
** The formula above is for computing the action when the lookahead is
** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
** a reduce action) then the yy_reduce_ofst[] array is used in place of
** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
** YY_SHIFT_USE_DFLT.
**

 view all matches for this distribution


Cmd-Dwarf

 view release on metacpan or  search on metacpan

examples/helloworld/htdocs/dwarf/bootstrap/css/bootstrap.css  view on Meta::CPAN

  content: "\e214";
}
.glyphicon-knight:before {
  content: "\e215";
}
.glyphicon-baby-formula:before {
  content: "\e216";
}
.glyphicon-tent:before {
  content: "\26fa";
}

 view all matches for this distribution


Color-Fade

 view release on metacpan or  search on metacpan

lib/Color/Fade.pm  view on Meta::CPAN

    '#FF0000', '#00FF00', '#0000FF',
  ));

=head1 DESCRIPTION

Color::Fade uses mathematical formulas to take an input string of virtually any length,
and virtually any number of colors, and assign an individual color to each character to
fade between each of the input colors.

In other words, it makes your sentences look really pretty. :)

 view all matches for this distribution


Color-RGB-Util

 view release on metacpan or  search on metacpan

lib/Color/RGB/Util.pm  view on Meta::CPAN

=item * approx1

This algorithm, described in [1] as "a low cost approximation" and "a
combination both weighted Euclidean distance functions, where the weight factors
depend on how big the 'red' component of the colour is" with "results that are
very close to L*u*v" and "a more stable algorithm", uses the following formula:

 ( 2*(R1-R2)**2 + 4*(G1-G2)**2 + 3*(B1-B2)**2 + Rm*((R1-R2)**2 - (B1-B2)**2)/256 )**0.5

where, Rm or "R mean" is (R1+R2)/2.

=item * approx2

Like C<approx1>, but uses this formula:

 ( 2*(R1-R2)**2 + 4*(G1-G2)**2 + 3*(B1-B2)**2 )**0.5  # if Rm < 128
 ( 3*(R1-R2)**2 + 4*(G1-G2)**2 + 2*(B1-B2)**2 )**0.5  # otherwise

=item * hsv_euclidean

lib/Color/RGB/Util.pm  view on Meta::CPAN


Usage:

 my $dist = rgb_distance($rgb1, $rgb2)

Calculate the euclidean RGB distance, using this formula:

 ( (R1-R2)**2 + (G1-G2)**2 + (B1-B2)**2 )**0.5

For example, the distance between "000000" and "ffffff" is ~441.67, while the
distance between "ffff00" and "ffffff" is 255.

lib/Color/RGB/Util.pm  view on Meta::CPAN


Usage:

 my $luminance = rgb_luminance($rgb);

Calculate standard/objective luminance from RGB value using this formula:

 (0.2126*R) + (0.7152*G) + (0.0722*B)

where R, G, and B range from 0 to 1. Return a number from 0 to 1.

 view all matches for this distribution


( run in 0.502 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )