[Biojava-l] Restriction digest progess

Keith James kdj@sanger.ac.uk
02 Jul 2002 10:18:24 +0100


I've had some free time to get started on this. Here's a summary of
what is currently checked in:

org.biojava.bio.symbol.MotifTools

This is another support class which contains static methods (well,
just one right now). String createRegex(SymbolList motif) will create
a regular expression String from a SymbolList, including ambiguities:

e.g. AANNNTGG returns A{2}[ACTG]{3}TG{2}

This should work for all finite alphabets.

This class is used by RestrictionEnzyme (see below) to create regex
Strings for the forward and reverse strand recognition sites.

There is a new package molbio alongside the proteomics package.

org.biojava.bio.molbio.RestrictionEnzyme

This class specifies restriction enzyme properties (recognition site,
cut site(s), type of end produced) and also returns regex Strings
suitable for finding forward and reverse strand recognition sites.

The constructors are public so that you can create custom enzymes, but
the main way to get instances is through the RestrictionEnzymeManager.

org.biojava.bio.molbio.RestrictionEnzymeManager

This class is allows you to get an enzyme by name, get all
isoschizomers of an enzyme by name, get all n-cutters and get a pair
of java.util.regex.Patterns for the forward and reverse strand
sites. There is a properties file
(RestrictionEnzymeManager.properties) which is loaded as a
ResourceBundle and tells the class where to find a REBASE file
(withrefm.### format, same format as used by EMBOSS program
rebaseextract - see REBASE site). I have not checked in a fallback
copy of REBASE - it's quite big and I wanted to get some feedback
first. Do we want the whole of a specific version of REBASE, or just a
subset of common enzymes? Anyone can override this by using their own
copy of REBASE and putting a new properties file in their CLASSPATH.

The part which is only partly implemented is searching. You can now
do searches using

org.biojava.bio.seq.io.SymbolListCharSequence

This class is an implementation of the Java 1.4 interface
CharSequence. It wraps a SymbolList and allows full regex seaching of
any SymbolList whose Symbols can be tokenized to chars. It appears
that the regex Matcher does not call the subSequence or toString
methods, only charAt (which translates directly to symbolAt) so no
extra copies of a big sequence get made. You need to use the regex
engine in Java 1.4

Finally there's stuff to do:

org.biojava.bio.molbio.RestrictionDigest

Is not written. This will do the convenience stuff of spitting out
SymbolList products etc. It should probably be threaded to search
multiple enzymes (or at least both strands for one enzyme)
simultaneously.

One thing I'm not clear on. Do we want "biologically correct"
cutting. That is, if my sequence has two different enzyme sites which
overlap and I do sequential digests, does the second fail to cut
because its site is now partly single-stranded, even though the regex
still matches on one strand? It seems the right way to me, but it may
not to to everyone.

In summary, you can currently do full ambiguity searches on both
strands with a bit of work.

1. Get a copy of REBASE format #31
2. Edit the RestrictionEnzymeManager.properties file to point to it

Do something like this:

RestrictionEnzyme ecoRI = RestrictionEnzymeManager.getEnzyme("EcoRI");
Pattern [] pat = RestrictionEnzymeManager.getPatterns(ecoRI);

CharSequence charSeq = new SymbolListCharSequence(mySymbolList);

Matcher forward = pat[0].matcher(charSeq);
Matcher reverse = pat[1].matcher(charSeq);

Then proceed to use the Matcher as normal. Right now the coordinate
you get back will be the start of the recognition site and you will
have to calculate the actual cut(s). There are methods in
RestrictionEnzyme which return the position(s) of the cut site in the
coordinate space of the recognition site SymbolList (there are some
freaky enzymes which cut both sides of their recognition site).

Please report bugs (or better still, add a test case which fails
because of the bug). Enjoy.

Keith

-- 

-= Keith James - kdj@sanger.ac.uk - http://www.sanger.ac.uk/Users/kdj =-
Pathogen Sequencing Unit, Wellcome Trust Sanger Institute, Cambridge, UK