Chemistry Reference
In-Depth Information
#-- return true if smi is matched by sma
my ($smi, $sma) = @_;
my $mol = Chemistry::Mol->parse($smi, format => smiles);
aromatize_mol($mol);
my $patt = Chemistry::Pattern->parse($sma, format => smarts);
if ( $patt->match($mol) ) {
return 't';
} else {
return 'f';
}
$EOPERL$ Language plperlu;
Create Or Replace Function count_matches(text, text) Returns
Integer As $EOPERL$
use Chemistry::File::SMILES;
use Chemistry::File::SMARTS;
use Chemistry::Ring 'aromatize_mol';
#-- return how many times smi is matched by sma
my ($smi, $sma) = @_;
my $mol = Chemistry::Mol->parse($smi, format => smiles);
aromatize_mol($mol);
my $patt = Chemistry::Pattern->parse($sma, format => smarts);
my $nmatch = 0;
while ( $patt->match($mol) ) {
++$nmatch;
}
return $nmatch;
$EOPERL$ Language plperlu;
Create Or Replace Function list_matches(text, text, integer)
Returns Text[] As $EOPERL$
use Chemistry::File::SMILES;
use Chemistry::File::SMARTS;
use Chemistry::Ring 'aromatize_mol';
#-- return list of atoms in smi matched by sma
#-- return nshow'th match; all matches if nshow=0
my ($smi, $sma, $nshow) = @_;
my $mol = Chemistry::Mol->parse($smi, format => smiles);
aromatize_mol($mol);
my $patt = Chemistry::Pattern->parse($sma, format => smarts);
#---- map atom ids (returned from $patt->atom_map below) to atom
numbers in mol
my %atom_number;
my $iatom = 1;
foreach ( $mol->atoms ) {
$atom_number{$_} = $iatom;
++$iatom;
}
Search WWH ::




Custom Search