[Biojava-l] Having problems using biojava regex.

Charles Danko dankoc at gmail.com
Thu Mar 15 02:20:54 UTC 2007


Thank worked!  I had no idea it would matter!

Thanks very much for the response!

Charles

On 3/14/07, Mark Schreiber <markjschreiber at gmail.com> wrote:
>
> Hi -
>
> From memory everything should be lower case. BioJava always represents DNA
> as lowercase and protein as upper case as per convention.
>
> Try that.
>
> - Mark
>
>
> On 3/15/07, Charles Danko <dankoc at gmail.com> wrote:
>
> > Hi,
> >
> > I'm having problems using the biojava regex classes.
> >
> > According to my understanding, the code posted below is the simplest
> > possible example of this class.
> >
> > However, my output is:
> > TAG
> > false
> > 0
> > TAG
> >
> > The TAG, TAG part of the output is for pattern.patternAsString() and
> > occurence.pattern().patternAsString().  As I understand it, both of
> > these
> > are correct, leading me to believe that both the Pattern and Matcher
> > objects
> > are being created correctly.  However, occurences.find() = false and
> > occurences.groupCount() = 0 ... meaning it's not finding any matches!?
> >
> > Where am I going wrong?
> >
> > Many thanks!
> > Charles
> >
> > import org.biojava.bio.*;
> > import org.biojava.bio.seq.*;
> > import org.biojava.bio.symbol.*;
> > import org.biojava.utils.regex.*;
> > import java.util.* ;
> > import java.io.*;
> >
> > public class Ambiguity2 {
> > public static void main(String[] args) {
> >    try {
> >        FiniteAlphabet IUPAC = DNATools.getDNA();
> >
> >        // Create pattern using pattern factory.
> >        Pattern pattern;
> >        PatternFactory FACTORY = PatternFactory.makeFactory(IUPAC);
> >        try{
> >            pattern = FACTORY.compile("TAG");
> >        } catch(Exception e) {e.printStackTrace(); return;}
> >        System.out.println(pattern.patternAsString());
> >
> >        // Variables needed...
> >        Matcher occurences;
> >
> >        // Promoter & Element
> >        Element WorkingElement = new Element("ElementName");
> >        SymbolList WorkingPromoter = DNATools.createDNA
> > ("TAGAGATAGACGATAGC");
> >
> >        // Obtain iterator of patterns.
> >        try {
> >            occurences = pattern.matcher( WorkingPromoter );
> >        } catch(Exception e) {e.printStackTrace(); return;}
> >        System.out.println(occurences.find());
> >        System.out.println(occurences.groupCount());
> >        System.out.println(occurences.pattern().patternAsString());
> >        // Foreach match
> >        while( occurences.find() ) {
> >                // Create Occurence object using information from
> > patterns.
> >            System.out.println("Match: " +"\t"+ WorkingPromoter +"\n"+
> > occurences.start() +"\t"+ occurences.group().seqString());
> >        }
> >    }
> >
> >    catch (Exception ex) {
> >      ex.printStackTrace();
> >    }
> > }
> > }
> > _______________________________________________
> > Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
> > http://lists.open-bio.org/mailman/listinfo/biojava-l
> >
>
>



More information about the Biojava-l mailing list