Skip to content

Commit

Permalink
inputs.diseases: bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ervau committed Dec 6, 2023
1 parent 2d97ffb commit ebc5765
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions pypath/inputs/diseases.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from typing import Generator, Literal

import collections
from collections import namedtuple

import pandas as pd

Expand Down Expand Up @@ -75,7 +75,7 @@ def _diseases_general(

query_type = 'filtered' if filtered else 'full'

url = urls['diseases']['url'] % (data_origin, query_type)
url = urls.urls['diseases']['url'] % (data_origin, query_type)

query_fields = {
'textmining':
Expand All @@ -84,7 +84,7 @@ def _diseases_general(
'confidence',
'url'
],
'knowlwdge':
'knowledge':
[
'resource',
'evidence_type',
Expand Down Expand Up @@ -118,21 +118,25 @@ def proc_field(value, key):
value = value.split('=')[1]

if key in _NUMERIC_FIELDS:

if '.' in value:
num_type = float
else:
num_type = int if common.is_int(value) else float

num_type = int if common.is_int(value) else float
value = num_type(value)

return value
return (key, value)


for line in c.result:

line = line.strip('\n ').split('\t')

line = [
proc_field(v, f)
for f, v in zip(fields, line)
]
line = dict(
proc_field(value, key)
for key, value in zip(fields, line)
)

yield record(**line)

Expand Down

0 comments on commit ebc5765

Please sign in to comment.