apollo.datamodel
Class AbstractSequence

java.lang.Object
  extended by apollo.datamodel.AbstractSequence
All Implemented Interfaces:
SequenceI, java.io.Serializable
Direct Known Subclasses:
AbstractLazySequence, Sequence

public abstract class AbstractSequence
extends java.lang.Object
implements SequenceI

See Also:
Serialized Form

Field Summary
protected  java.util.HashMap genomic_errors
          allow for some adjustments if the genomic sequence has sequencing errors
protected  RangeI genomicRange
           
protected  int length
           
 
Fields inherited from interface apollo.datamodel.SequenceI
AA, CLEAR_EDIT, DELETION, DNA, INSERTION, RNA, SUBSTITUTION
 
Constructor Summary
AbstractSequence(java.lang.String id)
           
 
Method Summary
 void addDbXref(DbXref xref)
           
 void addDbXref(java.lang.String db, java.lang.String acc)
           
 void addDbXref(java.lang.String db, java.lang.String acc, int isCurrent)
           
 boolean addSequenceEdit(SequenceEdit seq_edit)
           
 boolean addSequencingErrorPosition(java.lang.String operation, int pos, java.lang.String residue)
          The position of the genomic sequencing error is in genomic coordinates.
 void clearResidues()
          sets residues to empty string
 java.lang.String getAccessionNo()
           
 char getBaseAt(int loc)
           
 java.lang.String getChecksum()
           
 java.util.Vector getDbXrefs()
           
 java.lang.String getDescription()
           
 int getFrame(long base, boolean forward)
          This returns frame as 0, 1, or 2 (not 1,2,3)
 java.util.HashMap getGenomicErrors()
           
 int getLength()
           
 java.lang.String getName()
           
 java.lang.String getOrganism()
           
 RangeI getRange()
           
 java.lang.String getResidues()
           
 java.lang.String getResidues(int start, int end)
          returns substring of sequence residues, all of this apollo stuff is counting from 1 -not- 0
protected abstract  java.lang.String getResiduesImpl(int start)
           
protected abstract  java.lang.String getResiduesImpl(int start, int end)
           
 java.lang.String getResidueType()
          Returns null if never set.
 java.lang.String getReverseComplement()
           
 SequenceEdit getSequencingErrorAtPosition(int base_position)
           
abstract  SequenceI getSubSequence(int start, int end)
          I can see this being a handy method but its actually not used at all - delete?
 boolean hasName()
          Return true if name is NO_NAME.
protected  boolean hasRange()
          Convenience for getRange null check
 boolean hasResidues()
          This will return false if getResidues() is null or "", clearResidues() will set residues to "" causing this to be false.
 boolean hasResidueType()
          Calculates residue type by comparing seq length to feat length.
 boolean isAA()
          convenience
 boolean isLazy()
          Cleanup dangling references when SequenceI not needed anymore.
 boolean isNewerThan(java.util.Date recentDate)
           
 boolean isSequenceAvailable(long position)
           
 boolean isSequencingErrorPosition(int base_position)
           
protected  boolean needInclusiveEnd()
          Whether the end needs adding to, to make it inclusive.
protected  boolean needShiftFromOneToZeroBasedCoords()
          Returns true if getRange()==null && needShiftFromOneToZeroBasedCoords is true (default is true).
protected  int pegLimits(int value)
          If getRange!=null, checks that value is in range, and if not then puts it in range.
 boolean removeSequenceEdit(SequenceEdit seqEdit)
           
 void setAccessionNo(java.lang.String acc)
           
 void setChecksum(java.lang.String checksum)
           
 void setDate(java.util.Date update_date)
           
 void setDescription(java.lang.String desc)
           
 void setLength(int length)
           
 void setName(java.lang.String name)
           
protected  void setNeedShiftFromOneToZeroBasedCoords(boolean needShift)
          Perhaps this is funny, but if we have a Range then shift wont happen regardless of what you set here.
 void setOrganism(java.lang.String organism)
           
 void setRange(RangeI loc)
          I (SUZ) am removing the call to setLength, because the length of the viewed range should not logically change the length of the sequence.
 void setResidues(java.lang.String seqString)
           
 void setResidueType(java.lang.String res_type)
           
