[Biojava-dev] Test failed for Alphabet.getSymbolMatchType method

pprun pzgyuanf at gmail.com
Sat Oct 25 14:00:17 UTC 2008


Hi,
The current implementation uses the same condition equalsIgnoreCase for
EXACT_STRING_MATCH and MIXED_CASE_MATCH


public SymbolMatchType getSymbolMatchType(Symbol a, Symbol b) {
...
if (a.toString().equalsIgnoreCase(b.toString())) {
return SymbolMatchType.EXACT_STRING_MATCH;
}
if (a.toString().equalsIgnoreCase(b.toString())) {
return SymbolMatchType.MIXED_CASE_MATCH;
}
...

String.equals should be used for EXACT_STRING_MATCH:

public SymbolMatchType getSymbolMatchType(Symbol a, Symbol b) {
...
if (a.toString().equals(b.toString())) {
return SymbolMatchType.EXACT_STRING_MATCH;
}
if (a.toString().equalsIgnoreCase(b.toString())) {
return SymbolMatchType.MIXED_CASE_MATCH;
}
...

The test case used to identify the above bug is:

/*
* BioJava development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
* For more information on the BioJava project and its aims,
* or to join the biojava-l mailing list, visit the home page
* at:
*
* http://www.biojava.org/
*
*/
package org.biojava.core.symbol;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
*
* @author pprun
*/
public class AlphabetTest {

public AlphabetTest() {
}

@BeforeClass
public static void setUpClass() throws Exception {
}

@AfterClass
public static void tearDownClass() throws Exception {
}

@Before
public void setUp() {
}

@After
public void tearDown() {
}

/**
* Test of getSymbolMatchType method, of class Alphabet.
*/
@Test
public void testGetSymbolMatchType() {
System.out.println("getSymbolMatchType");

Alphabet testAlphabet = new Alphabet("testGetSymbolMatchType");

// 1. exact match
Symbol a = Symbol.get("ATGC");
Symbol b = Symbol.get("ATGC");
SymbolMatchType expResult = SymbolMatchType.EXACT_MATCH;
SymbolMatchType result = testAlphabet.getSymbolMatchType(a, b);
assertEquals(expResult, result);

// 2. mixed case match
a = Symbol.get("ATGC");
b = Symbol.get("aTGC");
expResult = SymbolMatchType.MIXED_CASE_MATCH;
result = testAlphabet.getSymbolMatchType(a, b);
assertEquals(expResult, result);
}
}


BTW., how can I get the dev/test role?
Then I can contribute to the development or test (as I'm still a
beginner for bio field) for BJ3.

Thanks,
Pprun




More information about the biojava-dev mailing list