From fcaf43ab48eb6840e8665cca2031119d9156d581 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Mon, 1 Jul 2019 21:26:08 +0200
Subject: [PATCH] search for drugs with rna components didn't work

---
 CHANGELOG                                         |  2 ++
 .../annotation/services/ChEMBLParser.java         | 15 +++++++++------
 .../annotation/services/ChEMBLParserTest.java     | 13 +++++++++++++
 3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 3ceaad7be8..e7624beee3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,8 @@ minerva (13.1.1) stable; urgency=medium
   * Bug fix: "Terms of Use" change to "Terms of Service" in all places (#843)
   * Bug fix: upgrade to 13.1.0 crashed on machines where every element was 
     inside compartment (#856)
+  * Bug fix: searching for some drugs in chembl didn't provide any results even 
+    though that data exists, for instance 'DORLIMOMAB ARITOX' (#842)
 
  -- Piotr Gawron <piotr.gawron@uni.lu>  Fri, 28 Jun 2019 17:00:00 +0200
 
diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChEMBLParser.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChEMBLParser.java
index 9b7e329224..3a7519a5f3 100644
--- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChEMBLParser.java
+++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/ChEMBLParser.java
@@ -256,12 +256,15 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService {
     MiriamData result = null;
     Node uniprotAccessionId = XmlParser.getNode("accession", targetComponent.getChildNodes());
     if (uniprotAccessionId != null) {
-      try {
-        result = uniprotAnnotator
-            .uniProtToHgnc(new MiriamData(MiriamType.UNIPROT, uniprotAccessionId.getTextContent()));
-        result.setAnnotator(null);
-      } catch (UniprotSearchException e) {
-        throw new DrugSearchException(e);
+      String uniprotId = uniprotAccessionId.getTextContent();
+      if (uniprotId != null && !uniprotId.isEmpty()) {
+        try {
+          result = uniprotAnnotator
+              .uniProtToHgnc(new MiriamData(MiriamType.UNIPROT, uniprotId));
+          result.setAnnotator(null);
+        } catch (UniprotSearchException e) {
+          throw new DrugSearchException(e);
+        }
       }
     }
     return result;
diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ChEMBLParserTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ChEMBLParserTest.java
index 0b4f0d4dd5..8fa920f651 100644
--- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ChEMBLParserTest.java
+++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ChEMBLParserTest.java
@@ -273,6 +273,19 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
 
   }
 
+  @Test
+  public void testGetTargetWithRnaComponent() throws Exception {
+    try {
+      Target test = chemblParser.getTargetFromId(new MiriamData(MiriamType.CHEMBL_TARGET, "CHEMBL2363135"));
+
+      assertEquals(test.getSource().getResource(), "CHEMBL2363135");
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+
+  }
+
   @Test
   public void testGetTargetFromInvalidId() throws Exception {
     try {
-- 
GitLab