Chemis...:Parser(3pm)

πŸ“¦
version 0.12.4 Β· 2 versions
, in ubuntu stonking

🌸 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" fr
  • raw β€” 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 in Chemistry::OpenSMILES expect non-raw data structures, so if you process raw output you might get distorted results. specifically, write_SMILES() calls from Chemistry::OpenSMILES::Writer have 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