Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions exports/config_template.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Dataset selection
dataset_selection = { '<dataset_column>': '<dataset_value(s)>' }
# e.g.:
# 'publication_id': 1
# 'num': 208
# 'id__in': ['OPD000056','OPD000105','OPD000154','OPD000203']
# 'num__in': ['56','105','154','203']

# Metadata exports
metadata_exports_publication_id = '<publication_id, e.g. 1>'
Expand All @@ -6,7 +13,6 @@
# PheWAS exports
phewas_exports_dir = '<path_to_directory>'


# SQLite exports
sqlite_default_values = {
'opp_id': '<dataset_id>', # e.g. OPP000003
Expand All @@ -17,7 +23,6 @@
'use_different_id_as_gene': '<opgs_id_OR_name>' # Use the OmicsPred ID, the score name in the 'gene' column or not. None if the key is missing
}


# Scoring files exports - only for PredictDB studies
scoring_file_config = {
'pmid': '<pubmed ID>', # e.g. 32913098
Expand Down
19 changes: 19 additions & 0 deletions exports/datasets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django.db.models import Q
from omicspred.models import Dataset
from exports.config import dataset_selection

class DatasetsSelection():

def __init__(self):
print(f'dataset_selection: {dataset_selection}')
ds_keys = list(dataset_selection.keys())
print(f'dataset_selection keys: {ds_keys}')
self.dataset_col = ds_keys[0]
self.dataset_value = dataset_selection[self.dataset_col]

def get_datasets(self) -> list:
param = self.dataset_col
param = Q(**{f'{self.dataset_col}':self.dataset_value})

datasets = Dataset.objects.filter(param).order_by('num')
return datasets
10 changes: 5 additions & 5 deletions exports/scripts/generate_metadata_exports.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from datetime import date
from omicspred.models import Dataset
from exports.metadata_build_export import MetadataExport
from exports.datasets import DatasetsSelection
from exports.config import metadata_exports_dir, metadata_exports_publication_id, sqlite_exports_dir
from django.db.models import Q


def run():
# datasets = Dataset.objects.filter(Q(publication_id=metadata_exports_publication_id) & Q(name__icontains='sQTL - Enet')).order_by('num')
# datasets = Dataset.objects.filter(Q(publication_id=metadata_exports_publication_id) & Q(num__lte=56)).order_by('num')
datasets = Dataset.objects.filter(publication_id=metadata_exports_publication_id).order_by('num')
# datasets = Dataset.objects.all().order_by('num')
# datasets = Dataset.objects.filter(num=6).order_by('num')
# Fetch dataset(s)
ds_selection = DatasetsSelection()
datasets = ds_selection.get_datasets()

print("## Start metadata exports, dataset by dataset")
datasets_total = len(datasets)
count_dataset = 0
Expand Down
19 changes: 5 additions & 14 deletions exports/scripts/generate_phewas_exports.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
from omicspred.models import Dataset
from exports.phewas_export import PheWASExport
from exports.datasets import DatasetsSelection
from exports.config import phewas_exports_dir
# from django.db.models import Q


# Need to run first the script import/phewas/add_mappings (and store the SQLite file in <raw_file_dir>/metadata)

def run():
# datasets = Dataset.objects.filter(Q(publication_id=metadata_exports_publication_id) & Q(name__icontains='sQTL - Enet')).order_by('num')
# datasets = Dataset.objects.filter(Q(publication_id=metadata_exports_publication_id) & Q(num__lte=56)).order_by('num')
# datasets = Dataset.objects.filter(publication_id=metadata_exports_publication_id).order_by('num')
# datasets = Dataset.objects.all().order_by('num')
datasets = Dataset.objects.filter(publication_id=6).order_by('num')
# datasets = Dataset.objects.filter(id__in=['OPD000056','OPD000105','OPD000154','OPD000203'])
# datasets = Dataset.objects.filter(id__in=['OPD000204','OPD000205','OPD000208','OPD000209','OPD000210','OPD000211','OPD000212','OPD000213']).order_by('num')
# datasets = Dataset.objects.filter(num__in=[2]).order_by('num')
# Fetch dataset(s)
ds_selection = DatasetsSelection()
datasets = ds_selection.get_datasets()

print("## Start PheWAS exports, dataset by dataset")
datasets_total = len(datasets)
count_dataset = 0
Expand All @@ -26,10 +22,5 @@ def run():

# Prepare data for exports - only DB
phewas_export = PheWASExport(phewas_export_file, phewas_exports_dir, dataset)

# Prepare data for exports - DB + file
# raw_file_dir = '/Users/lg10/Workspace/datafiles/OmicsPred/phenotypes'
# phewas_exports_dir_all = f'{phewas_exports_dir}/all'
# phewas_export = PheWASExport(phewas_export_file, phewas_exports_dir_all, dataset, raw_file_dir)

phewas_export.generate_export()
4 changes: 3 additions & 1 deletion exports/scripts/generate_sqlite_files.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from omicspred.models import *
from exports.sqlite_export import SqliteExport
from exports.datasets import DatasetsSelection
from exports.config import sqlite_default_values


Expand Down Expand Up @@ -98,7 +99,8 @@ def run(*args):
skip_zip = sqlite_default_values['skip_zip']

# Fetch dataset(s)
datasets = Dataset.objects.filter(publication__id=opp_id).order_by('id')
ds_selection = DatasetsSelection()
datasets = ds_selection.get_datasets()
# Create SqliteExport object
sqlite_export = SqliteExport(opp_id,output_sqlite_dir,scoring_files_dir,datasets,use_different_id_as_gene)
# Generate SQLite export file(s)
Expand Down
Loading