[Biojava-l] AnnotationDB
Matthew Pocock
matthew_pocock at yahoo.co.uk
Wed Mar 5 22:59:18 EST 2003
Kenny Yu wrote:
> I wonder why org.biojava.bio.annodb.AnnotationDB doesn't have a findById(String id) method. As it stands now, each time I need to find an anotatin, I have to loop through all the annotations. In general, we have to assume that they don't fit into the JVM memory. Then lookups are simply impractical on large set of annotations.
>
> _______________________________________________
> Biojava-l mailing list - Biojava-l at biojava.org
> http://biojava.org/mailman/listinfo/biojava-l
>
Annotations themselves don't have any real concept of magical properties
like ID. To pull out annotations by ID, do something like this:
AnnotationDB annoDB = ...;
AnnotationType searcher = new AnnotationType.Impl();
searcher.setConstraint(
"ID",
new CollectionConstraint.AllValuesIn(
new PropertyConstraint.Equals(theID),
Cardinality.ONE
)
);
AnnotationDB hits = annoDB.filter(searcher);
for(Iterator i = hits.iterator(); i.hasNext(); ) {
/// do stuff with hits
}
Looking at this in the cold light of day, it's obvious that the API for
building AnnotationType objects needs sliming substantialy. Mmm.
Matthew
--
BioJava Consulting LTD - Support and training for BioJava
http://www.biojava.co.uk
More information about the Biojava-l
mailing list