Skip to content

Instantly share code, notes, and snippets.

@yochannah
Created June 12, 2019 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yochannah/da70107869bd57e739a47aad07ccb936 to your computer and use it in GitHub Desktop.
Save yochannah/da70107869bd57e739a47aad07ccb936 to your computer and use it in GitHub Desktop.
more InterMineR error logging

This will produce a 400 error in the current (June 2019) InterMineR version.

library(InterMineR)

# Begin by initialising against an InterMine - in this case HumanMine
im <- initInterMine(mine=listMines()["HumanMine"], "SOME TOP SECRET TOKEN")

# initialise a variable to hold a new query
expressedPancreas = newQuery()

# Fetch
data("PL_DiabetesGenes")

pancreasConstraint1 = setConstraints(
  paths = c("Gene", "Gene.proteinAtlasExpression.level", "Gene.proteinAtlasExpression.tissue.name"),
  operators = c("IN", "ONE OF", "="),
  values = list("PL_DiabetesGenes", c("Medium", "High"), "Pancreas")
)

expressedPancreas = setQuery(
  select = c("Gene.primaryIdentifier",
             "Gene.symbol",
             "Gene.proteinAtlasExpression.cellType",
             "Gene.proteinAtlasExpression.level",
             "Gene.proteinAtlasExpression.tissue.name"
  ),
  where = pancreasConstraint1
)

query_results <-  runQuery(im = im, qry = expressedPancreas)

The reason for the error is that the query is malformed - this is the XML InterMineR produces

<query name="" model="genomic" view="Gene.primaryIdentifier Gene.symbol Gene.proteinAtlasExpression.cellType Gene.proteinAtlasExpression.level Gene.proteinAtlasExpression.tissue.name" longDescription="" sortOrder="Gene.primaryIdentifier ASC">
  <constraint path="Gene" value="PL_DiabetesGenes" code="A" op="IN" extraValue=""/>
  <constraint path="Gene.proteinAtlasExpression.level" value="Medium" code="B" op="ONE OF" extraValue=""/>
  <constraint path="Gene.proteinAtlasExpression.tissue.name" value="Pancreas" code="C" op="=" extraValue=""/>
</query> 

But ONE OF should convert to XML like this:

<query name="" model="genomic" view="Gene.primaryIdentifier Gene.symbol Gene.proteinAtlasExpression.cellType Gene.proteinAtlasExpression.level Gene.proteinAtlasExpression.tissue.name" longDescription="" sortOrder="Gene.primaryIdentifier ASC">
  <constraint path="Gene" value="PL_DiabetesGenes" code="A" op="IN" extraValue=""/>
  <constraint path="Gene.proteinAtlasExpression.level" op="ONE OF" code="B" >
    <value>Medium</value>
    <value>High</value>
  </constraint>
  <constraint path="Gene.proteinAtlasExpression.tissue.name" value="Pancreas" code="C" op="=" extraValue=""/>
</query> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment