mdanalysis icon indicating copy to clipboard operation
mdanalysis copied to clipboard

Make biopython an optional dependency

Open IAlibay opened this issue 3 years ago • 1 comments
trafficstars

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.

IAlibay avatar Sep 09 '22 13:09 IAlibay

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

orbeckst avatar Sep 15 '22 23:09 orbeckst

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?

IAlibay avatar Dec 08 '22 06:12 IAlibay

  • #3950 is deprecating align.sequence_alignment() for removal in 3.0 (but until then we need biopython >= 1.80)
  • ResidueGroup.sequence() produces by default biopython Bio.SeqRec instances (or Bio.Seq when requested). That was an unfortunate choice of default; str as 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.

orbeckst avatar Dec 08 '22 07:12 orbeckst

Btw, how do we declare that an optional dependency requires a minimal version number?

orbeckst avatar Dec 08 '22 07:12 orbeckst

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.

IAlibay avatar Nov 07 '23 09:11 IAlibay