[Biojava-l] comparison for exact sequence match

Schreiber, Mark mark.schreiber@agresearch.co.nz
Tue, 9 Jul 2002 10:15:47 +1200


Hi -

The following would be the prescribed way to test for an exact match:

    public static boolean compareSymbolLists(SymbolList sl1,
					     SymbolList sl2)
    {
	if (sl1.length() != sl2.length()) {
	    return false;
	}
	
	Iterator si1 = sl1.iterator();
	Iterator si2 = sl2.iterator();
	while (si1.hasNext()) {
	    if (! (si1.next() == si2.next())) {
		return false;
	    }
	}

	return true;
    }


Interestingly the equals() method of AbstractSymbolList has never been
overridden (to my knowledge) and cannot be used. I can't see anyreason
why it couldn't be overridden as long as the hashCode() method is
overridden.

I don't see any reason why your toList() workaround should't work. Give
it a try and let us know.

- Mark


> -----Original Message-----
> From: david.jackson@arrowt.co.uk [mailto:david.jackson@arrowt.co.uk] 
> Sent: Monday, 8 July 2002 7:46 p.m.
> To: biojava-l@biojava.org
> Subject: [Biojava-l] comparison for exact sequence match
> 
> 
> Hi - is the best way to compare two SymbolList objects
> to see if they represent the same sequence,
> 	mySL1.toList().equals(mySL2.toList())
> 
> (so if I want to use a sequence as a key in a Map I could
> use the SymbolList.toList() )?
> 
> thanks,
> david
> 
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l@biojava.org 
> http://biojava.org/mailman/listinfo/biojava-l
> 
=======================================================================
Attention: The information contained in this message and/or attachments
from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the
sender immediately.
=======================================================================