All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.bio.seq.pattern.NucleotidePatternMatch Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.bio.seq.pattern;

import java.util.Comparator;

import com.hfg.bio.Strand;
import com.hfg.bio.seq.SeqLocation;
import com.hfg.util.CompareUtil;

//------------------------------------------------------------------------------
/**
 Container for a nucleotide pattern match.
 
@author J. Alex Taylor, hairyfatguy.com
*/ //------------------------------------------------------------------------------ // com.hfg Library // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com // [email protected] //------------------------------------------------------------------------------ public class NucleotidePatternMatch extends SeqPatternMatch { private Strand mStrand; public static final Comparator LOCATION_COMPARATOR = new NucleotidePatternMatch().new LocationComparator(); //########################################################################### // CONSTRUCTORS //########################################################################### //-------------------------------------------------------------------------- private NucleotidePatternMatch() { } //-------------------------------------------------------------------------- public NucleotidePatternMatch(NucleotidePattern inPattern, String inSeq, SeqLocation inLocation) { super(inPattern, inSeq, inLocation); } //########################################################################### // PUBLIC METHODS //########################################################################### //-------------------------------------------------------------------------- @Override public boolean equals(Object inObj2) { boolean result = false; if (inObj2 instanceof NucleotidePatternMatch) { NucleotidePatternMatch match2 = (NucleotidePatternMatch) inObj2; if (getPattern().equals(match2.getPattern()) && getSeqLocation().equals(match2.getSeqLocation()) && 0 == CompareUtil.compare(getStrand(), match2.getStrand())) { result = true; } } return result; } //-------------------------------------------------------------------------- @Override public int hashCode() { int result = super.hashCode(); if (getStrand() != null) { result += 31 * getStrand().hashCode(); } return result; } //-------------------------------------------------------------------------- @Override public NucleotidePattern getPattern() { return (NucleotidePattern) super.getPattern(); } //-------------------------------------------------------------------------- public NucleotidePatternMatch setSequence(String inValue) { return (NucleotidePatternMatch) super.setSequence(inValue); } //-------------------------------------------------------------------------- public NucleotidePatternMatch setStrand(Strand inValue) { mStrand = inValue; return this; } //-------------------------------------------------------------------------- public Strand getStrand() { return mStrand; } private class LocationComparator implements Comparator { //-------------------------------------------------------------------------- public int compare(NucleotidePatternMatch inObj1, NucleotidePatternMatch inObj2) { return CompareUtil.compare(inObj1.getSeqLocation(), inObj2.getSeqLocation()); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy