mdanalysis
mdanalysis copied to clipboard
Make biopython an optional dependency
I think this has been a long time request by @jbarnoud (apologies if I'm misremembering).
Not the biggest dependency, but we could easily make it an optional one given we need it mostly for sequence alignment. Probably needs some discussion re: the impact it has on seqres though.
Ok with me. We can eventually replace it with something else (scikit-bio?) but perhaps also optional.
In alignment (?) we use pairwise alignment somewhere, I don’t want to implement our own.
Generic comment on optional packages: https://github.com/MDAnalysis/mdanalysis/issues/3822#issuecomment-1248739769
Honestly with the new 1.80 pin we need to have here, I feel like we should act on this sooner than later. Are there any objections for getting this done in 2.5.0?
- #3950 is deprecating
align.sequence_alignment()for removal in 3.0 (but until then we need biopython >= 1.80) ResidueGroup.sequence()produces by default biopythonBio.SeqRecinstances (orBio.Seqwhen requested). That was an unfortunate choice of default;stras default would have made it easier to hide biopython. We should definitely change the default to string (announce now and make the switch in 3.0 — or would it be ok to do it for 2.5?).
Both could load biopython on demand so we can definitely go ahead and make biopython an optional dependency.
Btw, how do we declare that an optional dependency requires a minimal version number?
Btw, how do we declare that an optional dependency requires a minimal version number?
Had a quick look with #4332 and it doesn't look like setuptools enforces a minimum version on biopython as an optional dep. This makes sense, the requirement is "optional", so it shouldn't be strongly opiniated about what's in your environment.
As-is all our optional deps now don't have lower/upper pins on, which might not be the behaviour we want as a package.
How do we want to go about this?
One possible suggestion here is to spruce up our optional importers to also have version validators? That shouldn't be too hard to do.