protected  int shiftFromOneToZeroBased(int coord)
          This just subtracts one from coord to shift from one based(apollo) to zero based(java string) coord system.
 boolean usesGenomicCoords()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

length

protected int length

genomicRange

protected RangeI genomicRange

genomic_errors

protected java.util.HashMap genomic_errors
allow for some adjustments if the genomic sequence has sequencing errors

Constructor Detail

AbstractSequence

public AbstractSequence(java.lang.String id)
Method Detail

getLength

public int getLength()
Specified by:
getLength in interface SequenceI

setLength

public void setLength(int length)
Specified by:
setLength in interface SequenceI

setDescription

public void setDescription(java.lang.String desc)
Specified by:
setDescription in interface SequenceI

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in interface SequenceI

setChecksum

public void setChecksum(java.lang.String checksum)
Specified by:
setChecksum in interface SequenceI

getChecksum

public java.lang.String getChecksum()
Specified by:
getChecksum in interface SequenceI

addDbXref

public void addDbXref(java.lang.String db,
                      java.lang.String acc)
Specified by:
addDbXref in interface SequenceI

addDbXref

public void addDbXref(java.lang.String db,
                      java.lang.String acc,
                      int isCurrent)
Specified by:
addDbXref in interface SequenceI

addDbXref

public void addDbXref(DbXref xref)
Specified by:
addDbXref in interface SequenceI

getDbXrefs

public java.util.Vector getDbXrefs()
Specified by:
getDbXrefs in interface SequenceI

getBaseAt

public char getBaseAt(int loc)
Specified by:
getBaseAt in interface SequenceI

getSubSequence

public abstract SequenceI getSubSequence(int start,
                                         int end)
Description copied from interface: SequenceI
I can see this being a handy method but its actually not used at all - delete?

Specified by:
getSubSequence in interface SequenceI

getName

public java.lang.String getName()
Specified by:
getName in interface SequenceI

setName

public void setName(java.lang.String name)
Specified by:
setName in interface SequenceI

hasName

public boolean hasName()
Return true if name is NO_NAME. this is true if sequence constructed with null or empty string.

Specified by:
hasName in interface SequenceI

setRange

public void setRange(RangeI loc)
I (SUZ) am removing the call to setLength, because the length of the viewed range should not logically change the length of the sequence. This may have a negative effect if there is any code around that was assuming the length of the sequence would be set this way. When this happens the code should be changed to independently call seq.setLength() This was having very bad effects when the sequence length was already being set. Then when setRefSequence was called the length was being silently changed to 1 (because the range was not yet set) Then the range could no longer be set because the sequence length was 0. Ugh.

Specified by:
setRange in interface SequenceI

getRange

public RangeI getRange()
Specified by:
getRange in interface SequenceI

hasRange

protected boolean hasRange()
Convenience for getRange null check


getAccessionNo

public java.lang.String getAccessionNo()
Specified by:
getAccessionNo in interface SequenceI

setAccessionNo

public void setAccessionNo(java.lang.String acc)
Specified by:
setAccessionNo in interface SequenceI

setResidues

public void setResidues(java.lang.String seqString)
Specified by:
setResidues in interface SequenceI

clearResidues

public void clearResidues()
sets residues to empty string

Specified by:
clearResidues in interface SequenceI

hasResidues

public boolean hasResidues()
This will return false if getResidues() is null or "", clearResidues() will set residues to "" causing this to be false.

Specified by:
hasResidues in interface SequenceI

getResidues

public java.lang.String getResidues()
Specified by:
getResidues in interface SequenceI

getResidues

public final java.lang.String getResidues(int start,
                                          int end)
returns substring of sequence residues, all of this apollo stuff is counting from 1 -not- 0

Specified by:
getResidues in interface SequenceI

needInclusiveEnd

protected boolean needInclusiveEnd()
Whether the end needs adding to, to make it inclusive. EnsCGISequence does not need an inclusive end and overrides this to return false. I think inclusive end combined with need shift from zero to one based is actually capturing interbase vs base-oriented - i put these in before i knew of interbase - refactor - set/getInterbase(boolean)? default true?


setNeedShiftFromOneToZeroBasedCoords

protected void setNeedShiftFromOneToZeroBasedCoords(boolean needShift)
Perhaps this is funny, but if we have a Range then shift wont happen regardless of what you set here. This only applies if we have no range


