Skip to content

Commit

Permalink
added p prefix to affinity parameter, discarding empty affinity or af…
Browse files Browse the repository at this point in the history
…finity parameter
  • Loading branch information
EvanDietzMorris committed Oct 3, 2023
1 parent eb24239 commit f0b932a
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions parsers/PHAROS/src/loadPHAROS.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PHAROSLoader(SourceDataLoader):
source_data_url = "https://pharos.nih.gov/"
license = "Data accessed from Pharos and TCRD is publicly available from the primary sources listed above. Please respect their individual licenses regarding proper use and redistribution."
attribution = 'Sheils, T., Mathias, S. et al, "TCRD and Pharos 2021: mining the human proteome for disease biology", Nucl. Acids Res., 2021. DOI: 10.1093/nar/gkaa993'
parsing_version: str = '1.4'
parsing_version: str = '1.5'

GENE_TO_DISEASE_QUERY: str = """select distinct x.value, d.did, d.name, p.sym, d.dtype, d.score
from disease d
Expand Down Expand Up @@ -100,16 +100,15 @@ def parse_data(self) -> dict:
:return: parsed meta data results
"""

if self.ping_pharos_db():
self.logger.info('Pinging PHAROS database successful..')
else:
error_message = "PHAROS DB was not accessible. " \
"Manually stand up PHAROS DB and configure environment variables before trying again."
raise SourceDataFailedError(error_message=error_message)

final_record_count: int = 0
final_skipped_count: int = 0
final_record_count = 0
final_skipped_count = 0

# get the nodes and edges for each dataset
self.logger.info('Querying for gene to disease..')
Expand Down Expand Up @@ -141,11 +140,8 @@ def parse_data(self) -> dict:

def parse_gene_to_disease(self) -> (int, int):
"""
gets gene to disease records from the pharos DB and creates nodes
:param node_list: list, the node list to append this data to
:return: list, the node list and record counters
gets gene to disease records from the pharos DB and creates nodes and edges
"""
# init the record counters
record_counter: int = 0
skipped_record_counter: int = 0

Expand Down Expand Up @@ -210,11 +206,9 @@ def parse_gene_to_disease(self) -> (int, int):

def parse_gene_to_drug_activity(self) -> (int, int):
"""
gets gene to drug activity records from the pharos DB and creates nodes
:param node_list: list, the node list to append this data to
gets gene to drug activity records from the pharos DB and creates nodes and edges
:return: list, the node list and record counters
"""
# init the record counters
record_counter: int = 0
skipped_record_counter: int = 0

Expand Down Expand Up @@ -269,11 +263,9 @@ def parse_gene_to_drug_activity(self) -> (int, int):

def parse_gene_to_cmpd_activity(self) -> (int, int):
"""
gets gene to compound activity records from the pharos DB and creates nodes
:param node_list: list, the node list to append this data to
gets gene to compound activity records from the pharos DB and creates nodes and edges
:return: list, the node list and record counters
"""
# init the record counters
record_counter: int = 0
skipped_record_counter: int = 0

Expand Down Expand Up @@ -356,9 +348,13 @@ def get_edge_props(self, result) -> (str, list, dict, str):

# if there was affinity data save it
props: dict = {}
if result['affinity'] is not None:
props['affinity'] = float(result['affinity'])
props['affinity_parameter'] = result['affinity_parameter']
affinity = result['affinity']
if affinity is not None and affinity != '':
props['affinity'] = float(affinity)

affinity_paramater = result['affinity_parameter']
if affinity_paramater:
props['affinity_parameter'] = f'p{result["affinity_parameter"]}'

# return to the caller
return predicate, pmids, props, provenance
Expand Down

0 comments on commit f0b932a

Please sign in to comment.