org.biojava.bio.search
Class SimpleSeqSimilaritySearchHit

java.lang.Object
  extended by org.biojava.utils.AbstractChangeable
      extended by org.biojava.bio.search.SimpleSeqSimilaritySearchHit
All Implemented Interfaces:
Annotatable, SeqSimilaritySearchHit, Changeable

public class SimpleSeqSimilaritySearchHit
extends AbstractChangeable
implements SeqSimilaritySearchHit

SimpleSeqSimilaritySearchHit objects represent a similarity search hit of a query sequence to a sequence referenced in a SequenceDB object. The core data (score, E-value, P-value) have accessors, while supplementary data are stored in the Annotation object. Supplementary data are typically the more loosely formatted details which vary from one search program to another (and between versions of those programs).

It is up to the user to define the meaning of the hit's query/subject start/end/strand with respect to its constituent sub-hits. One approach could be:

Since:
1.1
Author:
Keith James, Gerald Loeffler
See Also:
AbstractChangeable, SeqSimilaritySearchHit, Annotatable

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.biojava.bio.search.SeqSimilaritySearchHit
SeqSimilaritySearchHit.ByScoreComparator, SeqSimilaritySearchHit.BySubHitCountComparator
 
Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
Annotatable.AnnotationForwarder
 
Field Summary
protected  ChangeForwarder annotationForwarder
           
 
Fields inherited from interface org.biojava.bio.search.SeqSimilaritySearchHit
byScore, bySubHitCount
 
Fields inherited from interface org.biojava.bio.Annotatable
ANNOTATION
 
Constructor Summary
SimpleSeqSimilaritySearchHit(double score, double eValue, double pValue, int queryStart, int queryEnd, StrandedFeature.Strand queryStrand, int subjectStart, int subjectEnd, StrandedFeature.Strand subjectStrand, String subjectID, Annotation annotation, List subHits)
          Creates a new SimpleSeqSimilaritySearchHit object.
 
Method Summary
 boolean equals(Object other)
           
 Annotation getAnnotation()
          getAnnotation returns the Annotation associated with this hit.
protected  ChangeSupport getChangeSupport(ChangeType ct)
          Called to retrieve the ChangeSupport for this object.
 double getEValue()
          Return the overall E-value of this hit.
 double getPValue()
          Return the overall P-value of this hit.
 int getQueryEnd()
          Return the end position of the last sub-hit in the query sequence.
 int getQueryStart()
          Return the start position of the first sub-hit in the query sequence.
 StrandedFeature.Strand getQueryStrand()
          Return the strand of the hit with respect to the query sequence.
 double getScore()
          Return the overall score of this hit in the units defined by the search algorithm.
 List getSubHits()
          Return all sub-hits for this sequence similarity search hit.
 int getSubjectEnd()
          Return the end position of the last sub-hit in the subject sequence.
 String getSubjectID()
          The sequence identifier of this hit within the sequence database against which the search was performed.
 int getSubjectStart()
          Return the start position of the first sub-hit in the subject sequence.
 StrandedFeature.Strand getSubjectStrand()
          Return the strand of the sub-hit with respect to the subject sequence.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
 

Field Detail

annotationForwarder

protected transient ChangeForwarder annotationForwarder
Constructor Detail

SimpleSeqSimilaritySearchHit

public SimpleSeqSimilaritySearchHit(double score,
                                    double eValue,
                                    double pValue,
                                    int queryStart,
                                    int queryEnd,
                                    StrandedFeature.Strand queryStrand,
                                    int subjectStart,
                                    int subjectEnd,
                                    StrandedFeature.Strand subjectStrand,
                                    String subjectID,
                                    Annotation annotation,
                                    List subHits)
Creates a new SimpleSeqSimilaritySearchHit object.

Parameters:
score - a double value; the score of the hit, which may not be NaN.
eValue - a double value; the E-value of the hit, which may be NaN.
pValue - a double value; the P-value of the hit, which may be NaN.
queryStart - the start of the first sub-hit on the query sequence.
queryEnd - the end of the last sub-hit on the query sequence.
queryStrand - the strand of the sub-hits on the query sequence, which may be null for protein similarities. If they are not all positive or all negative, then this should be the unknown strand.
subjectStart - the start of the first sub-hit on the subject sequence.
subjectEnd - the end of the last sub-hit on the subject sequence.
subjectStrand - the strand of the sub-hits on the subject sequence, which may be null for protein similarities. If they are not all positive or all negative, then this should be the unknown strand.
subjectID - a String representing the ID in the SequenceDB of the sequence which was hit, which may not be null.
annotation - an Annotation object, which may not be null.
subHits - a List object containing the subhits, which may not be null. They should be sorted in the order specified by the search program.
Method Detail