needShiftFromOneToZeroBasedCoords

protected boolean needShiftFromOneToZeroBasedCoords()
Returns true if getRange()==null && needShiftFromOneToZeroBasedCoords is true (default is true). If AbsSeq has a range then the shift will be handled by the subclass dealing with the range(for now) (look into migrating range math to AbsSeq - it has been migrated i believe)


shiftFromOneToZeroBased

protected int shiftFromOneToZeroBased(int coord)
This just subtracts one from coord to shift from one based(apollo) to zero based(java string) coord system. Made this an explicit method for clarity sake.


pegLimits

protected int pegLimits(int value)
If getRange!=null, checks that value is in range, and if not then puts it in range. If no range then does check with 1 to length. If 0 based should override this (as jalview.datamodel.AlignSequence does) Get rid of begin/one->zero shift here - clever but opaque. This now expects coordinates to be one based or range based (not zero based) (it used to do the actual one->zero shifting) Zero based seqs need to override this mthod (see jalview.datamodel.AlignSeq)


getResiduesImpl

protected abstract java.lang.String getResiduesImpl(int start,
                                                    int end)

getResiduesImpl

protected abstract java.lang.String getResiduesImpl(int start)

getReverseComplement

public java.lang.String getReverseComplement()
Specified by:
getReverseComplement in interface SequenceI

isSequenceAvailable

public boolean isSequenceAvailable(long position)
Specified by:
isSequenceAvailable in interface SequenceI

getFrame

public int getFrame(long base,
                    boolean forward)
This returns frame as 0, 1, or 2 (not 1,2,3)

Specified by:
getFrame in interface SequenceI

getResidueType

public java.lang.String getResidueType()
Returns null if never set. Use calculateResFromFeatLength to come up with a res type based on feature length.

Specified by:
getResidueType in interface SequenceI

hasResidueType

public boolean hasResidueType()
Description copied from interface: SequenceI
Calculates residue type by comparing seq length to feat length. If there is more than 2 base pairs per residue than its assigned AA.

Specified by:
hasResidueType in interface SequenceI

isAA

public boolean isAA()
convenience

Specified by:
isAA in interface SequenceI

setResidueType

public void setResidueType(java.lang.String res_type)
Specified by:
setResidueType in interface SequenceI

usesGenomicCoords

public boolean usesGenomicCoords()
Specified by:
usesGenomicCoords in interface SequenceI

isLazy

public boolean isLazy()
Description copied from interface: SequenceI
Cleanup dangling references when SequenceI not needed anymore. Is this funny to have in SequenceI? (needed for AbstractLazySequence)

Specified by:
isLazy in interface SequenceI

isNewerThan

public boolean isNewerThan(java.util.Date recentDate)

setDate

public void setDate(java.util.Date update_date)
Specified by:
setDate in interface SequenceI

isSequencingErrorPosition

public boolean isSequencingErrorPosition(int base_position)
Specified by:
isSequencingErrorPosition in interface SequenceI

getSequencingErrorAtPosition

public SequenceEdit getSequencingErrorAtPosition(int base_position)
Specified by:
getSequencingErrorAtPosition in interface SequenceI

getGenomicErrors

public java.util.HashMap getGenomicErrors()
Specified by:
getGenomicErrors in interface SequenceI

addSequencingErrorPosition

public boolean addSequencingErrorPosition(java.lang.String operation,
                                          int pos,
                                          java.lang.String residue)
The position of the genomic sequencing error is in genomic coordinates. This is NOT for describing mutations or altering the genomic sequence. It simply accounts for errors in low quality sequence so that genes can be translated

Specified by:
addSequencingErrorPosition in interface SequenceI

addSequenceEdit

public boolean addSequenceEdit(SequenceEdit seq_edit)
Specified by:
addSequenceEdit in interface SequenceI

removeSequenceEdit

public boolean removeSequenceEdit(SequenceEdit seqEdit)
Specified by:
removeSequenceEdit in interface SequenceI

getOrganism

public java.lang.String getOrganism()
Specified by:
getOrganism in interface SequenceI

setOrganism

public void setOrganism(java.lang.String organism)
Specified by:
setOrganism in interface SequenceI