预期String是org.neo4j.values.virtual.VirtualNodeValue,但它是org.neo4j.values.storable.StringWrappingStringValue

时间:2019-01-16 21:26:14

标签: python neo4j neo4jrestclient

我正在尝试使用python和Neo4jrestclient将基因组数据解析为Neo4j。我正在尝试按标签(Allele)匹配特定的节点,然后匹配两个属性(posbp)。对于脚本的最后部分,我有以下代码:

if h1 and h2 == 0:
        q1 = """MATCH (n:Allele) WHERE n.pos:`{pos}` AND n.bp:`{bp}` RETURN n"""
        params = {
            "pos": int(pos[j]), "bp": str(ref[j]),
        }
        result = db.query(q1, params=params)
        q1.relationships.create("Homozygous", s1, HTA=h1, HTB=h2, GT=str(h1) + '|' + str(h2), seq_tech=seq_tech, dp=read_depth, phase_set=ps1, PL0=PL0, PL1=PL1, PL2=PL2, GP0=GP0, GP1=GP1, GP2=GP2)

    elif h1 == 0 and h2 > 0:
        q1 = """MATCH (n:Allele) WHERE n.pos:`{pos}` AND n.bp:`{bp}` RETURN n"""
        params = {
            "pos": int(pos[j]), "bp": str(ref[j]),
        }
        result = db.query(q1, params=params)
        q2 = """MATCH (n:Allele) WHERE n.pos:`{pos}` AND n.bp:`{bp}` RETURN n"""
        params = {
            "pos": int(pos[j]), "bp": str(alt[j][h2]),
        }
        result = db.query(q2, params=params)
        q1.relationships.create("Heterozygous, Haplotype A", s1, HTA=h1, GT=str(h1) + '|' + str(h2), seq_tech=seq_tech, dp=read_depth, phase_set=ps1, PL0=PL0, PL1=PL1, PL2=PL2, GP0=GP0, GP1=GP1, GP2=GP2)
        q2.relationships.create("Heterozygous, Haplotype B", s1, HTB=h2, GT=str(h1) + '|' + str(h2), seq_tech=seq_tech, dp=read_depth, phase_set=ps1, PL0=PL0, PL1=PL1, PL2=PL2, GP0=GP0, GP1=GP1, GP2=GP2)

    elif h1 > 0 and h2 == 0:
        q1 = """MATCH (n:Allele) WHERE n.pos:`{pos}` AND n.bp:`{bp}` RETURN n"""
        params = {
            "pos": int(pos[j]), "bp": str(alt[j][h1]),
        }
        result = db.query(q1, params=params)
        q2 = """MATCH (n:Allele) WHERE n.pos:`{pos}` AND n.bp:`{bp}` RETURN n"""
        params = {
            "pos": int(pos[j]), "bp": str(ref[j]),
        }
        result = db.query(q2, params=params)
        q1.relationships.create("Heterozygous, Haplotype A", s1, HTA=h1, GT=str(h1) + '|' + str(h2), seq_tech=seq_tech, dp=read_depth, phase_set=ps1, PL0=PL0, PL1=PL1, PL2=PL2, GP0=GP0, GP1=GP1, GP2=GP2)
        q2.relationships.create("Heterozygous, Haplotype B", s1, HTB=h2, GT=str(h1) + '|' + str(h2), seq_tech=seq_tech, dp=read_depth, phase_set=ps1, PL0=PL0, PL1=PL1, PL2=PL2, GP0=GP0, GP1=GP1, GP2=GP2)            

    elif h1 == h2 and h1 > 0:
        q1 = """MATCH (n:Allele) WHERE n.pos:`{pos}` AND n.bp:`{bp}` RETURN n"""
        params = {
            "pos": int(pos[j]), "bp": str(alt[j][h1]),
        }
        result = db.query(q1, params=params)
        q1.relationships.create("Homozygous", s1, HTA=h1, HTB=h2, GT=str(h1) + '|' + str(h2), seq_tech=seq_tech, dp=read_depth, phase_set=ps1, PL0=PL0, PL1=PL1, PL2=PL2, GP0=GP0, GP1=GP1, GP2=GP2)

    else:
        q1 = """MATCH (n:Allele) WHERE n.pos:`{pos}` AND n.bp:`{bp}` RETURN n"""
        params = {
            "pos": int(pos[j]), "bp": str(alt[j][h1]),
        }
        result = db.query(q1, params=params)
        q2 = """MATCH (n:Allele) WHERE n.pos:`{pos}` AND n.bp:`{bp}` RETURN n"""
        params = {
            "pos": int(pos[j]), "bp": str(alt[j][h2]),
        }
        result = db.query(q2, params=params)
        q1.relationships.create("Heterozygous, Haplotype A", s1, HTA=h1, GT=str(h1) + '|' + str(h2), seq_tech=seq_tech, dp=read_depth, phase_set=ps1, PL0=PL0, PL1=PL1, PL2=PL2, GP0=GP0, GP1=GP1, GP2=GP2)
        q2.relationships.create("Heterozygous, Haplotype B", s1, HTB=h2, GT=str(h1) + '|' + str(h2), seq_tech=seq_tech, dp=read_depth, phase_set=ps1, PL0=PL0, PL1=PL1, PL2=PL2, GP0=GP0, GP1=GP1, GP2=GP2)

