Skip to content
Snippets Groups Projects
Commit 9b8dfe6b authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when matching other target there was problem when no gene was defiend

parent e9ec958a
No related branches found
No related tags found
1 merge request!98Resolve "doubled results when searching for dugs"
...@@ -103,8 +103,17 @@ public class ElementMatcher { ...@@ -103,8 +103,17 @@ public class ElementMatcher {
return false; return false;
case OTHER: case OTHER:
// in other case just compare names // in other case just compare names
String name = target.getGenes().get(0).getResource(); String targetName = null;
return element.getName().equalsIgnoreCase(name); if (target.getGenes().size() > 0) {
targetName = target.getGenes().get(0).getResource();
}
if (targetName == null) {
targetName = target.getName();
}
if (targetName == null) {
return false;
}
return element.getName().equalsIgnoreCase(targetName);
default: default:
throw new InvalidArgumentException("Unknown drug target type: " + target.getType()); throw new InvalidArgumentException("Unknown drug target type: " + target.getType());
} }
......
...@@ -13,7 +13,8 @@ import lcsb.mapviewer.services.search.layout.AllSearchLayoutTests; ...@@ -13,7 +13,8 @@ import lcsb.mapviewer.services.search.layout.AllSearchLayoutTests;
@SuiteClasses({ AllCommentTests.class, // @SuiteClasses({ AllCommentTests.class, //
AllSearchDbTests.class, // AllSearchDbTests.class, //
AllSearchDataTests.class, // AllSearchDataTests.class, //
AllSearchLayoutTests.class,// AllSearchLayoutTests.class, //
ElementMatcherTest.class, //
}) })
public class AllSearchTests { public class AllSearchTests {
......
package lcsb.mapviewer.services.search; package lcsb.mapviewer.services.search;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.apache.log4j.Logger;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.AfterClass;
import org.junit.Test; import org.junit.Before;
import org.springframework.beans.factory.annotation.Autowired; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import lcsb.mapviewer.annotation.data.Chemical;
import lcsb.mapviewer.annotation.data.Target; import lcsb.mapviewer.annotation.data.Chemical;
import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.annotation.data.Target;
import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.annotation.data.TargetType;
import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.services.search.comment.FullCommentViewFactory; import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.services.search.db.DbSearchCriteria; import lcsb.mapviewer.model.map.species.Rna;
import lcsb.mapviewer.services.search.db.chemical.IChemicalService; import lcsb.mapviewer.services.ServiceTestFunctions;
import lcsb.mapviewer.services.search.db.DbSearchCriteria;
public class SearchResultFactoryTest extends ServiceTestFunctions {
public class ElementMatcherTest extends ServiceTestFunctions {
Logger logger = Logger.getLogger(SearchResultFactoryTest.class);
@Autowired
@Autowired ElementMatcher elementMatcher;
FullCommentViewFactory factory;
@AfterClass
@Autowired public static void tearDownAfterClass() throws Exception {
IChemicalService chemicalService; }
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
} }
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
} }
@Test @Test
public void testElementMatch() { public void testMatchOther() {
String geneName = "GDNF"; Target target = new Target();
Chemical view = chemicalService.getByName("Amphetamine", new DbSearchCriteria().disease(new MiriamData(MiriamType.MESH_2012, "D010300")));
Target target = null; target.setType(TargetType.OTHER);
for (Target t : view.getInferenceNetwork()) { assertFalse(elementMatcher.elementMatch(target, new GenericProtein("s1")));
for (MiriamData row : t.getGenes()) { }
if (row.getResource().equals(geneName)) {
target = t; @Test
} public void testElementMatch() {
} String geneName = "GDNF";
} Chemical view = chemicalService.getByName("Amphetamine", new DbSearchCriteria().disease(new MiriamData(MiriamType.MESH_2012, "D010300")));
Target target = null;
Element element = new Rna("id"); for (Target t : view.getInferenceNetwork()) {
element.setName(geneName); for (MiriamData row : t.getGenes()) {
if (row.getResource().equals(geneName)) {
assertTrue(factory.elementMatch(target, element)); target = t;
}
} }
}
}
Element element = new Rna("id");
element.setName(geneName);
assertTrue(elementMatcher.elementMatch(target, element));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment