Skip to content

Commit

Permalink
Merge branch 'pr264'
Browse files Browse the repository at this point in the history
  • Loading branch information
deeenes committed Sep 28, 2023
2 parents 8df8c8c + 60b8ac5 commit 3122e66
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 44 deletions.
3 changes: 2 additions & 1 deletion pypath/inputs/lncdisease.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import pypath.resources.urls as urls
import pypath.share.curl as curl
import pypath.utils.taxonomy as taxonomy


def lncdisease_interactions():
Expand Down Expand Up @@ -53,7 +54,7 @@ def lncdisease_interactions():
source_type = l[3].split('-')[0],
target_type = l[3].split('-')[1] if '-' in l[3] else '',
mechanism = l[4].lower(),
organism = l[6].lower(),
organism = taxonomy.ensure_ncbi_tax_id(l[6]),
pmid = l[9],
)
)
Expand Down
3 changes: 2 additions & 1 deletion pypath/inputs/lncrnadb.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import pypath.resources.urls as urls
import pypath.share.curl as curl
import pypath.utils.taxonomy as taxonomy


def lncrnadb_interactions():
Expand Down Expand Up @@ -73,7 +74,7 @@ def lncrnadb_interactions():
lncrna = lncrna,
partner = partner,
type = typ,
organism = organism,
organism = taxonomy.ensure_ncbi_tax_id(organism),
pmid = pmid,
)
)
Expand Down
5 changes: 3 additions & 2 deletions pypath/inputs/mirecords.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import pypath.resources.urls as urls
import pypath.share.curl as curl
import pypath.inputs.common as inputs_common
import pypath.utils.taxonomy as taxonomy


def mirecords_interactions():
Expand Down Expand Up @@ -54,8 +55,8 @@ def mirecords_interactions():
mirna_name = l[6],
target_refseq = l[3],
target_genesymbol = l[2],
mirna_organism = l[1],
target_organism = l[5],
mirna_organism = taxonomy.ensure_ncbi_tax_id(l[1]),
target_organism = taxonomy.ensure_ncbi_tax_id(l[5]),
pmid = l[0].split('.')[0],
)
for l in
Expand Down
8 changes: 6 additions & 2 deletions pypath/inputs/mirtarbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import pypath.resources.urls as urls
import pypath.share.curl as curl
import pypath.inputs.common as inputs_common
import pypath.utils.taxonomy as taxonomy


def mirtarbase_interactions(curated = True, strong = True, all = False):
Expand Down Expand Up @@ -82,10 +83,13 @@ def _mirtarbase_interactions(dataset):

return [
MirtarbaseInteraction(
*l[:6],
*l[:2],
taxonomy.ensure_ncbi_tax_id(l[2]),
*l[3:5],
taxonomy.ensure_ncbi_tax_id(l[5]),
l[6] if dataset == 'curated' else None,
*l[-3:],
dataset
dataset,
)
for l in tbl[1:]
]
13 changes: 7 additions & 6 deletions pypath/inputs/trrust.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

from pypath.share import curl
from pypath.resources.urls import urls
from pypath.utils import taxonomy
from pypath.share import session
from pypath.utils import taxonomy

_log = session.Logger(name = 'trrust_input')._log

Expand All @@ -39,14 +39,14 @@ def trrust_interactions(
Args:
organism:
Either "human" or "mouse".
Name or NCBI Taxonomy ID of the organism. Human and mouse
are available in TRRUST.
"""

organisms = {'human', 'mouse'}
_organism = taxonomy.ensure_common_name(organism, lower = True)

organism_ = taxonomy.ensure_common_name(organism, lower = True)

if organism not in organisms:
if _organism not in organisms:

err = f'Only human and mouse are availble in TRRUST, not `{organism}`.'
_log(err)
Expand All @@ -67,7 +67,7 @@ def __new__(cls, line):
return super().__new__(cls, *line[:-1], refs)


url = urls['trrust']['tsv_url'] % organism_
url = urls['trrust']['tsv_url'] % _organism

c = curl.Curl(
url,
Expand All @@ -86,6 +86,7 @@ def trrust_human():

return trrust_interactions('human')


def trrust_mouse():

return trrust_interactions('mouse')
38 changes: 7 additions & 31 deletions pypath/resources/data_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import pypath.resources.urls as urls
import pypath.share.common as common
import pypath.share.constants as constants
import pypath.utils.taxonomy as taxonomy


__all__ = [
Expand Down Expand Up @@ -2658,16 +2657,9 @@ def _pathwaycommons_single_resource(resource, transcription = False):
is_directed = True,
sign = False,
ncbi_tax_id = {
'A': {
'col': 3,
'dict': taxonomy.latin_name_to_ncbi_tax_id,
'include': {9606},
},
'B': {
'col': 4,
'dict': taxonomy.latin_name_to_ncbi_tax_id,
'include': {9606},
}},
'A': {'col': 3, 'include': {9606}},
'B': {'col': 4, 'include': {9606}},
},
input = 'mirecords.mirecords_interactions',
interaction_type = 'post_transcriptional',
references = 5,
Expand All @@ -2689,16 +2681,8 @@ def _pathwaycommons_single_resource(resource, transcription = False):
is_directed = True,
sign = False,
ncbi_tax_id = {
'A': {
'col': 2,
'dict': taxonomy.latin_name_to_ncbi_tax_id,
'include': {9606},
},
'B': {
'col': 5,
'dict': taxonomy.latin_name_to_ncbi_tax_id,
'include': {9606},
},
'A': {'col': 2, 'include': {9606}},
'B': {'col': 5, 'include': {9606}},
},
positive_filters = [(8, 'Functional MTI')],
input = 'mirtarbase.mirtarbase_interactions',
Expand Down Expand Up @@ -2854,11 +2838,7 @@ def _pathwaycommons_single_resource(resource, transcription = False):
entity_type_b = 'protein',
is_directed = True,
sign = False,
ncbi_tax_id= {
'col': 5,
'dict': common.swap_dict(taxonomy.taxids),
'include': set([9606])
},
ncbi_tax_id = {'col': 5, 'include': {9606}},
positive_filters = [(2, 'RNA'), (3, 'Protein')],
input = 'lncdisease.lncdisease_interactions',
interaction_type = 'lncrna_post_transcriptional',
Expand All @@ -2882,11 +2862,7 @@ def _pathwaycommons_single_resource(resource, transcription = False):
entity_type_b = 'protein',
is_directed = True,
sign = False,
ncbi_tax_id= {
'col': 3,
'dict': common.swap_dict(taxonomy.phosphoelm_taxids),
'include': set([9606])
},
ncbi_tax_id = {'col': 3, 'include': {9606}},
positive_filters = [(2, 'protein')],
input = 'lncrnadb.lncrnadb_interactions',
interaction_type = 'lncrna_post_transcriptional',
Expand Down
3 changes: 2 additions & 1 deletion pypath/utils/taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@ def init_db(key):

if swap:

this_db = common.swap_dict_simple(this_db)
this_db = common.swap_dict(this_db)
this_db = {k: min(v, key = len) for k, v in this_db.items()}

else:

Expand Down

0 comments on commit 3122e66

Please sign in to comment.