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 - [email protected]
http://lists.open-bio.org/mailman/listinfo/biojava-l