BioStructures.jl icon indicating copy to clipboard operation
BioStructures.jl copied to clipboard

biojulep: iterators or fold for structures

Open timholy opened this issue 1 year ago • 1 comments

This package has utilities like collectresidues and collectatoms. Because this allocates storage, it might be of interest to implement an alternative. I see two main options:

  • an iterator interface, e.g., EachResidue(struc) or EachAtom(struc). collectresidues could then be implemented as collectresidues(struc) = collect(EachResidue(struc)) but one could also perform other forms of processing (for r in EachResidue(struc) ... end).
  • a transducers interface, where foldxl is the core operation.

I have less personal experience with the latter, so left to my own devices I'd probably be tempted to implement the iterator version. But collectresidues/collectatoms are currently probably special cases of foldxl so generalizing them would be perfectly viable too.

timholy avatar Aug 21 '24 14:08 timholy

Sounds like a good idea, and I am also more familiar with the iterator interface.

jgreener64 avatar Aug 22 '24 10:08 jgreener64