Chemis...nSMILES(3pm)
π NAME π
Chemistry::OpenSMILES β bestie, this is your OpenSMILES format reader and writer, like a whole two-way translator for chemical structure strings and she is serving.
β¨ SYNOPSIS β¨
use Chemistry::OpenSMILES::Parser;
my $parser = Chemistry::OpenSMILES::Parser->new;
my @moieties = $parser->parse( 'C#C.c1ccccc1' );
$\ = "\n";
for my $moiety (@moieties) {
# $moiety is a Graph::Undirected object
print scalar $moiety->vertices;
print scalar $moiety->edges;
}
use Chemistry::OpenSMILES::Writer qw(write_SMILES);
print write_SMILES( \@moieties );
okay so that's literally the whole vibe: make a parser, throw a SMILES string at it, get back a list of Graph::Undirected objects, peek at how many vertices and edges each one has, then hand the whole list to write_SMILES and get a string back. no cap, iconic. π§ͺβ¨
πΈ DESCRIPTION πΈ
Chemistry::OpenSMILES has your back for SMILES chemical identifiers that play by the OpenSMILES v1.0 specification rules β here's where the rules live: <http://opensmiles.org/opensmiles.html> π«Ά
Chemistry::OpenSMILES::Parserreads in SMILES strings and hands them back parsed into arrays ofGraph::Undirectedobjects. Every single atom is represented by a hash. (yes. a hash. she's giving structure.)Chemistry::OpenSMILES::Writerdoes the inverse β the glow-up in reverse. For all the SMILES writing conventions and options, go check out its own description, iykyk. π
π¦ Molecular graph π¦
Disconnected parts of a compound? They get to be their own separate Graph::Undirected objects β no forcing them to sit together, we respect boundaries here. Atoms become vertices, and bonds become edges. that's the whole anatomy, periodt.
β Atoms
Atoms (aka the vertices of a molecular graph) are represented as hash references:
{
"symbol" => "C",
"isotope" => 13,
"chirality" => "@@",
"hcount" => 3,
"charge" => 1,
"class" => 0,
"number" => 0,
}
Okay so listen: except for "symbol", "class" and "number", every key in that hash is optional. You do not have to fill it all in, bestie, it's giving low-maintenance. And per the OpenSMILES specification, the default values for "hcount" and "class" are 0.
For chiral atoms π, the order of their neighbours in the input is preserved in an array that gets added as the value for the "chirality_neighbours" key of the atom hash. The order of the atoms in there follows OpenSMILES convention β so don't go rearranging them, the chirality is literally depending on it. π
π Bonds
Bonds β the edges of a molecular graph β rely completely on Graph::Undirected's internal representation. Like, fully trusting her, no extra sauce. π«Ά
Bond orders other than single (-, which is also the default, cute) are represented as values of the edge attribute "bond". Those values correspond to the symbols used in the OpenSMILES specification. β‘
π AUTHORS π
Andrius Merkys, <merkys@cpan.org> β thank you for your service, king. π«‘
and that's the whole page! shipped with π perl v5.40.1, dated 2026-06-19, and the manual name you're reading is Chemistry::OpenSMILES(3pm) β go forth and parse some molecules, bestie ππβ¨
π¦ where this page comes from
- ubuntu stonking: libchemistry-opensmiles-perl 0.12.4-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms