001package com.hfg.bio.seq.pattern;
002
003import com.hfg.bio.seq.SeqLocation;
004
005//------------------------------------------------------------------------------
006/**
007 Container for a sequence pattern match.
008 <div>
009 @author J. Alex Taylor, hairyfatguy.com
010 </div>
011 */
012//------------------------------------------------------------------------------
013// com.hfg Library
014//
015// This library is free software; you can redistribute it and/or
016// modify it under the terms of the GNU Lesser General Public
017// License as published by the Free Software Foundation; either
018// version 2.1 of the License, or (at your option) any later version.
019//
020// This library is distributed in the hope that it will be useful,
021// but WITHOUT ANY WARRANTY; without even the implied warranty of
022// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
023// Lesser General Public License for more details.
024//
025// You should have received a copy of the GNU Lesser General Public
026// License along with this library; if not, write to the Free Software
027// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
028//
029// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
030// jataylor@hairyfatguy.com
031//------------------------------------------------------------------------------
032
033public abstract class SeqPatternMatch
034{
035   private SeqPattern   mPattern;
036   private String       mSequence;
037   private SeqLocation  mSeqLocation;
038   private int          mNumMismatches;
039
040   //###########################################################################
041   // CONSTRUCTORS
042   //###########################################################################
043
044   //--------------------------------------------------------------------------
045   protected SeqPatternMatch()
046   {
047
048   }
049
050   //--------------------------------------------------------------------------
051   public SeqPatternMatch(SeqPattern inPattern, String inSeq, SeqLocation inLocation)
052   {
053      mPattern = inPattern;
054      mSequence = inSeq;
055      mSeqLocation = inLocation;
056   }
057
058   //###########################################################################
059   // PUBLIC METHODS
060   //###########################################################################
061
062   //--------------------------------------------------------------------------
063   @Override
064   public String toString()
065   {
066      return mSequence + " " + mSeqLocation;
067   }
068
069   //--------------------------------------------------------------------------
070   @Override
071   public boolean equals(Object inObj2)
072   {
073      boolean result = false;
074
075      if (inObj2 instanceof SeqPatternMatch)
076      {
077         SeqPatternMatch match2 = (SeqPatternMatch) inObj2;
078
079         if (getPattern().equals(match2.getPattern())
080               && getSeqLocation().equals(match2.getSeqLocation()))
081         {
082            result = true;
083         }
084      }
085
086      return result;
087   }
088
089   //--------------------------------------------------------------------------
090   @Override
091   public int hashCode()
092   {
093      int result = getPattern().hashCode();
094
095      result += 31 * getSeqLocation().hashCode();
096
097      return result;
098   }
099
100   //--------------------------------------------------------------------------
101   public SeqPattern getPattern()
102   {
103      return mPattern;
104   }
105
106
107   //--------------------------------------------------------------------------
108   public String getSequence()
109   {
110      return mSequence;
111   }
112
113   //--------------------------------------------------------------------------
114   public SeqPatternMatch setSequence(String inValue)
115   {
116      mSequence = inValue;
117      return this;
118   }
119
120   //--------------------------------------------------------------------------
121   public SeqLocation getSeqLocation()
122   {
123      return mSeqLocation;
124   }
125
126
127   //--------------------------------------------------------------------------
128   public SeqPatternMatch setNumMismatches(int inValue)
129   {
130      mNumMismatches = inValue;
131      return this;
132   }
133
134   //--------------------------------------------------------------------------
135   public int getNumMismatches()
136   {
137      return mNumMismatches;
138   }
139
140
141}