Chemis...:Parser(3pm)
πΈ Chemis...:Parser(3pm) πΈ
okay bestie, welcome to the Chemistry::OpenSMILES::Parser page from the User Contributed Perl Documentation (that's the 3pm manual section, for those of you keeping track) β¨ it's a whole manual page and we're gonna get through it together, no skimming, no skipping π
β¨ NAME β¨
Chemistry::OpenSMILES::Parser β the OpenSMILES format reader. that's it, that's the whole name section, short and sweet π
π SYNOPSIS π
here's the vibe in code form, literally copy-paste ready:
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;
}
like, you make a parser, you hand it a SMILES string, you get back a little pile of graphs. slay π¦
π DESCRIPTION π
Chemistry::OpenSMILES::Parser is an OpenSMILES format reader. that's the whole description fr fr, it reads OpenSMILES, iconic behavior, we move π
π METHODS π
π§ parse( $smiles, \%options )
this is the main character method right here π it parses a SMILES string and returns an array of disconnected molecular entities, each one its own separate instance of Graph::Undirected. how you're supposed to interpret those graphs is explained in detail over in Chemistry::OpenSMILES β go read that if you want the full lore π
π Options π
parse() accepts these as key-value pairs in an anonymous hash passed as its second parameter, so like:
- second argument =
{ option_name => value, ... }π
here's everything you can pass:
max_hydrogen_count_digitsβ so the OpenSMILES spec says attached hydrogen atoms inside square brackets max out at 9. but IUPAC SMILES+ went and bumped that number all the way up to 99 π with this option you can tell the parser to allow a different number of digits than 1 for the attached hydrogen count. it's giving "choose your own digit count" frrawβ set this to anything that evaluates to true and the parser will not convert implicit hydrogen atoms or explicit hydrogen atoms in square brackets into atom hashes of their own. on top of that, it also won't attempt to unify the representations of chirality. that said β heads up bestie π β lots of the subroutines inChemistry::OpenSMILESexpect non-raw data structures, so if you process raw output you might get distorted results. specifically,write_SMILES()calls fromChemistry::OpenSMILES::Writerhave to be told to expect the raw data structure:
write_SMILES( \@moieties, { raw => 1 } );
β οΈ this option is deprecated now and might get removed in upcoming versions. don't get too attached π
report_unnecessary_dot_usageβ set this to anything that evaluates to true and the parser will emit warnings about dot bonds used in parentheses. perfect for catching unnecessary dot bond usage, which is a very "not me leaving a stray dot bond in my SMILES" moment π
π CAVEATS π
okay this is the part where we get real. read it, bestie, I'm serious:
- Deprecated charge notations (
--and++) are supported. they're deprecated but they still work, so vibe check accordingly π - the OpenSMILES specification mandates a strict order of ring bonds and branches:
branched_atom ::= atom ringbond* branch*
but Chemistry::OpenSMILES::Parser supports both the mandated structure and the inverted one, where ring bonds come after the branch descriptions. flexible queen π
- Whitespace is not supported yet. SMILES descriptors must be cleaned of whitespace before you even try reading them with
Chemistry::OpenSMILES::Parser. so. clean your strings, bestie, the parser is not your housekeeper π§Ή - the derivation of implicit hydrogen counts for aromatic atoms is not unambiguously defined in the OpenSMILES specification π so only aromatic carbon gets accounted for, as if it had a valence of 3. that's the deal, no cap.
- chiral atoms with three neighbours are interpreted as having a lone pair of electrons on one of their chiral neighbours. the lone pair is always understood as being second in the order of neighbour enumeration β except when the atom with the lone pair starts a chain, and in that case the lone pair is first. yes, it's specific. yes, it matters. it's giving "the details are the whole point" β¨
π«Ά AUTHORS π«Ά
Andrius Merkys, merkys@cpan.org β thank you for your service, king π
and that's the page!! generated by perl v5.40.1, dated 2026-06-19, straight outta the User Contributed Perl Documentation, and it's been under the Chemis...:Parser(3pm) title this whole time in case you forgot where we started π bye bestie, go parse something cute πΈπ¦π
π¦ 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