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

when hgnc annotator uses element name, only first part before whitespace is...

when hgnc annotator uses element name, only first part before whitespace is processed as an identifier
parent 401e56a2
No related branches found
No related tags found
1 merge request!345Resolve "Genes annotations don't show"
...@@ -237,17 +237,17 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService ...@@ -237,17 +237,17 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
} }
} }
} }
} }
} }
} }
} catch (WrongResponseCodeIOException e) { } catch (WrongResponseCodeIOException e) {
logger.warn(prefix + "Cannot find information for element."); logger.warn(prefix + "Cannot find information for element.");
} catch (Exception e) { } catch (Exception e) {
throw new AnnotatorException(e); throw new AnnotatorException(e);
} }
} }
} }
/** /**
* Creates query url for given {@link MiriamType#HGNC} identifier. * Creates query url for given {@link MiriamType#HGNC} identifier.
...@@ -265,10 +265,12 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService ...@@ -265,10 +265,12 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
* *
* @param name * @param name
* {@link MiriamType#HGNC_SYMBOL} * {@link MiriamType#HGNC_SYMBOL}
* @return url to restful api webpage for given hgnc symbol * @return url to restful API web page for given HGNC symbol
*/ */
private String getHgncNameUrl(String name) { private String getHgncNameUrl(String name) {
return REST_API_URL + "symbol/" + name; String hgncSymbol = "" + name;
hgncSymbol = hgncSymbol.split("\\s+")[0];
return REST_API_URL + "symbol/" + hgncSymbol;
} }
/** /**
...@@ -304,34 +306,34 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService ...@@ -304,34 +306,34 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
} else { } else {
Node entry = getNode("doc", resultNode.getChildNodes()); Node entry = getNode("doc", resultNode.getChildNodes());
NodeList list = entry.getChildNodes(); NodeList list = entry.getChildNodes();
for (int i = 0; i < list.getLength(); i++) { for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i); Node node = list.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeType() == Node.ELEMENT_NODE) {
if (node.getNodeName().equals("arr")) { if (node.getNodeName().equals("arr")) {
String type = getNodeAttr("name", node); String type = getNodeAttr("name", node);
if (type.equals("uniprot_ids")) { if (type.equals("uniprot_ids")) {
NodeList uniprotList = node.getChildNodes(); NodeList uniprotList = node.getChildNodes();
for (int j = 0; j < uniprotList.getLength(); j++) { for (int j = 0; j < uniprotList.getLength(); j++) {
Node uniprotNode = uniprotList.item(j); Node uniprotNode = uniprotList.item(j);
if (uniprotNode.getNodeType() == Node.ELEMENT_NODE) { if (uniprotNode.getNodeType() == Node.ELEMENT_NODE) {
if (uniprotNode.getNodeName().equals("str")) { if (uniprotNode.getNodeName().equals("str")) {
result.add(createMiriamData(MiriamType.UNIPROT, uniprotNode.getTextContent())); result.add(createMiriamData(MiriamType.UNIPROT, uniprotNode.getTextContent()));
} }
} }
} }
} }
} }
} }
} }
} }
return result; return result;
} catch (WrongResponseCodeIOException e) { } catch (WrongResponseCodeIOException e) {
logger.warn("No HGNC data found for id: "+miriamData); logger.warn("No HGNC data found for id: " + miriamData);
return new ArrayList<>(); return new ArrayList<>();
} catch (Exception e) { } catch (Exception e) {
throw new AnnotatorException(e); throw new AnnotatorException(e);
} }
} }
/** /**
......
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