getScore

public double getScore()
Description copied from interface: SeqSimilaritySearchHit
Return the overall score of this hit in the units defined by the search algorithm.

Specified by:
getScore in interface SeqSimilaritySearchHit
Returns:
the overall score of this hit. This is a mandatory piece of information and hence may not be NaN.

getPValue

public double getPValue()
Description copied from interface: SeqSimilaritySearchHit
Return the overall P-value of this hit.

Specified by:
getPValue in interface SeqSimilaritySearchHit
Returns:
the overall P-value of this hit. This is an optional (but desired) piece of information and implementations of this interface may return NaN if a P-value is not available for this hit.

getEValue

public double getEValue()
Description copied from interface: SeqSimilaritySearchHit
Return the overall E-value of this hit.

Specified by:
getEValue in interface SeqSimilaritySearchHit
Returns:
the overall E-value of this hit. This is an optional (but desired) piece of information and implementations of this interface may return NaN if an E-value is not available for this hit.

getQueryStart

public int getQueryStart()
Description copied from interface: SeqSimilaritySearchHit
Return the start position of the first sub-hit in the query sequence.

Specified by:
getQueryStart in interface SeqSimilaritySearchHit
Returns:
an int.

getQueryEnd

public int getQueryEnd()
Description copied from interface: SeqSimilaritySearchHit
Return the end position of the last sub-hit in the query sequence.

Specified by:
getQueryEnd in interface SeqSimilaritySearchHit
Returns:
an int.

getQueryStrand

public StrandedFeature.Strand getQueryStrand()
Description copied from interface: SeqSimilaritySearchHit
Return the strand of the hit with respect to the query sequence. If the sub-hits are not all on the same strand this should return the unknown strand. This may be null for protein sequences.

Specified by:
getQueryStrand in interface SeqSimilaritySearchHit
Returns:
a Strand.

getSubjectStart

public int getSubjectStart()
Description copied from interface: SeqSimilaritySearchHit
Return the start position of the first sub-hit in the subject sequence.

Specified by:
getSubjectStart in interface SeqSimilaritySearchHit
Returns:
an int.

getSubjectEnd

public int getSubjectEnd()
Description copied from interface: SeqSimilaritySearchHit
Return the end position of the last sub-hit in the subject sequence.

Specified by:
getSubjectEnd in interface SeqSimilaritySearchHit
Returns:
an int.

getSubjectStrand

public StrandedFeature.Strand getSubjectStrand()
Description copied from interface: SeqSimilaritySearchHit
Return the strand of the sub-hit with respect to the subject sequence. If the sub-hits are not all on the same strand this should return the unknown strand. This may be null for protein sequences.

Specified by:
getSubjectStrand in interface SeqSimilaritySearchHit
Returns:
a Strand.

getSubjectID

public String getSubjectID()
Description copied from interface: SeqSimilaritySearchHit
The sequence identifier of this hit within the sequence database against which the search was performed.

Specified by:
getSubjectID in interface SeqSimilaritySearchHit
Returns:
the (unique) sequence identifier for this hit, valid within the sequence database against which this search was performed. Never returns null.

getSubHits

public List getSubHits()
Description copied from interface: SeqSimilaritySearchHit
Return all sub-hits for this sequence similarity search hit. The sub-hits contain concrete alignments (and scores) for sequence stretches from the sequence of this hit. The sub-hits in the list returned by this method are sorted from best to worst.

Specified by:
getSubHits in interface SeqSimilaritySearchHit
Returns:
a List of SeqSimilaritySearchSubHit objects containing all sub-hits for this hit. Never returns null and the List is guaranteed to contain at least one entry.

getAnnotation

public Annotation getAnnotation()
getAnnotation returns the Annotation associated with this hit.

Specified by:
getAnnotation in interface Annotatable
Returns:
an Annotation.

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

getChangeSupport

protected ChangeSupport getChangeSupport(ChangeType ct)
Description copied from class: AbstractChangeable
Called to retrieve the ChangeSupport for this object.

Your implementation of this method should have the following structure:

 ChangeSupport cs = super.getChangeSupport(ct);

 if(someForwarder == null && ct.isMatching(SomeInterface.SomeChangeType)) {
   someForwarder = new ChangeForwarder(...

   this.stateVariable.addChangeListener(someForwarder, VariableInterface.AChange);
 }

 return cs;
 
It is usual for the forwarding listeners (someForwarder in this example) to be transient and lazily instantiated. Be sure to register & unregister the forwarder in the code that does the ChangeEvent handling in setter methods.

Overrides:
getChangeSupport in class AbstractChangeable