我感觉自己几乎可以解决问题了(我对Neo4jrestclient来说还很新),但是我遇到了以下错误,并且似乎在任何在线位置都找不到错误消息的引用:< / p>

    TransactionException                      Traceback (most recent call last)
<ipython-input-34-64544466d5e0> in <module>()
    192                 "pos": int(pos[j]), "bp": str(alt[j][h1]),
    193             }
--> 194             result = db.query(q1, params=params)
    195             q1.relationships.create("Homozygous", s1, HTA=h1, HTB=h2, GT=str(h1) + '|' + str(h2), seq_tech=seq_tech, dp=read_depth, phase_set=ps1, PL0=PL0, PL1=PL1, PL2=PL2, GP0=GP0, GP1=GP1, GP2=GP2)
    196 

~/anaconda3/lib/python3.6/site-packages/neo4jrestclient/client.py in query(self, q, params, returns, data_contents, tx)
    210                 self._cypher, self._auth, q=q, params=params,
    211                 types=types, returns=returns, data_contents=data_contents,
--> 212                 tx=tx
    213             )
    214             if tx is not None and tx.id in self._transactions:

~/anaconda3/lib/python3.6/site-packages/neo4jrestclient/query.py in __init__(self, cypher, auth, q, params, types, returns, lazy, data_contents, tx)
    322             tx.append(q=self.q, params=self.params, returns=self._returns,
    323                       data_contents=data_contents, obj=self)
--> 324             tx.execute()
    325         elif not lazy:
    326             self._get_elements()

~/anaconda3/lib/python3.6/site-packages/neo4jrestclient/query.py in execute(self)
    934         if self.auto_execute:
    935             self.url_commit = None
--> 936             return self.commit()
    937         if not self.url_tx:
    938             self._begin()

~/anaconda3/lib/python3.6/site-packages/neo4jrestclient/query.py in commit(self)
    946         else:
    947             url = u"{}/commit".format(self.url_begin)
--> 948         results = self._execute(url, results=True)
    949         self.finished = True
    950         return results

~/anaconda3/lib/python3.6/site-packages/neo4jrestclient/query.py in _execute(self, url, results)
    865         response = self._request(url, statements=self.statements)
    866         content = response.json()
--> 867         self._manage_errors(content["errors"])
    868         _results = self._update(content["results"])
    869         self.executed = self.references

~/anaconda3/lib/python3.6/site-packages/neo4jrestclient/query.py in _manage_errors(self, errors)
    839                     message, error["code"], error["message"]
    840                 )
--> 841             raise TransactionException(200, message)
    842 
    843     def _begin(self):

TransactionException: Code [200]: OK. Request fulfilled, document follows.

Neo.ClientError.Statement.TypeError:
Expected String("T") to be a org.neo4j.values.virtual.VirtualNodeValue, but it was a org.neo4j.values.storable.StringWrappingStringValue

我假设我要传递的“ bp”值作为参数存在问题,但是我在每个参数以及脚本的前面都使用过str()来确保。该密码可在Neo4j浏览器中使用,因此我猜测这与通过API传递的信息有关。

0 个答案:

没有答案