[Biojava-l] Non-Deterministic behaviour of the FeatureFilter-Walker !?

Benjamin Schuster-Boeckler benjamins at Biomax.de
Wed Jan 14 04:18:41 EST 2004


I witness a _very_ weird problem executing my code. I have a class 
called FilterHandler that implements org.biojava.utils.walker.Visitor 
and is used in conjunction with FilterUtils.visitFilter(). I added some 
debuging-output to the each handling method just to see what's  going 
on. So normally I get this:

------------------------------ snip ------------------------------
DEBUG das.ContigSequence - filter - And(And(ByType(orf) , 
Not(ByAncestor(ByClass(org.biojava.bio.seq.ComponentFeature)))) , 
Overlaps([1,1000000])), recurse=true
DEBUG das.FilterHandler - byType - orf
DEBUG das.FilterHandler - byClass - org.biojava.bio.seq.ComponentFeature
DEBUG das.FilterHandler - byAncestor - ByAncestor
DEBUG das.FilterHandler - not - Not
DEBUG das.FilterHandler - and - And
DEBUG das.FilterHandler - overlapsLocation - [1, 1000000]
DEBUG das.FilterHandler - and - And
------------------------------ snap ------------------------------

This is fine. The first line is simply filter.toString() before I pass 
the filter to the visitFilter method.
Now for some reason, and I can't tell when actually, I get that:

------------------------------ snip ------------------------------
DEBUG das.ContigSequence - filter - And(And(ByType(orf) , 
Not(ByAncestor(ByClass(org.biojava.bio.seq.ComponentFeature)))) , 
Overlaps([1,1000000])), recurse=true
WARN  das.FilterHandler - and - Seems like some Filter was not evaluated!
DEBUG das.FilterHandler - and - And
------------------------------ snap ------------------------------

The warning is of course my own code, it just triggers if And was called 
without any other filters evaluated beforehand. It seems like the filter 
is not beeing processed, just the outer 'and' but nothing else. Any clue 
how this can be? I don't seem to get any error messages, too. I'll 
attach the handler method at the end of the file.

Thanks in advance,

Benjamin

------------------------------ snip ------------------------------
public final class FilterHandler implements 
org.biojava.utils.walker.Visitor {

    private Logger logger; //the log4j-logger to write to
    private Stack query; //keep track of recent calls
    private List types; //in case we have ByType queries
    private Location boundaries;
    private boolean isComponentQuery;

    public FilterHandler() {
        this.logger = Logger.getLogger(FilterHandler.class); //tell 
logger the name of this class
        query = new Stack(); //the query is still empty"
        types = new Vector(); //no types to look for, yet...
        isComponentQuery = false; //we don't look for structural 
features, do we?
    }
   
    public void and( FeatureFilter.And ffa ) {
        try{
            query.pop();
            query.pop();
        } catch(EmptyStackException e) {
            logger.warn("Seems like some Filter was not evaluated!", e);
        }
        query.push("and");
        logger.debug("And");
    }

    public void or( FeatureFilter.Or ffo ) {
        try{
            query.pop();
            query.pop();
        } catch(EmptyStackException e) {
            logger.warn("Seems like some Filter was not evaluated!", e);
        }
        query.push("or");
        logger.debug("Or");
    }

    public void not( FeatureFilter.Not ffn ) {
        try {
            if((String)query.pop() == "byAncestor")
                if((String)query.pop() == "byClass")
                    if(isComponentQuery) isComponentQuery = false;
        } catch(EmptyStackException e) {
            logger.warn("This was not the usual case of 'not'!", e);
        }
        query.push("not");
        logger.debug("Not");
    }

    public void byAncestor( FeatureFilter.ByAncestor ffb ) {
        query.push("byAncestor");
        logger.debug("ByAncestor");
    }

    public void byClass( FeatureFilter.ByClass ffc ) {
        query.push("byClass");
        if(ffc.getTestClass().getName().indexOf("ComponentFeature")>=0) 
isComponentQuery = true;
        logger.debug(ffc.getTestClass().getName());
    }

    public void byType( FeatureFilter.ByType fft ) {
        query.push("byType");
        types.add(fft.getType());
        logger.debug(fft.getType());
    }

    public void overlapsLocation( FeatureFilter.OverlapsLocation ffo ) {
        query.push("overlapsLocation");
        boundaries = ffo.getLocation();
        logger.debug("["+ffo.getLocation().getMin()+", 
"+ffo.getLocation().getMax()+"]");
    }
------------------------------ snap ------------------------------



More information about the Biojava-l mailing list