EddyRivasLab / hmmer

HMMER: biological sequence analysis using profile HMMs
http://hmmer.org
Other
317 stars 70 forks source link

Add functions to clone a `P7_TOPHITS` #273

Closed althonos closed 2 years ago

althonos commented 2 years ago

Hi !

This PR adds new functions to clone a P7_TOPHITS, namely p7_domain_Copy, p7_hit_Copy and p7_tophits_Clone, which follow the copy/clone semantics of the rest of the code.

You may not have immediate use for it in HMMER, but I definitely need them for PyHMMER (where I actually implemented them, but they have their place in the upstream code). Basically, since the p7_tophits_merge function effectively consumes its second argument, this makes it unsound to use in Python, because reference counting means that several references may still exist to the second top hits. Copying the hits before merging solves the issue because the original object is then untouched.

cryptogenomicon commented 2 years ago

Thanks, looks good!