Skip to content

Initial work on new restriction analysis library. - #148

Closed
anntzer wants to merge 2 commits into
biopython:masterfrom
anntzer:restriction
Closed

anntzer wants to merge 2 commits into
biopython:masterfrom
anntzer:restriction

Conversation

@anntzer

@anntzer anntzer commented Jan 15, 2013

Copy link
Copy Markdown
Contributor

An attempt at writing a slightly more sane restriction analysis library. As it is right now, Bio.Restriction is not usable e.g. with IPython because the classes used to define restriction enzymes raise an error when their metaclass' len is called (which IPython's pretty-printer implicitely does), which is a bit crazy in my opinion.
Comments are welcome.

@peterjc

peterjc commented Jan 15, 2013

Copy link
Copy Markdown
Member

Can we fix the len issue in the current code base?

My two top pain points with the current restriction module are that fact is uses 1-based counting (it should be zero based like Python and the rest of Biopython) and creating a named class for every enzyme automatically - which means dir(module) and auto-generated help including help(module) is overly busy.

In terms of namespaces perhaps under Bio.SeqUtils might be better? Something for the mailing list I think...

@anntzer

anntzer commented Jan 15, 2013

Copy link
Copy Markdown
Contributor Author

I fixed the __len__ issue now and 1-based counting shouldn't be too hard to fix either; on the other hand the fact that the module creates a new type for each enzyme (which is insane IMHO) cannot really be fixed (I think) without rewriting the whole module (which is what I already did...).
I don't know enough about biopython to discuss namespace issues... though in any case it would probably be better to use Bio.Seq rather than a custom Seq type; however I'd much rather have the linear/circular information in the Seq object rather than being passed to the search functions as a separate keyword argument (which looks like bad API to me).

@peterjc

peterjc commented Jan 15, 2013

Copy link
Copy Markdown
Member

We can't change the 1-based counting or creation of loads of classes in the old Bio.Restriction as it would break any existing scripts using it. This would be best done as a rewrite of the whole restriction digest enyzme code.

We could (and perhaps should) fix __len__ on the old Bio.Restriction code base - but I'm wary of touching it as much as your f2a6c3a8c513ec1620fe420754d36924e0b28662 commit did. There is too much 'magic' as Frédéric once phrased it http://lists.open-bio.org/pipermail/biopython-dev/2008-October/004369.html

Regarding holding linear/circular information in the Seq object or a new CircularSeq object this has come up before, but we've never managed to agree a sensible behaviour (particularly for slicing). If you have some thoughts about this I'd also suggest moving this discussion to the biopython-dev mailing list.

Fix the __len__ issue (that was defined in the wrong metaclass for IPython).
Put all type creations in a single function to clean up the global namespace.
Remove irrelevant comments about import speed.
@anntzer

anntzer commented Jan 15, 2013

Copy link
Copy Markdown
Contributor Author

Sorry for rebasing but there was some bug that got stranded in an earlier commit.

@anntzer

anntzer commented Jan 15, 2013

Copy link
Copy Markdown
Contributor Author

I understand the need for backwards compatibility; that is why I put all my code in a Restriction2 module so that the old Restriction module can stay.
My __len__-fixing commit actually does very little: the only interesting line is on line 2408 of the new Restriction.py; the rest is only a matter of moving all the initialization to a single function so that the module globals can then be cleaned up simply with del create_types instead of del'ing each name one by one (the old code didn't actually clean every thing, e.g. newenz showed up in the module dir).
I think the design of the current module is unpythonic, to say the least. It seems like the correct way to store all these enzyme properties (overhang type, overhang sequence, etc) is to put them either in instance attributes or python properties. Having accessor functions feels very Java to me (on the other hand there is no MI in Java so I wonder where did Frédéric get the idea of such a module design...).
I have (quickly) read the CircularSeq thread on the mailing list but we can move the discussion to the mailing list, as you suggest.

@peterjc

peterjc commented Dec 5, 2013

Copy link
Copy Markdown
Member

Bundling the REBASE files Bio/Restriction2/emboss_e.txt into our repository is problematic from a copyright and licensing perspective (I don't think we can do that). The old code's solution of storing a Python file generated from the REBASE files was possibly on shaky ground too.

As I understand it, EMBOSS fetches these files from the ftp://ftp.neb.com/pub/rebase/ via their tool http://emboss.sourceforge.net/apps/release/6.5/emboss/apps/rebaseextract.html with the aim of sidestepping distributing the raw data. From a legal perspective this seems safer (but a bit more complicated).

@anntzer

anntzer commented Dec 5, 2013

Copy link
Copy Markdown
Contributor Author

Superseded by #268.

@anntzer anntzer closed this Dec 5, 2013
@anntzer
anntzer deleted the restriction branch August 22, 2023 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants