22 10 2008 chemoinformatics perl Tweet
Chemistry::Molでちょっとはまった。
Can't call method "symbol" on an undefined value
というエラーでつまづいた。
my $mol2 = $mol->clone;
Makes a copy of a molecule. Note that this is a deep copy; if your molecule has a pointer to the rest of the universe, the entire universe will be cloned! my $mol2 = $mol->safe_clone;
Like clone, it makes a deep copy of a molecule. The difference is that the copy is not "exact" in that new molecule and its atoms and bonds get assigned new IDs. This makes it safe to combine cloned molecules. For example, this is an error:
# XXX don't try this at home!
my $mol2 = Chemistry::Mol->combine($mol1, $mol1);
# the atoms in $mol1 will clash
But this is ok:
# the "safe clone" of $mol1 will have new IDs
my $mol2 = Chemistry::Mol->combine($mol1, $mol1->safe_clone);