Chemis...:Writer(3pm)

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

✨ Chemis...:Writer(3pm) β€” the Perl doc you didn't know you needed ✨

okay bestie, pull up a chair πŸŽ€ this is Chemistry::OpenSMILES::Writer, a lil Perl module from the user-contributed Perl documentation shelf, and she is exactly what you think she is: the writer half of the OpenSMILES duo. πŸ’…


🌸 NAME 🌸

Chemistry::OpenSMILES::Writer β€” an OpenSMILES format writer. she writes, she slays, that's the whole job. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

like, here's the vibe in code form:

use Graph::Undirected;
use Chemistry::OpenSMILES::Writer qw( write_SMILES );

my $g = Graph::Undirected->new;
$g->add_edge( { symbol => 'C' }, { symbol => 'O' } );
print write_SMILES( [ $g ] );

look at her go 🫢


πŸ‘‘ DESCRIPTION πŸ‘‘

Chemistry::OpenSMILES::Writer is the writer for molecular graph objects β€” the ones made by Chemistry::OpenSMILES::Parser, or honestly any way you want to make them, no gatekeeping here. 🌈

She exports exactly one subroutine: write_SMILES(). You hand her an array of molecular graph objects, and she hands you back a SMILES representation of them. iconic behavior, truly. ✨


πŸ’… METHODS πŸ’…

🌟 write_SMILES( \@molecules, \%options ) 🌟

so @molecules is your array of molecular graph objects, periodt. and then there's the options, which we're gonna go through one by one because every single one matters, no skips. πŸ’œ

πŸ“ Options πŸ“

  • explicit_aromatic_bonds β€” a boolean flag that tells the writer to output all aromatic bonds as ':'. she's off by default, so don't come for me when your aromatics look normal. πŸ™ˆ
  • explicit_parentheses β€” a boolean flag that tells the writer to always wrap those "children" atoms in parentheses. also off by default. yes she's extra, no she's not on unless you turn her on. πŸ’…
  • immediately_reuse_ring_numbers β€” a boolean flag that tells the writer to reuse ring closure numbers immediately. this one is on by default. now, lowkey, immediately reused ring numbers can trip up human readers and cause some confusion 😭 β€” but the payoff is being able to have more open rings at once, so it's giving tradeoff, and the default says the tradeoff is worth it.
  • remove_implicit_hydrogens β€” a boolean flag that tells the writer to remove hydrogens, when they're expressed as atom properties, if their number can be unambiguously derived from normal valency. on by default. if it's unambiguous, she's not writing it, periodt. ✨
  • unsprout_hydrogens β€” a boolean flag that tells the writer to demote explicit hydrogens β€” the "atoms on their own", the "sprouted" ones 🌱 β€” down into atom properties of their parent heavy atom. on by default. caveat though: not all hydrogens can be demoted. some of them are just gonna stay sprouted, and that's that. πŸ₯²
  • order_sub β€” a subroutine reference she uses to figure out the next atom in order when there's ambiguity. if you don't hand her one, input order is retained whenever possible. but here's the tea you need: write_SMILES() does not necessarily respect the order subroutine β€” what she actually does is perform DFS merely guided by the order you requested. so before you call write_SMILES(), the exact postorder is not known. only the preorder is known. which means relative properties β€” cis/trans markers, for example β€” have to be adjusted to preorder. and any other order-dependent markers? yeah, those have to be adjusted to preorder too. adjust accordingly, bestie. 🧚
  • write_atom_sub β€” a subroutine reference used to depict an atom in the output SMILES. it takes three parameters: the atom hash, the molecular graph, and the option hash. it must return a string. caveat: the interface might change, so, y'know, iykyk. πŸ’€

πŸ’– AUTHORS πŸ’–

Andrius Merkys, <merkys@cpan.org> β€” thank you king, we love a credited author. πŸ‘‘


fr fr, that's the whole page. nothing skipped, nothing invented, every flag still exactly where it belongs. πŸ’―

and that's a wrap on this lil page, written by yours truly with the energy of a group chat and the accuracy of a spec sheet β€” this was Chemis...:Writer(3pm), from the User Contributed Perl Documentation, running on perl v5.40.1, dated 2026-06-19. mwah, take care of her πŸ«ΆπŸ’…βœ¨

πŸ“¦ where this page comes from